Compare commits
18 Commits
19d6637a29
...
tahrion_te
| Author | SHA1 | Date | |
|---|---|---|---|
| cfa75bd8f3 | |||
| b08f808167 | |||
| eb69779b0d | |||
| b0fc925750 | |||
| e12b0d64e5 | |||
| efcee33a02 | |||
| ce778673c7 | |||
| 5ec4bdd933 | |||
| 6332f23bf3 | |||
| 966af2328a | |||
| d08ee33400 | |||
| ba97a8f36f | |||
| ef6c0d9fe6 | |||
| c3bdb29852 | |||
| 6904090d19 | |||
| f3c5beb341 | |||
| fc90ae54c0 | |||
| 0952e96452 |
@@ -1,3 +1,6 @@
|
|||||||
|
local tableConcat, tableKeyValueList, tableInsert
|
||||||
|
= table.concat, table.key_value_list, table.insert
|
||||||
|
|
||||||
local getInstance = Class.getInstance
|
local getInstance = Class.getInstance
|
||||||
|
|
||||||
---@class Formspec
|
---@class Formspec
|
||||||
@@ -107,25 +110,26 @@ function Formspec:new(def)
|
|||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
---TODO: описание
|
---Returns a string specifying the form parameters:
|
||||||
|
---`version`, `size`, `position`, `anchor`, `padding`, `no_prepend`, `real_coordinates`, `allowClose`.
|
||||||
---@return string
|
---@return string
|
||||||
function Formspec:getParams()
|
function Formspec:getParams()
|
||||||
return self.params
|
return self.params
|
||||||
end
|
end
|
||||||
|
|
||||||
---TODO: описание
|
---Returns a string containing all elements registered in the form.
|
||||||
---@return string
|
---@return string
|
||||||
function Formspec:getElements()
|
function Formspec:getElements()
|
||||||
return self.elements
|
return self.elements
|
||||||
end
|
end
|
||||||
|
|
||||||
---TODO: описание
|
---Returns a formspec string that is a form definition for Luanti.
|
||||||
---@return string
|
---@return string
|
||||||
function Formspec:toString()
|
function Formspec:toString()
|
||||||
return self:getParams()..self:getElements()
|
return self:getParams()..self:getElements()
|
||||||
end
|
end
|
||||||
|
|
||||||
---TODO: описание
|
---Adds an element to the list of form elements.
|
||||||
---@param element string
|
---@param element string
|
||||||
function Formspec:addElement(element)
|
function Formspec:addElement(element)
|
||||||
self.elements = self.elements..element
|
self.elements = self.elements..element
|
||||||
@@ -138,13 +142,15 @@ end
|
|||||||
---@param container Formspec
|
---@param container Formspec
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
|
---@return Formspec
|
||||||
function Formspec:container(container, x, y)
|
function Formspec:container(container, x, y)
|
||||||
local element = ('container[%s,%s]'):format(x, y)..container:getElements()..'container_end[]'
|
local element = ('container[%s,%s]'):format(x, y)..container:getElements()..'container_end[]'
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Start of a scroll_container block. All contained elements will
|
---Create scroll_container block. All contained elements will
|
||||||
---take the scroll_container coordinate as position origin,
|
---take the scroll_container coordinate as position origin,
|
||||||
---be additionally moved by the current value of the scrollbar with
|
---be additionally moved by the current value of the scrollbar with
|
||||||
---the name `scrollbar name` times `scroll factor` along the orientation `orientation` and
|
---the name `scrollbar name` times `scroll factor` along the orientation `orientation` and
|
||||||
@@ -159,13 +165,16 @@ end
|
|||||||
---@param scrollbarName string
|
---@param scrollbarName string
|
||||||
---@param orientation 'vertical'|'horizontal'
|
---@param orientation 'vertical'|'horizontal'
|
||||||
---@param scrollFactor number? Defaults to 0.1.
|
---@param scrollFactor number? Defaults to 0.1.
|
||||||
---@param contentPadding string? TODO: разобраться, что тут
|
---@param contentPadding number? In formspec coordinate units. If specified, the scrollbar properties `max` and `thumbsize` are calculated
|
||||||
|
--- automatically based on the content size plus `content padding` at the end of the container. `min` is set to `0`.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:scrollContainer(container, x, y, w, h, scrollbarName, orientation, scrollFactor, contentPadding)
|
function Formspec:scrollContainer(container, x, y, w, h, scrollbarName, orientation, scrollFactor, contentPadding)
|
||||||
local element = ('scroll_container[%s,%s;%s,%s;%s;%s;%s;%s]'):format(
|
local element = ('scroll_container[%s,%s;%s,%s;%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, scrollbarName, orientation, scrollFactor or '', contentPadding or '')..
|
x, y, w, h, scrollbarName, orientation, scrollFactor or '', contentPadding or '')..
|
||||||
container:getElements()..'scroll_container_end[]'
|
container:getElements()..'scroll_container_end[]'
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---@alias Formspec.ListDef {inventoryLocation:string, listName:string, x:number, y:number, w:number, h:number,startingItemIndex:number}
|
---@alias Formspec.ListDef {inventoryLocation:string, listName:string, x:number, y:number, w:number, h:number,startingItemIndex:number}
|
||||||
@@ -185,29 +194,35 @@ end
|
|||||||
---@param w number Are in inventory slots, not in coordinates.
|
---@param w number Are in inventory slots, not in coordinates.
|
||||||
---@param h number Are in inventory slots, not in coordinates.
|
---@param h number Are in inventory slots, not in coordinates.
|
||||||
---@param startingItemIndex number? The index of the first (upper-left) item to draw. Indices start at `0`. Default is `0`.
|
---@param startingItemIndex number? The index of the first (upper-left) item to draw. Indices start at `0`. Default is `0`.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:list(inventoryLocation, listName, x, y, w, h, startingItemIndex)
|
function Formspec:list(inventoryLocation, listName, x, y, w, h, startingItemIndex)
|
||||||
local element = ('list[%s;%s;%s,%s;%s,%s;%s]'):format(
|
local element = ('list[%s;%s;%s,%s;%s,%s;%s]'):format(
|
||||||
inventoryLocation, listName, x, y, w, h,startingItemIndex or '')
|
inventoryLocation, listName, x, y, w, h,startingItemIndex or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---TODO: немного отличается от листринга луанти, так что надо дописать подробности
|
---Creates and appends a list of `listring[<inventory location>;<list name>]` items based on the passed inventory list.
|
||||||
---
|
---
|
||||||
---**Elements:** `listring[<inventory location>;<list name>]` or `listring[]`
|
---**Elements:** `listring[<inventory location>;<list name>]` or `listring[]`
|
||||||
---@param lists [string, string][]? List of looping lists in the format `[inventory location, list name]`
|
---@param lists [string, string][]? List of looping lists in the format `[inventory location, list name]`. If `nil`, it will be added `listring[]`.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:listring(lists)
|
function Formspec:listring(lists)
|
||||||
if lists == nil then
|
if lists == nil then
|
||||||
self:addElement('listring[]')
|
self:addElement('listring[]')
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
local element = ''
|
local element = ''
|
||||||
|
|
||||||
for list in lists do
|
for _, list in pairs(lists) do
|
||||||
element = element..('listring[%s;%s]'):format(list[1], list[2])
|
element = element..('listring[%s;%s]'):format(list[1], list[2])
|
||||||
end
|
end
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---The following descriptions are allowed:
|
---The following descriptions are allowed:
|
||||||
@@ -219,6 +234,7 @@ end
|
|||||||
---@param slotBorder ColorString?
|
---@param slotBorder ColorString?
|
||||||
---@param tooltipBgcolor ColorString?
|
---@param tooltipBgcolor ColorString?
|
||||||
---@param tooltipFontcolor ColorString?
|
---@param tooltipFontcolor ColorString?
|
||||||
|
---@return Formspec
|
||||||
function Formspec:listColors(slotBackgroundNormal, slotBackgroundHover, slotBorder, tooltipBgcolor, tooltipFontcolor)
|
function Formspec:listColors(slotBackgroundNormal, slotBackgroundHover, slotBorder, tooltipBgcolor, tooltipFontcolor)
|
||||||
local element
|
local element
|
||||||
|
|
||||||
@@ -234,6 +250,7 @@ function Formspec:listColors(slotBackgroundNormal, slotBackgroundHover, slotBord
|
|||||||
end
|
end
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Adds tooltip for an element.
|
---Adds tooltip for an element.
|
||||||
@@ -243,11 +260,13 @@ end
|
|||||||
---@param tooltipText string
|
---@param tooltipText string
|
||||||
---@param bgcolor ColorString?
|
---@param bgcolor ColorString?
|
||||||
---@param fontcolor ColorString?
|
---@param fontcolor ColorString?
|
||||||
|
---@return Formspec
|
||||||
function Formspec:tooltipForElement(elementName, tooltipText, bgcolor, fontcolor)
|
function Formspec:tooltipForElement(elementName, tooltipText, bgcolor, fontcolor)
|
||||||
local element = ('tooltip[%s;%s;%s;%s]'):format(
|
local element = ('tooltip[%s;%s;%s;%s]'):format(
|
||||||
elementName, tooltipText, bgcolor or '', fontcolor or '')
|
elementName, tooltipText, bgcolor or '', fontcolor or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Adds tooltip for an area. Other tooltips will take priority when present.
|
---Adds tooltip for an area. Other tooltips will take priority when present.
|
||||||
@@ -260,11 +279,13 @@ end
|
|||||||
---@param tooltipText string
|
---@param tooltipText string
|
||||||
---@param bgcolor ColorString?
|
---@param bgcolor ColorString?
|
||||||
---@param fontcolor ColorString?
|
---@param fontcolor ColorString?
|
||||||
|
---@return Formspec
|
||||||
function Formspec:tooltipForArea(x, y, w, h, tooltipText, bgcolor, fontcolor)
|
function Formspec:tooltipForArea(x, y, w, h, tooltipText, bgcolor, fontcolor)
|
||||||
local element = ('tooltip[%s,%s;%s,%s;%s;%s;%s]'):format(
|
local element = ('tooltip[%s,%s;%s,%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, tooltipText, bgcolor or '', fontcolor or '')
|
x, y, w, h, tooltipText, bgcolor or '', fontcolor or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Show an image.
|
---Show an image.
|
||||||
@@ -276,26 +297,29 @@ end
|
|||||||
---@param h number
|
---@param h number
|
||||||
---@param textureName string
|
---@param textureName string
|
||||||
---@param middle boolean? Makes the image render in 9-sliced mode and defines the middle rect.
|
---@param middle boolean? Makes the image render in 9-sliced mode and defines the middle rect.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:image(x, y, w, h, textureName, middle)
|
function Formspec:image(x, y, w, h, textureName, middle)
|
||||||
local element = ('image[%s,%s;%s,%s;%s;%s]'):format(
|
local element = ('image[%s,%s;%s,%s;%s;%s]'):format(
|
||||||
x, y, w, h, textureName, middle or '')
|
x, y, w, h, textureName, middle or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Show an animated image. The image is drawn like a "vertical_frames" tile animation
|
---Show an animated image. The image is drawn like a "vertical_frames" tile animation
|
||||||
---(See Tile animation definition), but uses a frame count/duration for simplicity.
|
---(See Tile animation definition), but uses a frame count/duration for simplicity.
|
||||||
---
|
---
|
||||||
---**Element:** `animated_image[<X>,<Y>;<W>,<H>;<name>;<texture name>;<frame count>;<frame duration>;<frame start>;<middle>]`
|
---**Element:** `animated_image[<X>,<Y>;<W>,<H>;<name>;<texture name>;<frame count>;<frame duration>;<frame start>;<middle>]`
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param w number
|
---@param w number
|
||||||
---@param h number
|
---@param h number
|
||||||
---@param textureName string
|
---@param textureName string
|
||||||
---@param frameCount number
|
---@param frameCount number
|
||||||
---@param frameDuration number
|
---@param frameDuration number
|
||||||
---@param frameStart number
|
---@param frameStart number
|
||||||
---@param middle boolean? Makes the image render in 9-sliced mode and defines the middle rect.
|
---@param middle boolean? Makes the image render in 9-sliced mode and defines the middle rect.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:animatedImage(x, y, w, h, textureName, frameCount, frameDuration, frameStart, middle)
|
function Formspec:animatedImage(x, y, w, h, textureName, frameCount, frameDuration, frameStart, middle)
|
||||||
if middle == nil then
|
if middle == nil then
|
||||||
middle = false
|
middle = false
|
||||||
@@ -305,6 +329,7 @@ function Formspec:animatedImage(x, y, w, h, textureName, frameCount, frameDurati
|
|||||||
x, y, w, h, textureName, frameCount, frameDuration, frameStart, middle)
|
x, y, w, h, textureName, frameCount, frameDuration, frameStart, middle)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Show a mesh model.
|
---Show a mesh model.
|
||||||
@@ -322,11 +347,13 @@ end
|
|||||||
---@param mouseControl boolean? Whether the model can be controlled with the mouse. Default `true`.
|
---@param mouseControl boolean? Whether the model can be controlled with the mouse. Default `true`.
|
||||||
---@param frameLoopRange string? Range of the animation frames. Defaults to the full range of all available frames. Syntax: `<begin>,<end>`.
|
---@param frameLoopRange string? Range of the animation frames. Defaults to the full range of all available frames. Syntax: `<begin>,<end>`.
|
||||||
---@param animationSpeed number? Sets the animation speed. Default 0 FPS.
|
---@param animationSpeed number? Sets the animation speed. Default 0 FPS.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:model(x, y, w, h, name, mesh, textures, rotation, continuous, mouseControl, frameLoopRange, animationSpeed)
|
function Formspec:model(x, y, w, h, name, mesh, textures, rotation, continuous, mouseControl, frameLoopRange, animationSpeed)
|
||||||
local element = ('model[%s,%s;%s,%s;%s;%s;%s;%s;%s;%s;%s;%s]'):format(
|
local element = ('model[%s,%s;%s,%s;%s;%s;%s;%s;%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, name, mesh, textures, rotation or '', continuous or '', mouseControl or '', frameLoopRange or '', animationSpeed or '')
|
x, y, w, h, name, mesh, textures, rotation or '', continuous or '', mouseControl or '', frameLoopRange or '', animationSpeed or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Show an inventory image of registered item/node.
|
---Show an inventory image of registered item/node.
|
||||||
@@ -337,11 +364,13 @@ end
|
|||||||
---@param w number
|
---@param w number
|
||||||
---@param h number
|
---@param h number
|
||||||
---@param itemName string
|
---@param itemName string
|
||||||
|
---@return Formspec
|
||||||
function Formspec:itemImage(x, y, w, h, itemName)
|
function Formspec:itemImage(x, y, w, h, itemName)
|
||||||
local element = ('item_image[%s,%s;%s,%s;%s]'):format(
|
local element = ('item_image[%s,%s;%s,%s;%s]'):format(
|
||||||
x, y, w, h, itemName)
|
x, y, w, h, itemName)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Sets background color of formspec.
|
---Sets background color of formspec.
|
||||||
@@ -355,12 +384,14 @@ end
|
|||||||
---**Element:** `bgcolor[<bgcolor>;<fullscreen>;<fbgcolor>]`
|
---**Element:** `bgcolor[<bgcolor>;<fullscreen>;<fbgcolor>]`
|
||||||
---@param bgcolor ColorString Define the color of the non-fullscreen and the fullscreen background.
|
---@param bgcolor ColorString Define the color of the non-fullscreen and the fullscreen background.
|
||||||
---@param fullscreen 'false'|'true'|'both'|'neither'
|
---@param fullscreen 'false'|'true'|'both'|'neither'
|
||||||
---@param fbgcolor ColorString? Define the color of the non-fullscreen and the fullscreen background.
|
---@param fbgcolor ColorString? Define the color of the non-fullscreen and the fullscreen background.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:bgcolor(bgcolor, fullscreen, fbgcolor)
|
function Formspec:bgcolor(bgcolor, fullscreen, fbgcolor)
|
||||||
local element = ('bgcolor[%s;%s;%s]'):format(
|
local element = ('bgcolor[%s;%s;%s]'):format(
|
||||||
bgcolor, fullscreen or '', fbgcolor or '')
|
bgcolor, fullscreen or '', fbgcolor or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Example for formspec 8x4 in 16x resolution: image shall be sized 8 times 16px times 4 times 16px.
|
---Example for formspec 8x4 in 16x resolution: image shall be sized 8 times 16px times 4 times 16px.
|
||||||
@@ -374,6 +405,7 @@ end
|
|||||||
---@param autoClip boolean? If is `true`, the background is clipped.
|
---@param autoClip boolean? If is `true`, the background is clipped.
|
||||||
--- to the formspec size (x and y are used as offset
|
--- to the formspec size (x and y are used as offset
|
||||||
--- values, w and h are ignored)
|
--- values, w and h are ignored)
|
||||||
|
---@return Formspec
|
||||||
function Formspec:background(x, y, w, h, textureName, autoClip)
|
function Formspec:background(x, y, w, h, textureName, autoClip)
|
||||||
local element
|
local element
|
||||||
|
|
||||||
@@ -386,6 +418,7 @@ function Formspec:background(x, y, w, h, textureName, autoClip)
|
|||||||
end
|
end
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
|
---9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
|
||||||
@@ -406,11 +439,13 @@ end
|
|||||||
--- Negative x2 and y2 values will be added to the width and height of
|
--- Negative x2 and y2 values will be added to the width and height of
|
||||||
--- the texture, allowing it to be used as the distance from the far end.
|
--- the texture, allowing it to be used as the distance from the far end.
|
||||||
--- * All numbers in middle are integers.
|
--- * All numbers in middle are integers.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:background9(x, y, w, h, textureName, autoClip, middle)
|
function Formspec:background9(x, y, w, h, textureName, autoClip, middle)
|
||||||
local element = ('background9[%s,%s;%s,%s;%s;%s]'):format(
|
local element = ('background9[%s,%s;%s,%s;%s;%s]'):format(
|
||||||
x, y, w, h, textureName, autoClip, middle)
|
x, y, w, h, textureName, autoClip, middle)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Textual password style field; will be sent to server when a button is clicked
|
---Textual password style field; will be sent to server when a button is clicked
|
||||||
@@ -427,11 +462,13 @@ end
|
|||||||
---@param h number
|
---@param h number
|
||||||
---@param name string Is the name of the field as returned in `fields to on_receive_fields`.
|
---@param name string Is the name of the field as returned in `fields to on_receive_fields`.
|
||||||
---@param label string? If not blank, will be text printed on the top left above the field.
|
---@param label string? If not blank, will be text printed on the top left above the field.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:pwdfield(x, y, w, h, name, label)
|
function Formspec:pwdfield(x, y, w, h, name, label)
|
||||||
local element = ('pwdfield[%s,%s;%s,%s;%s;%s]'):format(
|
local element = ('pwdfield[%s,%s;%s,%s;%s;%s]'):format(
|
||||||
x, y, w, h, name, label or '')
|
x, y, w, h, name, label or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Textual field; will be sent to server when a button is clicked.
|
---Textual field; will be sent to server when a button is clicked.
|
||||||
@@ -451,11 +488,13 @@ end
|
|||||||
---@param default string? is the default value of the field default may contain variable references
|
---@param default string? is the default value of the field default may contain variable references
|
||||||
--- such as `${text}` which will fill the value from the metadata value text.
|
--- such as `${text}` which will fill the value from the metadata value text.
|
||||||
--- Note: no extra text or more than a single variable is supported ATM.
|
--- Note: no extra text or more than a single variable is supported ATM.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:field(x, y, w, h, name, label, default)
|
function Formspec:field(x, y, w, h, name, label, default)
|
||||||
local element = ('field[%s,%s;%s,%s;%s;%s;%s]'):format(
|
local element = ('field[%s,%s;%s,%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, name, label or '', default or '')
|
x, y, w, h, name, label or '', default or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Textual field; will be sent to server when a button is clicked.
|
---Textual field; will be sent to server when a button is clicked.
|
||||||
@@ -472,11 +511,13 @@ end
|
|||||||
---@param default string? is the default value of the field default may contain variable references
|
---@param default string? is the default value of the field default may contain variable references
|
||||||
--- such as `${text}` which will fill the value from the metadata value text.
|
--- such as `${text}` which will fill the value from the metadata value text.
|
||||||
--- Note: no extra text or more than a single variable is supported ATM.
|
--- Note: no extra text or more than a single variable is supported ATM.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:fieldWithoutPos(name, label, default)
|
function Formspec:fieldWithoutPos(name, label, default)
|
||||||
local element = ('field[%s,%s;%s,%s;%s;%s;%s]'):format(
|
local element = ('field[%s,%s;%s,%s;%s;%s;%s]'):format(
|
||||||
name, label or '', default or '')
|
name, label or '', default or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -484,15 +525,17 @@ end
|
|||||||
---Only affects Android clients.
|
---Only affects Android clients.
|
||||||
---
|
---
|
||||||
---**Element:** `field_enter_after_edit[<name>;<enter_after_edit>]`
|
---**Element:** `field_enter_after_edit[<name>;<enter_after_edit>]`
|
||||||
---@param name string Is the name of the field.
|
---@param name string Is the name of the field.
|
||||||
---@param enterAfterEdit boolean? If is true, pressing the "Done" button in the Android
|
---@param enterAfterEdit boolean? If is true, pressing the "Done" button in the Android
|
||||||
--- text input dialog will simulate an Enter keypress. Defaults to `false`
|
--- text input dialog will simulate an Enter keypress. Defaults to `false`
|
||||||
--- when not specified (i.e. no tag for a field).
|
--- when not specified (i.e. no tag for a field).
|
||||||
|
---@return Formspec
|
||||||
function Formspec:fieldEnterAfterEdit(name, enterAfterEdit)
|
function Formspec:fieldEnterAfterEdit(name, enterAfterEdit)
|
||||||
local element = ('field_enter_after_edit[%s;%s]'):format(
|
local element = ('field_enter_after_edit[%s;%s]'):format(
|
||||||
name, enterAfterEdit or false)
|
name, enterAfterEdit or false)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -500,11 +543,13 @@ end
|
|||||||
---@param name string Is the name of the field.
|
---@param name string Is the name of the field.
|
||||||
---@param closeOnEnter boolean? If` is false, pressing Enter in the field will submit the form but not close it.
|
---@param closeOnEnter boolean? If` is false, pressing Enter in the field will submit the form but not close it.
|
||||||
--- Defaults to true when not specified (i.e. no tag for a field).
|
--- Defaults to true when not specified (i.e. no tag for a field).
|
||||||
|
---@return Formspec
|
||||||
function Formspec:fieldCloseOnEnter(name, closeOnEnter)
|
function Formspec:fieldCloseOnEnter(name, closeOnEnter)
|
||||||
local element = ('field_enter_after_edit[%s;%s]'):format(
|
local element = ('field_enter_after_edit[%s;%s]'):format(
|
||||||
name, closeOnEnter or false)
|
name, closeOnEnter or false)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Same as text fields, but with multi-line input.
|
---Same as text fields, but with multi-line input.
|
||||||
@@ -524,11 +569,13 @@ end
|
|||||||
---@param default string? is the default value of the field default may contain variable references
|
---@param default string? is the default value of the field default may contain variable references
|
||||||
--- such as `${text}` which will fill the value from the metadata value text.
|
--- such as `${text}` which will fill the value from the metadata value text.
|
||||||
--- Note: no extra text or more than a single variable is supported ATM.
|
--- Note: no extra text or more than a single variable is supported ATM.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:textArea(x, y, w, h, name, label, default)
|
function Formspec:textArea(x, y, w, h, name, label, default)
|
||||||
local element = ('textarea[%s,%s;%s,%s;%s;%s;%s]'):format(
|
local element = ('textarea[%s,%s;%s,%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, name or '', label or '', default or '')
|
x, y, w, h, name or '', label or '', default or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---The label formspec element displays the text set in `label` at the specified position.
|
---The label formspec element displays the text set in `label` at the specified position.
|
||||||
@@ -542,11 +589,13 @@ end
|
|||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param label string
|
---@param label string
|
||||||
|
---@return Formspec
|
||||||
function Formspec:label(x, y, label)
|
function Formspec:label(x, y, label)
|
||||||
local element = ('label[%s,%s;%s]'):format(
|
local element = ('label[%s,%s;%s]'):format(
|
||||||
x, y, label)
|
x, y, label)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---The "area label" formspec element displays the text set in label at the specified position and size.
|
---The "area label" formspec element displays the text set in label at the specified position and size.
|
||||||
@@ -560,11 +609,13 @@ end
|
|||||||
---@param w number
|
---@param w number
|
||||||
---@param h number
|
---@param h number
|
||||||
---@param label string
|
---@param label string
|
||||||
|
---@return Formspec
|
||||||
function Formspec:areaLabel(x, y, w, h, label)
|
function Formspec:areaLabel(x, y, w, h, label)
|
||||||
local element = ('label[%s,%s;%s,%s;%s]'):format(
|
local element = ('label[%s,%s;%s,%s;%s]'):format(
|
||||||
x, y, w, h, label)
|
x, y, w, h, label)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Displays a static formatted text with hyperlinks.
|
---Displays a static formatted text with hyperlinks.
|
||||||
@@ -577,11 +628,13 @@ end
|
|||||||
---@param h number
|
---@param h number
|
||||||
---@param name string Is the name of the field as returned in fields to `on_receive_fields` in case of action in text.
|
---@param name string Is the name of the field as returned in fields to `on_receive_fields` in case of action in text.
|
||||||
---@param text string Is the formatted text using `Markup Language` described below.
|
---@param text string Is the formatted text using `Markup Language` described below.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:hypertext(x, y, w, h, name, text)
|
function Formspec:hypertext(x, y, w, h, name, text)
|
||||||
local element = ('hypertext[%s,%s;%s,%s;%s;%s]'):format(
|
local element = ('hypertext[%s,%s;%s,%s;%s;%s]'):format(
|
||||||
x, y, w, h, name, text)
|
x, y, w, h, name, text)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Textual label drawn vertically.
|
---Textual label drawn vertically.
|
||||||
@@ -590,11 +643,13 @@ end
|
|||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param label string
|
---@param label string
|
||||||
|
---@return Formspec
|
||||||
function Formspec:vertlabel(x, y, label)
|
function Formspec:vertlabel(x, y, label)
|
||||||
local element = ('vertlabel[%s,%s;%s]'):format(
|
local element = ('vertlabel[%s,%s;%s]'):format(
|
||||||
x, y, label)
|
x, y, label)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Clickable button. When clicked, fields will be sent. With the old coordinate system,
|
---Clickable button. When clicked, fields will be sent. With the old coordinate system,
|
||||||
@@ -608,11 +663,13 @@ end
|
|||||||
---@param h number
|
---@param h number
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param label string? Is the text on the button
|
---@param label string? Is the text on the button
|
||||||
|
---@return Formspec
|
||||||
function Formspec:button(x, y, w, h, name, label)
|
function Formspec:button(x, y, w, h, name, label)
|
||||||
local element = ('button[%s,%s;%s,%s;%s;%s]'):format(
|
local element = ('button[%s,%s;%s,%s;%s;%s]'):format(
|
||||||
x, y, w, h, name, label or '')
|
x, y, w, h, name, label or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Clickable button. When clicked, fields will be sent and the user will be given
|
---Clickable button. When clicked, fields will be sent and the user will be given
|
||||||
@@ -628,11 +685,13 @@ end
|
|||||||
---@param name string
|
---@param name string
|
||||||
---@param label string? Is the text on the button
|
---@param label string? Is the text on the button
|
||||||
---@param url string Must be a valid web URL, starting with `http://` or `https://`.
|
---@param url string Must be a valid web URL, starting with `http://` or `https://`.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:buttonUrl(x, y, w, h, name, label, url)
|
function Formspec:buttonUrl(x, y, w, h, name, label, url)
|
||||||
local element = ('button_url[%s,%s;%s,%s;%s;%s;%s]'):format(
|
local element = ('button_url[%s,%s;%s,%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, name, label or '', url)
|
x, y, w, h, name, label or '', url)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Clickable image button. When clicked, fields will be sent.
|
---Clickable image button. When clicked, fields will be sent.
|
||||||
@@ -652,6 +711,7 @@ end
|
|||||||
---@param pressedTextureName string Is the filename of an image on pressed state.
|
---@param pressedTextureName string Is the filename of an image on pressed state.
|
||||||
---@param noclip boolean? Means the image button doesn't need to be within specified formsize. Default: `true`
|
---@param noclip boolean? Means the image button doesn't need to be within specified formsize. Default: `true`
|
||||||
---@param drawborder boolean? Draw button border or not. Default `false`
|
---@param drawborder boolean? Draw button border or not. Default `false`
|
||||||
|
---@return Formspec
|
||||||
function Formspec:imageButton(x, y, w, h, textureName, name, label, pressedTextureName, noclip, drawborder)
|
function Formspec:imageButton(x, y, w, h, textureName, name, label, pressedTextureName, noclip, drawborder)
|
||||||
local element
|
local element
|
||||||
|
|
||||||
@@ -664,9 +724,10 @@ function Formspec:imageButton(x, y, w, h, textureName, name, label, pressedTextu
|
|||||||
end
|
end
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---TODO: описание
|
---Clickable item image button. When clicked, fields will be sent.
|
||||||
---
|
---
|
||||||
---**Element:** `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
|
---**Element:** `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
|
||||||
---@param x number
|
---@param x number
|
||||||
@@ -676,11 +737,13 @@ end
|
|||||||
---@param itemName string
|
---@param itemName string
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param label string?
|
---@param label string?
|
||||||
|
---@return Formspec
|
||||||
function Formspec:itemImageButton(x, y, w, h, itemName, name, label)
|
function Formspec:itemImageButton(x, y, w, h, itemName, name, label)
|
||||||
local element = ('item_image_button[%s,%s;%s,%s;%s;%s;%s]'):format(
|
local element = ('item_image_button[%s,%s;%s,%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, itemName, name, label or '')
|
x, y, w, h, itemName, name, label or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---When clicked, fields will be sent and the form will quit.
|
---When clicked, fields will be sent and the form will quit.
|
||||||
@@ -693,11 +756,13 @@ end
|
|||||||
---@param h number
|
---@param h number
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param label string? Is the text on the button
|
---@param label string? Is the text on the button
|
||||||
|
---@return Formspec
|
||||||
function Formspec:buttonExit(x, y, w, h, name, label)
|
function Formspec:buttonExit(x, y, w, h, name, label)
|
||||||
local element = ('button_exit[%s,%s;%s,%s;%s;%s]'):format(
|
local element = ('button_exit[%s,%s;%s,%s;%s;%s]'):format(
|
||||||
x, y, w, h, name, label or '')
|
x, y, w, h, name, label or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---When clicked, fields will be sent and the form will quit.
|
---When clicked, fields will be sent and the form will quit.
|
||||||
@@ -711,11 +776,13 @@ end
|
|||||||
---@param name string
|
---@param name string
|
||||||
---@param label string? Is the text on the button
|
---@param label string? Is the text on the button
|
||||||
---@param url string Must be a valid web URL, starting with `http://` or `https://`.
|
---@param url string Must be a valid web URL, starting with `http://` or `https://`.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:buttonUrlExit(x, y, w, h, name, label, url)
|
function Formspec:buttonUrlExit(x, y, w, h, name, label, url)
|
||||||
local element = ('button_url_exit[%s,%s;%s,%s;%s;%s;%s]'):format(
|
local element = ('button_url_exit[%s,%s;%s,%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, name, label or '', url)
|
x, y, w, h, name, label or '', url)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---When clicked, fields will be sent and the form will quit.
|
---When clicked, fields will be sent and the form will quit.
|
||||||
@@ -729,11 +796,13 @@ end
|
|||||||
---@param textureName string Is the filename of an image.
|
---@param textureName string Is the filename of an image.
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param label string?
|
---@param label string?
|
||||||
|
---@return Formspec
|
||||||
function Formspec:imageButtonExit(x, y, w, h, textureName, name, label)
|
function Formspec:imageButtonExit(x, y, w, h, textureName, name, label)
|
||||||
local element = ('image_button_exit[%s,%s;%s,%s;%s;%s;%s]'):format(
|
local element = ('image_button_exit[%s,%s;%s,%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, textureName, name, label or '')
|
x, y, w, h, textureName, name, label or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Scrollable item list showing arbitrary text elements.
|
---Scrollable item list showing arbitrary text elements.
|
||||||
@@ -749,18 +818,20 @@ end
|
|||||||
--- If you want a listelement to start with "#" write "##"
|
--- If you want a listelement to start with "#" write "##"
|
||||||
---@param selectedIdx number? Index to be selected within textlist.
|
---@param selectedIdx number? Index to be selected within textlist.
|
||||||
---@param transparent boolean? Draw transparent background.
|
---@param transparent boolean? Draw transparent background.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:textlist(x, y, w, h, name, listElements, selectedIdx, transparent)
|
function Formspec:textlist(x, y, w, h, name, listElements, selectedIdx, transparent)
|
||||||
local element
|
local element
|
||||||
|
|
||||||
if selectedIdx == nil and transparent == nil then
|
if selectedIdx == nil and transparent == nil then
|
||||||
element = ('textlist[%s,%s;%s,%s;%s;%s]'):format(
|
element = ('textlist[%s,%s;%s,%s;%s;%s]'):format(
|
||||||
x, y, w, h, name, table.concat(listElements, ','))
|
x, y, w, h, name, tableConcat(listElements, ','))
|
||||||
else
|
else
|
||||||
element = ('textlist[%s,%s;%s,%s;%s;%s;%s;%s]'):format(
|
element = ('textlist[%s,%s;%s,%s;%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, name, table.concat(listElements, ','), selectedIdx or '', transparent or '')
|
x, y, w, h, name, tableConcat(listElements, ','), selectedIdx or '', transparent or '')
|
||||||
end
|
end
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Show a tabheader at specific position (ignores formsize).
|
---Show a tabheader at specific position (ignores formsize).
|
||||||
@@ -778,39 +849,43 @@ end
|
|||||||
---@param currentTab number?
|
---@param currentTab number?
|
||||||
---@param transparent boolean?
|
---@param transparent boolean?
|
||||||
---@param drawBorder boolean?
|
---@param drawBorder boolean?
|
||||||
|
---@return Formspec
|
||||||
function Formspec:tabheader(x, y, w, h, name, listCaptions, currentTab, transparent, drawBorder)
|
function Formspec:tabheader(x, y, w, h, name, listCaptions, currentTab, transparent, drawBorder)
|
||||||
local element
|
local element
|
||||||
|
|
||||||
if w == nil and h == nil then
|
if w == nil and h == nil then
|
||||||
element = ('tabheader[%s,%s;%s;%s;%s;%s;%s]'):format(
|
element = ('tabheader[%s,%s;%s;%s;%s;%s;%s]'):format(
|
||||||
x, y, name, table.concat(listCaptions, ','), currentTab or '', transparent or '', drawBorder or '')
|
x, y, name, tableConcat(listCaptions, ','), currentTab or '', transparent or '', drawBorder or '')
|
||||||
elseif w == nil then
|
elseif w == nil then
|
||||||
element = ('tabheader[%s,%s;%s;%s;%s;%s;%s;%s]'):format(
|
element = ('tabheader[%s,%s;%s;%s;%s;%s;%s;%s]'):format(
|
||||||
x, y, name, h, table.concat(listCaptions, ','), currentTab or '', transparent or '', drawBorder or '')
|
x, y, name, h, tableConcat(listCaptions, ','), currentTab or '', transparent or '', drawBorder or '')
|
||||||
else
|
else
|
||||||
element = ('tabheader[%s,%s;%s,%s;%s;%s,%s;%s;%s;%s]'):format(
|
element = ('tabheader[%s,%s;%s,%s;%s;%s,%s;%s;%s;%s]'):format(
|
||||||
x, y, name, w, h, table.concat(listCaptions, ','), currentTab or '', transparent or '', drawBorder or '')
|
x, y, name, w, h, tableConcat(listCaptions, ','), currentTab or '', transparent or '', drawBorder or '')
|
||||||
end
|
end
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Simple colored box.
|
---Simple colored box.
|
||||||
---
|
---
|
||||||
---**Element:** `box[<X>,<Y>;<W>,<H>;<color>]`
|
---**Element:** `box[<X>,<Y>;<W>,<H>;<color>]`
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param w number
|
---@param w number
|
||||||
---@param h number
|
---@param h number
|
||||||
---@param color ColorString Is color specified as a `ColorString`. If the alpha component is left blank,
|
---@param color ColorString Is color specified as a `ColorString`. If the alpha component is left blank,
|
||||||
--- the box will be semitransparent. If the color is not specified, the box will
|
--- the box will be semitransparent. If the color is not specified, the box will
|
||||||
--- use the options specified by its style. If the color is specified, all styling
|
--- use the options specified by its style. If the color is specified, all styling
|
||||||
--- options will be ignored.
|
--- options will be ignored.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:box(x, y, w, h, color)
|
function Formspec:box(x, y, w, h, color)
|
||||||
local element = ('box[%s,%s;%s,%s;%s]'):format(
|
local element = ('box[%s,%s;%s,%s;%s]'):format(
|
||||||
x, y, w, h, color)
|
x, y, w, h, color)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Show a dropdown field
|
---Show a dropdown field
|
||||||
@@ -831,18 +906,20 @@ end
|
|||||||
---@param indexEvent boolean? (optional, allowed parameter since formspec version 4): Specifies the event field value for selected items.
|
---@param indexEvent boolean? (optional, allowed parameter since formspec version 4): Specifies the event field value for selected items.
|
||||||
--- * `true`: Selected item index
|
--- * `true`: Selected item index
|
||||||
--- * `false` (default): Selected item value
|
--- * `false` (default): Selected item value
|
||||||
|
---@return Formspec
|
||||||
function Formspec:dropdown(x, y, w, h, name, listItems, selectedIdx, indexEvent)
|
function Formspec:dropdown(x, y, w, h, name, listItems, selectedIdx, indexEvent)
|
||||||
local element
|
local element
|
||||||
|
|
||||||
if h == nil then
|
if h == nil then
|
||||||
element = ('dropdown[%s,%s;%s;%s;%s;%s;%s]'):format(
|
element = ('dropdown[%s,%s;%s;%s;%s;%s;%s]'):format(
|
||||||
x, y, w, name, table.concat(listItems, ','), selectedIdx or '', indexEvent or '')
|
x, y, w, name, tableConcat(listItems, ','), selectedIdx or '', indexEvent or '')
|
||||||
else
|
else
|
||||||
element = ('dropdown[%s,%s;%s,%s;%s;%s;%s;%s]'):format(
|
element = ('dropdown[%s,%s;%s,%s;%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, name, table.concat(listItems, ','), selectedIdx or '', indexEvent or '')
|
x, y, w, h, name, tableConcat(listItems, ','), selectedIdx or '', indexEvent or '')
|
||||||
end
|
end
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Show a checkbox.
|
---Show a checkbox.
|
||||||
@@ -856,11 +933,13 @@ end
|
|||||||
---@param name string Fieldname data is transferred to Lua
|
---@param name string Fieldname data is transferred to Lua
|
||||||
---@param label string? To be shown left of checkbox
|
---@param label string? To be shown left of checkbox
|
||||||
---@param selected boolean?
|
---@param selected boolean?
|
||||||
|
---@return Formspec
|
||||||
function Formspec:checkbox(x, y, name, label, selected)
|
function Formspec:checkbox(x, y, name, label, selected)
|
||||||
local element = ('checkbox[%s,%s;%s;%s;%s]'):format(
|
local element = ('checkbox[%s,%s;%s;%s;%s]'):format(
|
||||||
x, y, name, label or '', selected or '')
|
x, y, name, label or '', selected or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Show a scrollbar using options defined by the previous `scrollbaroptions[]`
|
---Show a scrollbar using options defined by the previous `scrollbaroptions[]`
|
||||||
@@ -873,11 +952,13 @@ end
|
|||||||
---@param orientation 'vertical'|'horizontal'
|
---@param orientation 'vertical'|'horizontal'
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param value number?
|
---@param value number?
|
||||||
|
---@return Formspec
|
||||||
function Formspec:scrollbar(x, y, w, h, orientation, name, value)
|
function Formspec:scrollbar(x, y, w, h, orientation, name, value)
|
||||||
local element = ('scrollbar[%s,%s;%s,%s;%s;%s;%s]'):format(
|
local element = ('scrollbar[%s,%s;%s,%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, orientation, name, value or '')
|
x, y, w, h, orientation, name, value or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---@alias Formspec.scrollbarOptionsDef {min:integer?, max:integer?, smallstep:integer?, largestep:integer?, thumbsize:integer?, arrows:'show'|'hide'|'default'|nil}
|
---@alias Formspec.scrollbarOptionsDef {min:integer?, max:integer?, smallstep:integer?, largestep:integer?, thumbsize:integer?, arrows:'show'|'hide'|'default'|nil}
|
||||||
@@ -902,11 +983,13 @@ end
|
|||||||
---
|
---
|
||||||
---**Element**: `scrollbaroptions[opt1;opt2;...]`
|
---**Element**: `scrollbaroptions[opt1;opt2;...]`
|
||||||
---@param options Formspec.scrollbarOptionsDef
|
---@param options Formspec.scrollbarOptionsDef
|
||||||
|
---@return Formspec
|
||||||
function Formspec:scrollbarOptions(options)
|
function Formspec:scrollbarOptions(options)
|
||||||
local element = ('scrollbaroptions[%s]'):format(
|
local element = ('scrollbaroptions[%s]'):format(
|
||||||
table.key_value_list(options, ';'))
|
tableKeyValueList(options, ';'))
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Show scrollable table using options defined by the previous `tableoptions[]`.
|
---Show scrollable table using options defined by the previous `tableoptions[]`.
|
||||||
@@ -922,11 +1005,13 @@ end
|
|||||||
---@param name string Fieldname sent to server on row select or double-click
|
---@param name string Fieldname sent to server on row select or double-click
|
||||||
---@param listCells string[] Cells contents given in row-major order.
|
---@param listCells string[] Cells contents given in row-major order.
|
||||||
---@param selectedIdx number? Index of row to be selected within table (first row = `1`)
|
---@param selectedIdx number? Index of row to be selected within table (first row = `1`)
|
||||||
|
---@return Formspec
|
||||||
function Formspec:table(x, y, w, h, name, listCells, selectedIdx)
|
function Formspec:table(x, y, w, h, name, listCells, selectedIdx)
|
||||||
local element = ('table[%s,%s;%s,%s;%s;%s;%s]'):format(
|
local element = ('table[%s,%s;%s,%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, name, table.concat(listCells, ','), selectedIdx or '')
|
x, y, w, h, name, tableConcat(listCells, ','), selectedIdx or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---@alias Formspec.tableOptionsDef {color:ColorString?, background:ColorString?, border:boolean?, highlight:ColorString?, highlight_text:ColorString?, opendepth:integer?}
|
---@alias Formspec.tableOptionsDef {color:ColorString?, background:ColorString?, border:boolean?, highlight:ColorString?, highlight_text:ColorString?, opendepth:integer?}
|
||||||
@@ -948,11 +1033,13 @@ end
|
|||||||
---
|
---
|
||||||
---**Element:** `tableoptions[<opt 1>;<opt 2>;...]`
|
---**Element:** `tableoptions[<opt 1>;<opt 2>;...]`
|
||||||
---@param options Formspec.tableOptionsDef
|
---@param options Formspec.tableOptionsDef
|
||||||
|
---@return Formspec
|
||||||
function Formspec:tableOptions(options)
|
function Formspec:tableOptions(options)
|
||||||
local element = ('tableoptions[%s]'):format(
|
local element = ('tableoptions[%s]'):format(
|
||||||
table.key_value_list(options, ';'))
|
tableKeyValueList(options, ';'))
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---@alias Formspec.tableColumnsTypes 'text'|'image'|'color'|'indent'|'tree'
|
---@alias Formspec.tableColumnsTypes 'text'|'image'|'color'|'indent'|'tree'
|
||||||
@@ -986,29 +1073,77 @@ end
|
|||||||
---
|
---
|
||||||
---**Element**: `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
|
---**Element**: `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
|
||||||
---@param columns Formspec.tableColumn[]
|
---@param columns Formspec.tableColumn[]
|
||||||
|
---@return Formspec
|
||||||
function Formspec:tablecolumns(columns)
|
function Formspec:tablecolumns(columns)
|
||||||
local columnsStrings = {}
|
local columnsStrings = {}
|
||||||
|
|
||||||
for _, column in pairs(columns) do
|
for _, column in pairs(columns) do
|
||||||
table.insert(columnsStrings,
|
tableInsert(columnsStrings,
|
||||||
column.type..','..table.key_value_list(column.options,',')
|
column.type..','..tableKeyValueList(column.options,',')
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
local element = ('tablecolumns[%s]'):format(
|
local element = ('tablecolumns[%s]'):format(
|
||||||
table.key_value_list(columnsStrings, ';'))
|
tableKeyValueList(columnsStrings, ';'))
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---TODO
|
---Set the style for the element(s) matching `selector` by name.
|
||||||
function Formspec:style()
|
---
|
||||||
|
---`state` is a list of states separated by the `+` character.
|
||||||
|
--- * If a state is provided, the style will only take effect when the element is in that state.
|
||||||
|
--- * All provided states must be active for the style to apply.
|
||||||
|
---
|
||||||
|
---**Note**: this must be before the element is defined.
|
||||||
|
---
|
||||||
|
---See [Styling Formspecs](https://api.luanti.org/formspec/#styling-formspecs).
|
||||||
|
---
|
||||||
|
---**Element**: `style[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
|
||||||
|
---@param selectors string|string[] Can be one of:
|
||||||
|
--- * `<name>` - An element name. Includes `*`, which represents every element.
|
||||||
|
--- * `<name>:<state>` - An element name, a colon, and one or more states.
|
||||||
|
---@param properties string[] TODO: добавить тут алиас, который бы содержал доступные настройки
|
||||||
|
---@return Formspec
|
||||||
|
function Formspec:style(selectors, properties)
|
||||||
|
if type(selectors) == 'string' then
|
||||||
|
selectors = { selectors }
|
||||||
|
end
|
||||||
|
|
||||||
|
local element = ('style[%s;%s]'):format(
|
||||||
|
tableConcat(selectors, ','), tableConcat(properties, ','))
|
||||||
|
|
||||||
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---TODO
|
---Set the style for the element(s) matching `selector` by type.
|
||||||
function Formspec:styleType()
|
---
|
||||||
|
---`state` is a list of states separated by the `+` character.
|
||||||
|
--- * If a state is provided, the style will only take effect when the element is in that state.
|
||||||
|
--- * All provided states must be active for the style to apply.
|
||||||
|
---
|
||||||
|
---**Note**: this must be before the element is defined.
|
||||||
|
---
|
||||||
|
---See [Styling Formspecs](https://api.luanti.org/formspec/#styling-formspecs).
|
||||||
|
---
|
||||||
|
---**Element**: `style[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
|
||||||
|
---@param selectors string|string[] Can be one of:
|
||||||
|
--- * `<name>` - An element name. Includes `*`, which represents every element.
|
||||||
|
--- * `<name>:<state>` - An element name, a colon, and one or more states.
|
||||||
|
---@param properties string[] TODO: добавить тут алиас, который бы содержал доступные настройки
|
||||||
|
---@return Formspec
|
||||||
|
function Formspec:styleType(selectors, properties)
|
||||||
|
if type(selectors) == 'string' then
|
||||||
|
selectors = { selectors }
|
||||||
|
end
|
||||||
|
|
||||||
|
local element = ('style[%s;%s]'):format(
|
||||||
|
tableConcat(selectors, ','), tableConcat(properties, ','))
|
||||||
|
|
||||||
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Sets the focus to the element with the same name parameter.
|
---Sets the focus to the element with the same name parameter.
|
||||||
@@ -1033,11 +1168,13 @@ end
|
|||||||
---@param force string? (optional, default `false`): By default, focus is not applied for re-sent
|
---@param force string? (optional, default `false`): By default, focus is not applied for re-sent
|
||||||
--- formspecs with the same name so that player-set focus is kept. true sets
|
--- formspecs with the same name so that player-set focus is kept. true sets
|
||||||
--- the focus to the specified element for every sent formspec.
|
--- the focus to the specified element for every sent formspec.
|
||||||
|
---@return Formspec
|
||||||
function Formspec:setFocus(name, force)
|
function Formspec:setFocus(name, force)
|
||||||
local element = ('set_focus[%s;%s]'):format(
|
local element = ('set_focus[%s;%s]'):format(
|
||||||
name, force or '')
|
name, force or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
return Formspec
|
return Formspec
|
||||||
|
|||||||
@@ -81,6 +81,17 @@ function MapGen:new(def)
|
|||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Returns a layer by name. If such a layer does not exist, an error will be raised.
|
||||||
|
---@param layerName string The name of the layer to be retrieved.
|
||||||
|
---@return MapGen.Layer
|
||||||
|
function MapGen:getLayerByName(layerName)
|
||||||
|
local layer = self.layersByName[layerName]
|
||||||
|
|
||||||
|
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
||||||
|
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
---Determines which layer a node belongs to based on its height coordinate.
|
---Determines which layer a node belongs to based on its height coordinate.
|
||||||
---@param yPos number
|
---@param yPos number
|
||||||
---@return MapGen.Layer?
|
---@return MapGen.Layer?
|
||||||
@@ -127,19 +138,10 @@ end
|
|||||||
function MapGen:getPeakByPos(layer, category, pos)
|
function MapGen:getPeakByPos(layer, category, pos)
|
||||||
if type(layer) == 'string' then
|
if type(layer) == 'string' then
|
||||||
local layerName = layer
|
local layerName = layer
|
||||||
layer = self.layersByName[layerName]
|
layer = self:getLayerByName(layerName)
|
||||||
|
|
||||||
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
pos = vector.new(pos)
|
return layer:getPeakByPos(category, pos)
|
||||||
|
|
||||||
---@param peak MapGen.Peak
|
|
||||||
for _, peak in ipairs(layer.peaksList[category]) do
|
|
||||||
if peak:getPeakPos() == pos then
|
|
||||||
return peak
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns `true` if the point is within the triangle's region.
|
---Returns `true` if the point is within the triangle's region.
|
||||||
@@ -180,9 +182,7 @@ end
|
|||||||
function MapGen:getTriangleByPos2D(layer, category, pos)
|
function MapGen:getTriangleByPos2D(layer, category, pos)
|
||||||
if type(layer) == 'string' then
|
if type(layer) == 'string' then
|
||||||
local layerName = layer
|
local layerName = layer
|
||||||
layer = self.layersByName[layerName]
|
layer = self:getLayerByName(layerName)
|
||||||
|
|
||||||
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, triangle in ipairs(layer.trianglesList[category]) do
|
for _, triangle in ipairs(layer.trianglesList[category]) do
|
||||||
@@ -206,6 +206,153 @@ function MapGen:pointInRegion2D(layer, regionName, point)
|
|||||||
return region:pointInRegion(point)
|
return region:pointInRegion(point)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Returns `true` if there is a cavern at the specified coordinates.
|
||||||
|
---@param layer MapGen.Layer
|
||||||
|
---@param x integer
|
||||||
|
---@param y integer
|
||||||
|
---@param z integer
|
||||||
|
---@return boolean
|
||||||
|
function MapGen:isCavern(layer, x, y, z)
|
||||||
|
for _, cavern in ipairs(layer.cavernsList) do
|
||||||
|
if cavern.isRegional then
|
||||||
|
local inRegion, distance = self:pointInRegion2D(layer, cavern.name, {x=x,y=y,z=z})
|
||||||
|
|
||||||
|
if inRegion and distance ~= nil then
|
||||||
|
if cavern:isCavern(x, y, z, distance) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if cavern:isLayeredCavern(x, y, z) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
---Creates a unique key for a vertex (using X and Z coordinates).
|
||||||
|
---@param peak MapGen.Peak
|
||||||
|
---@return string
|
||||||
|
local function vertexKey(peak)
|
||||||
|
local pos = peak:getPeakPos()
|
||||||
|
|
||||||
|
return string.format("%.6f,%.6f", pos.x, pos.z)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Creates a canonical (sorted) key for an edge.
|
||||||
|
---@param edge MapGen.Triangulation.Edge
|
||||||
|
---@return string
|
||||||
|
local function edgeKey(edge)
|
||||||
|
local k1 = vertexKey(edge.p1)
|
||||||
|
local k2 = vertexKey(edge.p2)
|
||||||
|
|
||||||
|
if k1 < k2 then
|
||||||
|
return k1 .. "|" .. k2
|
||||||
|
else
|
||||||
|
return k2 .. "|" .. k1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---Calculates the outer boundary of a triangulated region.
|
||||||
|
---Works on the XZ horizontal plane.
|
||||||
|
---@param triangles MapGen.Triangle[]
|
||||||
|
---@return table
|
||||||
|
function MapGen:getTriangulateBoundaryVertices(triangles)
|
||||||
|
-- Count how many triangles share each edge
|
||||||
|
local edgeCount = {}
|
||||||
|
---@type table<string, MapGen.Triangulation.Edge>
|
||||||
|
local edgeData = {}
|
||||||
|
|
||||||
|
for _, triangle in ipairs(triangles) do
|
||||||
|
local edges = {
|
||||||
|
triangle.e1,
|
||||||
|
triangle.e2,
|
||||||
|
triangle.e3
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, edge in ipairs(edges) do
|
||||||
|
local key = edgeKey(edge)
|
||||||
|
|
||||||
|
edgeCount[key] = (edgeCount[key] or 0) + 1
|
||||||
|
edgeData[key] = edge
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Boundary edges belong to exactly ONE triangle
|
||||||
|
---@type MapGen.Triangulation.Edge[]
|
||||||
|
local boundaryEdges = {}
|
||||||
|
|
||||||
|
for key, count in pairs(edgeCount) do
|
||||||
|
if count == 1 then
|
||||||
|
table.insert(boundaryEdges, edgeData[key])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #boundaryEdges == 0 then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Build adjacency list for boundary vertices
|
||||||
|
---@type table<string, MapGen.Peak>
|
||||||
|
local adjacency = {}
|
||||||
|
---@type table<string, MapGen.Peak>
|
||||||
|
local vertexData = {}
|
||||||
|
|
||||||
|
for _, edge in ipairs(boundaryEdges) do
|
||||||
|
local k1 = vertexKey(edge.p1)
|
||||||
|
local k2 = vertexKey(edge.p2)
|
||||||
|
|
||||||
|
vertexData[k1] = edge.p1
|
||||||
|
vertexData[k2] = edge.p2
|
||||||
|
|
||||||
|
adjacency[k1] = adjacency[k1] or {}
|
||||||
|
adjacency[k2] = adjacency[k2] or {}
|
||||||
|
|
||||||
|
table.insert(adjacency[k1], k2)
|
||||||
|
table.insert(adjacency[k2], k1)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Walk along boundary edges to create ordered vertex list
|
||||||
|
---@type Position[]
|
||||||
|
local boundary = {}
|
||||||
|
---@type table<string, boolean>
|
||||||
|
local visited = {}
|
||||||
|
|
||||||
|
if boundaryEdges[1] == nil then
|
||||||
|
error()
|
||||||
|
end
|
||||||
|
|
||||||
|
---@type string?
|
||||||
|
local currentKey = vertexKey(boundaryEdges[1].p1)
|
||||||
|
|
||||||
|
while currentKey and not visited[currentKey] do
|
||||||
|
visited[currentKey] = true
|
||||||
|
local pos = vertexData[currentKey]:getPeakPos()
|
||||||
|
|
||||||
|
table.insert(boundary, {
|
||||||
|
x = pos.x,
|
||||||
|
y = 0,
|
||||||
|
z = pos.z
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Move to next unvisited neighbor
|
||||||
|
local nextKey = nil
|
||||||
|
|
||||||
|
for _, neighborKey in ipairs(adjacency[currentKey] or {}) do
|
||||||
|
if not visited[neighborKey] then
|
||||||
|
nextKey = neighborKey
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
currentKey = nextKey
|
||||||
|
end
|
||||||
|
|
||||||
|
return boundary
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- --- REGISTRATION METHODS ---
|
-- --- REGISTRATION METHODS ---
|
||||||
@@ -240,10 +387,7 @@ end
|
|||||||
---@param color ColorString Noise color. Must be unique.
|
---@param color ColorString Noise color. Must be unique.
|
||||||
---@param noiseParams NoiseParams Fractal noise parameters.
|
---@param noiseParams NoiseParams Fractal noise parameters.
|
||||||
function MapGen:registerLayerNoiseColor(layerName, category, color, noiseParams)
|
function MapGen:registerLayerNoiseColor(layerName, category, color, noiseParams)
|
||||||
---@type MapGen.Layer
|
local layer = self:getLayerByName(layerName)
|
||||||
local layer = self.layersByName[layerName]
|
|
||||||
|
|
||||||
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
|
||||||
|
|
||||||
layer:addNoiseParamsColor(category, color, noiseParams)
|
layer:addNoiseParamsColor(category, color, noiseParams)
|
||||||
end
|
end
|
||||||
@@ -279,14 +423,11 @@ end
|
|||||||
---@param category MapGen.Layer.Category Category indicating what will be generated by peak.
|
---@param category MapGen.Layer.Category Category indicating what will be generated by peak.
|
||||||
---@param def MapGen.PeakDef Peak description table, see details `MapGen.PeakDef`.
|
---@param def MapGen.PeakDef Peak description table, see details `MapGen.PeakDef`.
|
||||||
function MapGen:registerPeak(layerName, category, def)
|
function MapGen:registerPeak(layerName, category, def)
|
||||||
---@type MapGen.Layer
|
local layer = self:getLayerByName(layerName)
|
||||||
local layer = self.layersByName[layerName]
|
|
||||||
|
|
||||||
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
--assert(self:getPeakByPos(layer, category, def.pos) == nil,
|
||||||
|
--('In the `%s` layer in the `%s` category there is already a peak with coordinates: %s, %s, %s.'):format(
|
||||||
assert(self:getPeakByPos(layer, category, def.pos) == nil,
|
-- layerName, category, def.pos.x, def.pos.y, def.pos.z))
|
||||||
('In the `%s` layer in the `%s` category there is already a peak with coordinates: %s, %s, %s.'):format(
|
|
||||||
layerName, category, def.pos.x, def.pos.y, def.pos.z))
|
|
||||||
|
|
||||||
---@type MapGen.Peak
|
---@type MapGen.Peak
|
||||||
local peak = Peak:new(def)
|
local peak = Peak:new(def)
|
||||||
@@ -336,17 +477,34 @@ end
|
|||||||
---@param category MapGen.Layer.Category Category indicating what will be generated by peaks.
|
---@param category MapGen.Layer.Category Category indicating what will be generated by peaks.
|
||||||
---@param groups? table<string, number> Groups that will be added to all peaks.
|
---@param groups? table<string, number> Groups that will be added to all peaks.
|
||||||
function MapGen:register2DPeaksFromFile(layerName, map, scale,zeroPos, category, groups)
|
function MapGen:register2DPeaksFromFile(layerName, map, scale,zeroPos, category, groups)
|
||||||
|
if scale < 2 then
|
||||||
|
error('The map scale should not be less than 2.')
|
||||||
|
end
|
||||||
|
|
||||||
local modPath = core.get_modpath(core.get_current_modname())
|
local modPath = core.get_modpath(core.get_current_modname())
|
||||||
local peaks = ff2luat(modPath .. '/textures/maps/' .. map)
|
local peaks = ff2luat(modPath .. '/textures/maps/' .. map)
|
||||||
|
|
||||||
|
---@type {h:integer, w:integer}
|
||||||
local mapSize = peaks.size
|
local mapSize = peaks.size
|
||||||
peaks.size = nil
|
peaks.size = nil
|
||||||
|
|
||||||
|
zeroPos.x = zeroPos.x + mathRound(mapSize.w/2)
|
||||||
|
zeroPos.y = zeroPos.y + mathRound(mapSize.h/2)
|
||||||
|
|
||||||
|
local x, z
|
||||||
|
|
||||||
for color, peaksPos in pairs(peaks) do
|
for color, peaksPos in pairs(peaks) do
|
||||||
for _, peakPos in ipairs(peaksPos) do
|
for _, peakPos in ipairs(peaksPos) do
|
||||||
|
x, z = (peakPos.x - zeroPos.x - 1) * scale, (peakPos.y - zeroPos.y - 1) * -scale
|
||||||
|
|
||||||
|
-- Converting a rectangular grid into an isometric-like one.
|
||||||
|
if peakPos.y % 2 == 1 then
|
||||||
|
x = x + (scale/2)
|
||||||
|
end
|
||||||
|
|
||||||
---@type MapGen.PeakDef
|
---@type MapGen.PeakDef
|
||||||
local def = {
|
local def = {
|
||||||
pos = vector.new((peakPos.x - zeroPos.x - 1) * scale, 0, (peakPos.y - zeroPos.y - 1) * scale),
|
pos = vector.new(x, 0, z),
|
||||||
color = color,
|
color = color,
|
||||||
groups = groups,
|
groups = groups,
|
||||||
}
|
}
|
||||||
@@ -363,10 +521,7 @@ end
|
|||||||
---@param pos Position The position of the peak to which the group should be added.
|
---@param pos Position The position of the peak to which the group should be added.
|
||||||
---@param groups table<string, number> Groups to be added.
|
---@param groups table<string, number> Groups to be added.
|
||||||
function MapGen:addGroupsToPeakByPos(layerName, category, pos, groups)
|
function MapGen:addGroupsToPeakByPos(layerName, category, pos, groups)
|
||||||
---@type MapGen.Layer
|
local layer = self:getLayerByName(layerName)
|
||||||
local layer = self.layersByName[layerName]
|
|
||||||
|
|
||||||
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
|
||||||
|
|
||||||
local peak = self:getPeakByPos(layer, category, pos)
|
local peak = self:getPeakByPos(layer, category, pos)
|
||||||
assert( peak ~= nil, ('In the `%s` layer in the `%s` category there is no peak with coordinates: %s, %s, %s.'):format(
|
assert( peak ~= nil, ('In the `%s` layer in the `%s` category there is no peak with coordinates: %s, %s, %s.'):format(
|
||||||
@@ -380,10 +535,7 @@ end
|
|||||||
---@param biomeName string The name to be assigned to the biome. The name must be unique for each biome.
|
---@param biomeName string The name to be assigned to the biome. The name must be unique for each biome.
|
||||||
---@param def MapGen.BiomeDef Biome description table, see details `MapGen.BiomeDef`
|
---@param def MapGen.BiomeDef Biome description table, see details `MapGen.BiomeDef`
|
||||||
function MapGen:registerBiome(layerName, biomeName, def)
|
function MapGen:registerBiome(layerName, biomeName, def)
|
||||||
local layer = self.layersByName[layerName]
|
local layer = self:getLayerByName(layerName)
|
||||||
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
|
||||||
---TODO: перенести проверку на уникальность в конструктор
|
|
||||||
assert(layer.biomesByName[biomeName] == nil, ('A biome named `%s` already exists in the `%s` layer.'):format(biomeName, layerName))
|
|
||||||
|
|
||||||
local biome = Biome:new(biomeName, def)
|
local biome = Biome:new(biomeName, def)
|
||||||
|
|
||||||
@@ -394,25 +546,35 @@ end
|
|||||||
---@param layerName string The name of the layer in which the new cavern will be included.
|
---@param layerName string The name of the layer in which the new cavern will be included.
|
||||||
---@param cavernName string The name to be assigned to the cavern. The name must be unique for each cavern.
|
---@param cavernName string The name to be assigned to the cavern. The name must be unique for each cavern.
|
||||||
---@param def MapGen.CavernDef Cavern description table, see details `MapGen.CavernDef`
|
---@param def MapGen.CavernDef Cavern description table, see details `MapGen.CavernDef`
|
||||||
function MapGen:registerCavern(layerName, cavernName, def)
|
---@param regionVertices Position[]? The region to which the cave generation will be limited.
|
||||||
local layer = self.layersByName[layerName]
|
function MapGen:registerCavern(layerName, cavernName, def, regionVertices)
|
||||||
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
local layer = self:getLayerByName(layerName)
|
||||||
---TODO: перенести проверку на уникальность в конструктор
|
|
||||||
assert(layer.cavernsByName[cavernName] == nil, ('A cavern named `%s` already exists in the `%s` layer.'):format(cavernName, layerName))
|
if regionVertices ~= nil then
|
||||||
|
self:registerRegion(layerName, cavernName, {
|
||||||
|
vertices = regionVertices
|
||||||
|
})
|
||||||
|
|
||||||
|
def.isRegional = true
|
||||||
|
end
|
||||||
|
|
||||||
local cavern = Cavern:new(cavernName, def)
|
local cavern = Cavern:new(cavernName, def)
|
||||||
|
|
||||||
layer:addCavern(cavernName, cavern)
|
layer:addCavern(cavernName, cavern)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Designate the world region between the vertices as `MapGen.Region` and give it a name.
|
---Mark the world region between the vertices as `MapGen.Region` and give it a name.
|
||||||
---@param layerName string The name of the layer in which the new region will be included.
|
---@param layerName string The name of the layer in which the new region will be included.
|
||||||
---@param regionName string The name to be assigned to the region. The name must be unique for each region.
|
---@param regionName string The name to be assigned to the region. The name must be unique for each region.
|
||||||
---@param def MapGen.RegionDef Region description table, see details `MapGen.RegionDef`
|
---@param def MapGen.RegionDef Region description table, see details `MapGen.RegionDef`
|
||||||
function MapGen:registerRegion(layerName, regionName, def)
|
function MapGen:registerRegion(layerName, regionName, def)
|
||||||
local layer = self.layersByName[layerName]
|
if regionName == 'landscape_boundary' or
|
||||||
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
regionName == 'temp_boundary' or
|
||||||
assert(layer.regionsByName[regionName] == nil, ('A region named `%s` already exists in the `%s` layer.'):format(regionName, layerName))
|
regionName == 'humidity_boundary' then
|
||||||
|
error(('The name `%s` is reserved for special regions and cannot be used.'):format(regionName))
|
||||||
|
end
|
||||||
|
|
||||||
|
local layer = self:getLayerByName(layerName)
|
||||||
|
|
||||||
local region = Region:new(regionName, def)
|
local region = Region:new(regionName, def)
|
||||||
|
|
||||||
@@ -420,15 +582,32 @@ function MapGen:registerRegion(layerName, regionName, def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- --- INITIALIZATION METHODS ---
|
-- --- INITIALIZATION METHODS ---
|
||||||
|
|
||||||
|
---Initialize the boundary region for a triangulated area.
|
||||||
|
---@param layer MapGen.Layer
|
||||||
|
---@param category MapGen.Layer.Category
|
||||||
|
---@param triangles MapGen.Triangle[]
|
||||||
|
function MapGen:initTriangultaionBoundaryRegion(layer, category, triangles)
|
||||||
|
local regionVertices = self:getTriangulateBoundaryVertices(triangles)
|
||||||
|
|
||||||
|
local regionName = category..'_boundary'
|
||||||
|
|
||||||
|
local region = Region:new(regionName, {vertices = regionVertices})
|
||||||
|
|
||||||
|
layer:addRegion(regionName, region)
|
||||||
|
end
|
||||||
|
|
||||||
---Divide all layers into triangles whose vertices are the `Mapgen.Peak` belonging to these layers.
|
---Divide all layers into triangles whose vertices are the `Mapgen.Peak` belonging to these layers.
|
||||||
function MapGen:initLayersTriangultaion()
|
function MapGen:initLayersTriangultaion()
|
||||||
---@param layer MapGen.Layer
|
---@param layer MapGen.Layer
|
||||||
for _, layer in ipairs(self.layersList) do
|
for _, layer in ipairs(self.layersList) do
|
||||||
for category, peaks in pairs(layer.peaksList) do
|
for category, peaks in pairs(layer.peaksList) do
|
||||||
|
local triangles = Triangulation.triangulate(peaks)
|
||||||
|
|
||||||
layer.trianglesList[category] = Triangulation.triangulate(peaks)
|
layer.trianglesList[category] = triangles
|
||||||
|
--self:initTriangultaionBoundaryRegion(layer, category, triangles)
|
||||||
-- layer.tetrahedronsList = Triangulation.tetrahedralize(layer.peaksList) -- 3D not supported
|
-- layer.tetrahedronsList = Triangulation.tetrahedralize(layer.peaksList) -- 3D not supported
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -469,22 +648,6 @@ end
|
|||||||
|
|
||||||
-- --- GENERATION METHODS ---
|
-- --- GENERATION METHODS ---
|
||||||
|
|
||||||
---Returns `true` if there is a cavern at the specified coordinates.
|
|
||||||
---@param layer MapGen.Layer
|
|
||||||
---@param x integer
|
|
||||||
---@param y integer
|
|
||||||
---@param z integer
|
|
||||||
---@return boolean
|
|
||||||
local function isCavern(layer, x, y, z)
|
|
||||||
for _, cavern in ipairs(layer.cavernsList) do
|
|
||||||
if cavern:isCavern(x, y, z) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
---The core logic of world generation. Determines which node type (water, rock, soil, air)
|
---The core logic of world generation. Determines which node type (water, rock, soil, air)
|
||||||
---and which biome will be generated at the specified coordinates.
|
---and which biome will be generated at the specified coordinates.
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
@@ -541,7 +704,7 @@ local function generateNode(mapGenerator, layer, height, temp, humidity, data, i
|
|||||||
-- If the block is below the surface height...
|
-- If the block is below the surface height...
|
||||||
elseif y <= height then
|
elseif y <= height then
|
||||||
-- ... and a cavern is generated in the block...
|
-- ... and a cavern is generated in the block...
|
||||||
if isCavern(layer, x, y, z) then
|
if mapGenerator:isCavern(layer, x, y, z) then
|
||||||
-- ... then airspace is generated.
|
-- ... then airspace is generated.
|
||||||
biome:generateCavernAir(mapGenerator, data, index, x, y, z)
|
biome:generateCavernAir(mapGenerator, data, index, x, y, z)
|
||||||
|
|
||||||
@@ -694,6 +857,10 @@ function MapGen:getNoises2dValue(category, layer, x, y, z)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not self:pointInRegion2D(layer, category..'_boundary', {x=x, y=y, z=z}) then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
---@param triangle MapGen.Triangle
|
---@param triangle MapGen.Triangle
|
||||||
for _, triangle in ipairs(layer.trianglesList[category]) do
|
for _, triangle in ipairs(layer.trianglesList[category]) do
|
||||||
if pointInTriangle2D(x, z, triangle) then
|
if pointInTriangle2D(x, z, triangle) then
|
||||||
@@ -829,9 +996,23 @@ local function generatorHandler(mapGenerator, data, index, x, y, z)
|
|||||||
|
|
||||||
-- If the value of the noise is `nil`,
|
-- If the value of the noise is `nil`,
|
||||||
-- then the point does not fall within any of the triangles.
|
-- then the point does not fall within any of the triangles.
|
||||||
local noiseHeightValue = mapGenerator:getNoises2dValue('landscape', layer, x, y, z) or 0.0
|
local noiseHeightValue = mapGenerator:getNoises2dValue('landscape', layer, x, y, z)
|
||||||
local noiseTempValue = mapGenerator:getNoises2dValue('temp', layer, x, y, z) or 0.0
|
if noiseHeightValue == nil then
|
||||||
local noiseHumidityValue = mapGenerator:getNoises2dValue('humidity', layer, x, y, z) or 0.0
|
data[index] = core.CONTENT_IGNORE
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local noiseTempValue = mapGenerator:getNoises2dValue('temp', layer, x, y, z)
|
||||||
|
if noiseTempValue == nil then
|
||||||
|
data[index] = core.CONTENT_IGNORE
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local noiseHumidityValue = mapGenerator:getNoises2dValue('humidity', layer, x, y, z)
|
||||||
|
if noiseHumidityValue == nil then
|
||||||
|
data[index] = core.CONTENT_IGNORE
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- We recalculate the climate based on altitude.
|
-- We recalculate the climate based on altitude.
|
||||||
noiseTempValue = layer:calcTemp(noiseTempValue, y)
|
noiseTempValue = layer:calcTemp(noiseTempValue, y)
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
local mathMin, mathMax, mathAbs
|
local mathMin, mathMax, mathAbs, mathClamp
|
||||||
= math.min, math.max, math.abs
|
= math.min, math.max, math.abs, math.clamp
|
||||||
|
|
||||||
local getInstance = Class.getInstance
|
local getInstance = Class.getInstance
|
||||||
|
|
||||||
---@class MapGen.Cavern
|
---@class MapGen.Cavern
|
||||||
---@field name string
|
---@field name string
|
||||||
|
---@field isRegional boolean
|
||||||
---@field minY number
|
---@field minY number
|
||||||
---@field maxY number
|
---@field maxY number
|
||||||
---@field smoothDistance number
|
---@field smoothDistance number
|
||||||
@@ -18,6 +19,7 @@ local Cavern = {}
|
|||||||
---
|
---
|
||||||
---**Only for EmmyLua.**
|
---**Only for EmmyLua.**
|
||||||
---@class MapGen.CavernDef
|
---@class MapGen.CavernDef
|
||||||
|
---@field isRegional boolean?
|
||||||
---@field minY number
|
---@field minY number
|
||||||
---@field maxY number
|
---@field maxY number
|
||||||
---@field noiseParams NoiseParams
|
---@field noiseParams NoiseParams
|
||||||
@@ -58,6 +60,7 @@ function Cavern:new(name, def)
|
|||||||
maxY = def.maxY,
|
maxY = def.maxY,
|
||||||
smoothDistance = def.smoothDistance,
|
smoothDistance = def.smoothDistance,
|
||||||
threshold = def.threshold,
|
threshold = def.threshold,
|
||||||
|
isRegional = def.isRegional or false,
|
||||||
})
|
})
|
||||||
|
|
||||||
function instance:getNoise()
|
function instance:getNoise()
|
||||||
@@ -79,32 +82,49 @@ function Cavern:new(name, def)
|
|||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param y number
|
---@param distance number
|
||||||
---@param minY number
|
---@return number
|
||||||
---@param maxY number
|
function Cavern:calcCavernWeight(distance)
|
||||||
---@param smoothDistance number
|
return mathClamp(distance / self.smoothDistance, 0, 1)
|
||||||
---@return number
|
|
||||||
local function calcCavernWeight(y, smoothDistance, minY, maxY)
|
|
||||||
local maxDist = maxY - y
|
|
||||||
local minDist = y - minY
|
|
||||||
|
|
||||||
return mathMax(0, mathMin(maxDist / smoothDistance, minDist / smoothDistance, 1))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns `true` if there is a cavern at the specified coordinates.
|
---Returns `true` if there is a cavern at the specified coordinates.
|
||||||
---@param x integer
|
---@param x integer
|
||||||
---@param y integer
|
---@param y integer
|
||||||
---@param z integer
|
---@param z integer
|
||||||
---@return boolean
|
---@param distance number
|
||||||
function Cavern:isCavern(x, y, z)
|
---@return boolean
|
||||||
|
function Cavern:isCavern(x, y, z, distance)
|
||||||
|
local minY, maxY = self.minY, self.maxY
|
||||||
|
|
||||||
|
if y >= maxY or y <= minY then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
distance = mathMin(maxY - y, y - minY, distance)
|
||||||
|
|
||||||
|
local noise = self:getNoise()
|
||||||
|
local weight = self:calcCavernWeight(distance)
|
||||||
|
|
||||||
|
return noise:get_3d({x = x, y = y, z = z}) * weight > self.threshold
|
||||||
|
end
|
||||||
|
|
||||||
|
---Returns `true` if there is a cavern at the specified coordinates.
|
||||||
|
---@param x integer
|
||||||
|
---@param y integer
|
||||||
|
---@param z integer
|
||||||
|
---@return boolean
|
||||||
|
function Cavern:isLayeredCavern(x, y, z)
|
||||||
local minY, maxY = self.minY, self.maxY
|
local minY, maxY = self.minY, self.maxY
|
||||||
|
|
||||||
if y > maxY or y < minY then
|
if y > maxY or y < minY then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local distance = mathMin(maxY - y, y - minY)
|
||||||
|
|
||||||
local noise = self:getNoise()
|
local noise = self:getNoise()
|
||||||
local weight = calcCavernWeight(y, self.smoothDistance, minY, maxY)
|
local weight = self:calcCavernWeight(distance)
|
||||||
|
|
||||||
return noise:get_3d({x = x, y = y, z = z}) * weight > self.threshold
|
return noise:get_3d({x = x, y = y, z = z}) * weight > self.threshold
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -129,6 +129,21 @@ function Layer:addPeak(category, peak)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Returns the `MapGen.Peak` at the coordinates. If there is no peak at these coordinates, it returns `nil`.
|
||||||
|
---@param category MapGen.Layer.Category The category in which the peak is located.
|
||||||
|
---@param pos Position Coordinate of the desired peak.
|
||||||
|
---@return MapGen.Peak?
|
||||||
|
function Layer:getPeakByPos(category, pos)
|
||||||
|
pos = vector.new(pos)
|
||||||
|
|
||||||
|
---@param peak MapGen.Peak
|
||||||
|
for _, peak in ipairs(self.peaksList[category]) do
|
||||||
|
if peak:getPeakPos() == pos then
|
||||||
|
return peak
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---Adds a NoiseParams color to the `Layer.noisesParamsByColor`
|
---Adds a NoiseParams color to the `Layer.noisesParamsByColor`
|
||||||
---@param category MapGen.Layer.Category
|
---@param category MapGen.Layer.Category
|
||||||
---@param color ColorString
|
---@param color ColorString
|
||||||
@@ -179,26 +194,69 @@ end
|
|||||||
---@param biomeName string
|
---@param biomeName string
|
||||||
---@param biome MapGen.Biome
|
---@param biome MapGen.Biome
|
||||||
function Layer:addBiome(biomeName, biome)
|
function Layer:addBiome(biomeName, biome)
|
||||||
-- TODO: перенести сюда проверку на уникальность
|
assert(self.biomesByName[biomeName] == nil,
|
||||||
|
('A biome named `%s` already exists in the `%s` layer.'):format(
|
||||||
|
biomeName, self.name))
|
||||||
|
|
||||||
self.biomesByName[biomeName] = biome
|
self.biomesByName[biomeName] = biome
|
||||||
table.insert(self.biomesList, biome)
|
table.insert(self.biomesList, biome)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Returns a biome by name, if there is no such biome, it will raise an error.
|
||||||
|
---@param biomeName string
|
||||||
|
---@return MapGen.Biome
|
||||||
|
function Layer:getBiomeByName(biomeName)
|
||||||
|
local biome = self.biomesByName[biomeName]
|
||||||
|
assert(biome ~= nil, ('Biome named `%s` does not exist in the `%s` layer.'):format(
|
||||||
|
biomeName, self.name))
|
||||||
|
|
||||||
|
return biome
|
||||||
|
end
|
||||||
|
|
||||||
---Adds a cavern to the `Layer.cavernsByName` & `Layer.cavernsList`
|
---Adds a cavern to the `Layer.cavernsByName` & `Layer.cavernsList`
|
||||||
---@param cavernName string
|
---@param cavernName string
|
||||||
---@param cavern MapGen.Cavern
|
---@param cavern MapGen.Cavern
|
||||||
function Layer:addCavern(cavernName, cavern)
|
function Layer:addCavern(cavernName, cavern)
|
||||||
-- TODO: перенести сюда проверку на уникальность
|
assert(self.cavernsByName[cavernName] == nil,
|
||||||
|
('A cavern named `%s` already exists in the `%s` layer.'):format(
|
||||||
|
cavernName, self.name))
|
||||||
|
|
||||||
self.cavernsByName[cavernName] = cavern
|
self.cavernsByName[cavernName] = cavern
|
||||||
table.insert(self.cavernsList, cavern)
|
table.insert(self.cavernsList, cavern)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Returns a cavern by name, if there is no such cavern, it will raise an error.
|
||||||
|
---@param cavernName string
|
||||||
|
---@return MapGen.Cavern
|
||||||
|
function Layer:getCavernByName(cavernName)
|
||||||
|
local cavern = self.cavernsByName[cavernName]
|
||||||
|
assert(cavern ~= nil, ('Cavern named `%s` does not exist in the `%s` layer.'):format(
|
||||||
|
cavernName, self.name))
|
||||||
|
|
||||||
|
return cavern
|
||||||
|
end
|
||||||
|
|
||||||
function Layer:addRegion(regionName, region)
|
function Layer:addRegion(regionName, region)
|
||||||
-- TODO: перенести сюда проверку на уникальность
|
assert(self.regionsByName[regionName] == nil,
|
||||||
|
('A region named `%s` already exists in the `%s` layer.'):format(
|
||||||
|
regionName, self.name))
|
||||||
|
|
||||||
self.regionsByName[regionName] = region
|
self.regionsByName[regionName] = region
|
||||||
--table.insert(self.regionsList, region)
|
--table.insert(self.regionsList, region)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Returns a region by name, if there is no such region, it will raise an error.
|
||||||
|
---@param regionName string
|
||||||
|
---@return MapGen.Region
|
||||||
|
function Layer:getRegionByName(regionName)
|
||||||
|
local region = self.regionsByName[regionName]
|
||||||
|
assert(region ~= nil, ('Region named `%s` does not exist in the `%s` layer.'):format(
|
||||||
|
regionName, self.name))
|
||||||
|
|
||||||
|
return region
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---@param height number
|
---@param height number
|
||||||
---@param biomesList MapGen.Biome[]
|
---@param biomesList MapGen.Biome[]
|
||||||
---@return string[], MapGen.Biome[]
|
---@return string[], MapGen.Biome[]
|
||||||
|
|||||||
@@ -12,13 +12,12 @@ listForm:list('current_player', 'main', 10.5, 6.5, 8, 4)
|
|||||||
|
|
||||||
local listFormItems = Formspec:new()
|
local listFormItems = Formspec:new()
|
||||||
|
|
||||||
local items = core.registered_nodes
|
local items = table.get_keys(core.registered_nodes)
|
||||||
|
table.sort(items)
|
||||||
local w, h = 0, 0
|
local w, h = 0, 0
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param def NodeDefinition
|
for _, name in ipairs(items) do
|
||||||
for name, def in pairs(items) do
|
|
||||||
listFormItems:itemImageButton(w, h, 1, 1, name, name..'::item_button')
|
listFormItems:itemImageButton(w, h, 1, 1, name, name..'::item_button')
|
||||||
|
|
||||||
w = w + 1
|
w = w + 1
|
||||||
@@ -31,10 +30,9 @@ end
|
|||||||
|
|
||||||
--listFormItems:list('current_player', 'main', 0, 0, 1, 32)
|
--listFormItems:list('current_player', 'main', 0, 0, 1, 32)
|
||||||
|
|
||||||
listForm:scrollContainer(listFormItems, 0.5, 0.5, 9, 11, 'admin_commands:list_items', 'vertical')
|
listForm:
|
||||||
listForm:scrollbar(10, 0.5, 0.25, 10, 'vertical', 'admin_commands:list_items')
|
scrollContainer(listFormItems, 0.5, 0.5, 9, 11, 'admin_commands:list_items', 'vertical'):
|
||||||
|
scrollbar(10, 0.5, 0.25, 10, 'vertical', 'admin_commands:list_items')
|
||||||
core.log(listForm:toString())
|
|
||||||
|
|
||||||
core.register_chatcommand('list', {
|
core.register_chatcommand('list', {
|
||||||
privs = {server = true},
|
privs = {server = true},
|
||||||
|
|||||||
@@ -15,14 +15,16 @@ local MapGen = mapGenRequire('MapGen')
|
|||||||
air = 'air',
|
air = 'air',
|
||||||
|
|
||||||
-- Rocks
|
-- Rocks
|
||||||
sylite = 'rocks:sylite',
|
sylite = 'rocks:sylite',
|
||||||
tauitite = 'rocks:tauitite',
|
syliteGray = 'rocks:sylite_gray',
|
||||||
iyellite = 'rocks:iyellite',
|
syliteBlack = 'rocks:sylite_black',
|
||||||
falmyte = 'rocks:falmyte',
|
tauitite = 'rocks:tauitite',
|
||||||
hapcoryte = 'rocks:hapcoryte',
|
iyellite = 'rocks:iyellite',
|
||||||
burcite = 'rocks:burcite',
|
falmyte = 'rocks:falmyte',
|
||||||
felhor = 'rocks:felhor',
|
hapcoryte = 'rocks:hapcoryte',
|
||||||
malachite = 'rocks:malachite',
|
burcite = 'rocks:burcite',
|
||||||
|
felhor = 'rocks:felhor',
|
||||||
|
malachite = 'rocks:malachite',
|
||||||
|
|
||||||
-- Liquids
|
-- Liquids
|
||||||
water = 'liquids:water_source',
|
water = 'liquids:water_source',
|
||||||
@@ -50,137 +52,398 @@ mapGenerator:registerLayer('midgard', {
|
|||||||
biomesGorizontalScattering = 5
|
biomesGorizontalScattering = 5
|
||||||
})
|
})
|
||||||
|
|
||||||
local land1 = {
|
|
||||||
offset = -10,
|
-- TODO: Config should be imported from .json file in the world's folder
|
||||||
scale = 5,
|
local ocean = {
|
||||||
spread = {x = 10, y = 10, z = 10},
|
['landscape'] = {
|
||||||
seed = 47,
|
offset = -10,
|
||||||
octaves = 3,
|
scale = 3,
|
||||||
persistence = 0.4,
|
spread = {x = 10, y = 10, z = 10},
|
||||||
lacunarity = 2,
|
seed = 420,
|
||||||
|
octaves = 2,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['temp'] = {
|
||||||
|
offset = -10,
|
||||||
|
scale = 5,
|
||||||
|
spread = {x = 10, y = 10, z = 10},
|
||||||
|
seed = 47,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['humidity'] = {
|
||||||
|
offset = -10,
|
||||||
|
scale = 5,
|
||||||
|
spread = {x = 10, y = 10, z = 10},
|
||||||
|
seed = 47,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local land2 = {
|
local common_lands = {
|
||||||
offset = 20,
|
['landscape'] = {
|
||||||
scale = 5,
|
offset = 0,
|
||||||
spread = {x = 30, y = 30, z = 30},
|
scale = 5,
|
||||||
seed = 47,
|
spread = {x = 10, y = 10, z = 10},
|
||||||
octaves = 3,
|
seed = 88005553535,
|
||||||
persistence = 0.4,
|
octaves = 2,
|
||||||
lacunarity = 2,
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['temp'] = {
|
||||||
|
offset = -10,
|
||||||
|
scale = 5,
|
||||||
|
spread = {x = 10, y = 10, z = 10},
|
||||||
|
seed = 47,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['humidity'] = {
|
||||||
|
offset = -10,
|
||||||
|
scale = 5,
|
||||||
|
spread = {x = 10, y = 10, z = 10},
|
||||||
|
seed = 47,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local land3 = {
|
local foresty_lands = {
|
||||||
offset = 40,
|
['landscape'] = {
|
||||||
scale = 20,
|
offset = 5,
|
||||||
spread = {x = 45, y = 20, z = 45},
|
scale = 8,
|
||||||
seed = 472,
|
spread = {x = 15, y = 15, z = 15},
|
||||||
octaves = 3,
|
seed = 12345,
|
||||||
persistence = 0.3,
|
octaves = 3,
|
||||||
lacunarity = 2,
|
persistence = 0.5,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['temp'] = {
|
||||||
|
offset = 20,
|
||||||
|
scale = 10,
|
||||||
|
spread = {x = 20, y = 20, z = 20},
|
||||||
|
seed = 48,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['humidity'] = {
|
||||||
|
offset = 60,
|
||||||
|
scale = 15,
|
||||||
|
spread = {x = 15, y = 15, z = 15},
|
||||||
|
seed = 49,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local climat1 = {
|
local hilly_lands = {
|
||||||
offset = 80,
|
['landscape'] = {
|
||||||
scale = 10,
|
offset = 15,
|
||||||
spread = {x = 10, y = 10, z = 10},
|
scale = 12,
|
||||||
seed = 47,
|
spread = {x = 20, y = 20, z = 20},
|
||||||
octaves = 8,
|
seed = 54321,
|
||||||
persistence = 0.6,
|
octaves = 3,
|
||||||
lacunarity = 2,
|
persistence = 0.5,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['temp'] = {
|
||||||
|
offset = 15,
|
||||||
|
scale = 10,
|
||||||
|
spread = {x = 25, y = 25, z = 25},
|
||||||
|
seed = 50,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['humidity'] = {
|
||||||
|
offset = 40,
|
||||||
|
scale = 15,
|
||||||
|
spread = {x = 20, y = 20, z = 20},
|
||||||
|
seed = 51,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local climat2 = {
|
local low_mountains = {
|
||||||
offset = 30,
|
['landscape'] = {
|
||||||
scale = 10,
|
offset = 30,
|
||||||
spread = {x = 10, y = 10, z = 10},
|
scale = 20,
|
||||||
seed = 47,
|
spread = {x = 25, y = 25, z = 25},
|
||||||
octaves = 8,
|
seed = 11111,
|
||||||
persistence = 0.6,
|
octaves = 4,
|
||||||
lacunarity = 2,
|
persistence = 0.5,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['temp'] = {
|
||||||
|
offset = 5,
|
||||||
|
scale = 15,
|
||||||
|
spread = {x = 30, y = 30, z = 30},
|
||||||
|
seed = 52,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['humidity'] = {
|
||||||
|
offset = 30,
|
||||||
|
scale = 15,
|
||||||
|
spread = {x = 25, y = 25, z = 25},
|
||||||
|
seed = 53,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local climat0 = {
|
local high_mountains = {
|
||||||
offset = 50,
|
['landscape'] = {
|
||||||
scale = 0,
|
offset = 60,
|
||||||
spread = {x = 10, y = 10, z = 10},
|
scale = 35,
|
||||||
seed = 47,
|
spread = {x = 30, y = 30, z = 30},
|
||||||
octaves = 8,
|
seed = 22222,
|
||||||
persistence = 0.4,
|
octaves = 4,
|
||||||
lacunarity = 2,
|
persistence = 0.55,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['temp'] = {
|
||||||
|
offset = -10,
|
||||||
|
scale = 15,
|
||||||
|
spread = {x = 35, y = 35, z = 35},
|
||||||
|
seed = 54,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['humidity'] = {
|
||||||
|
offset = 20,
|
||||||
|
scale = 10,
|
||||||
|
spread = {x = 30, y = 30, z = 30},
|
||||||
|
seed = 55,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local highest_peaks = {
|
||||||
|
['landscape'] = {
|
||||||
|
offset = 100,
|
||||||
|
scale = 50,
|
||||||
|
spread = {x = 40, y = 40, z = 40},
|
||||||
|
seed = 33333,
|
||||||
|
octaves = 5,
|
||||||
|
persistence = 0.6,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['temp'] = {
|
||||||
|
offset = -30,
|
||||||
|
scale = 10,
|
||||||
|
spread = {x = 50, y = 50, z = 50},
|
||||||
|
seed = 56,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['humidity'] = {
|
||||||
|
offset = 10,
|
||||||
|
scale = 10,
|
||||||
|
spread = {x = 40, y = 40, z = 40},
|
||||||
|
seed = 57,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local rivers = {
|
||||||
|
['landscape'] = {
|
||||||
|
offset = -5,
|
||||||
|
scale = 2,
|
||||||
|
spread = {x = 5, y = 5, z = 100},
|
||||||
|
seed = 44444,
|
||||||
|
octaves = 2,
|
||||||
|
persistence = 0.3,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['temp'] = {
|
||||||
|
offset = 10,
|
||||||
|
scale = 5,
|
||||||
|
spread = {x = 50, y = 50, z = 50},
|
||||||
|
seed = 58,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['humidity'] = {
|
||||||
|
offset = 80,
|
||||||
|
scale = 10,
|
||||||
|
spread = {x = 20, y = 20, z = 20},
|
||||||
|
seed = 59,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local lakes = {
|
||||||
|
['landscape'] = {
|
||||||
|
offset = -8,
|
||||||
|
scale = 2,
|
||||||
|
spread = {x = 15, y = 15, z = 15},
|
||||||
|
seed = 55555,
|
||||||
|
octaves = 2,
|
||||||
|
persistence = 0.3,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['temp'] = {
|
||||||
|
offset = 10,
|
||||||
|
scale = 5,
|
||||||
|
spread = {x = 30, y = 30, z = 30},
|
||||||
|
seed = 60,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['humidity'] = {
|
||||||
|
offset = 90,
|
||||||
|
scale = 5,
|
||||||
|
spread = {x = 20, y = 20, z = 20},
|
||||||
|
seed = 61,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local rocky_shores = {
|
||||||
|
['landscape'] = {
|
||||||
|
offset = 2,
|
||||||
|
scale = 4,
|
||||||
|
spread = {x = 8, y = 8, z = 8},
|
||||||
|
seed = 66666,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.5,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['temp'] = {
|
||||||
|
offset = 15,
|
||||||
|
scale = 8,
|
||||||
|
spread = {x = 15, y = 15, z = 15},
|
||||||
|
seed = 62,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['humidity'] = {
|
||||||
|
offset = 70,
|
||||||
|
scale = 10,
|
||||||
|
spread = {x = 15, y = 15, z = 15},
|
||||||
|
seed = 63,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local rocky_islands = {
|
||||||
|
['landscape'] = {
|
||||||
|
offset = 8,
|
||||||
|
scale = 10,
|
||||||
|
spread = {x = 12, y = 12, z = 12},
|
||||||
|
seed = 77777,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.5,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['temp'] = {
|
||||||
|
offset = 20,
|
||||||
|
scale = 8,
|
||||||
|
spread = {x = 20, y = 20, z = 20},
|
||||||
|
seed = 64,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['humidity'] = {
|
||||||
|
offset = 60,
|
||||||
|
scale = 15,
|
||||||
|
spread = {x = 20, y = 20, z = 20},
|
||||||
|
seed = 65,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local swamp_land = {
|
||||||
|
['landscape'] = {
|
||||||
|
offset = 1,
|
||||||
|
scale = 2,
|
||||||
|
spread = {x = 12, y = 12, z = 12},
|
||||||
|
seed = 88888,
|
||||||
|
octaves = 2,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['temp'] = {
|
||||||
|
offset = 25,
|
||||||
|
scale = 5,
|
||||||
|
spread = {x = 15, y = 15, z = 15},
|
||||||
|
seed = 66,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
['humidity'] = {
|
||||||
|
offset = 85,
|
||||||
|
scale = 10,
|
||||||
|
spread = {x = 15, y = 15, z = 15},
|
||||||
|
seed = 67,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.4,
|
||||||
|
lacunarity = 2,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
local v = vector.new
|
local v = vector.new
|
||||||
--[[
|
|
||||||
mapGenerator:register2DPeaks('midgard',
|
|
||||||
{
|
|
||||||
landscapeNoise = land1,
|
|
||||||
tempNoise = climat2,
|
|
||||||
humidityNoise = climat2,
|
|
||||||
},{
|
|
||||||
v(500, 0, 500),
|
|
||||||
v(-500, 0, -500),
|
|
||||||
v(-500, 0, 500),
|
|
||||||
v(500, 0, -500),
|
|
||||||
})
|
|
||||||
|
|
||||||
mapGenerator:register2DPeaks('midgard',
|
|
||||||
{
|
|
||||||
landscapeNoise = land2,
|
|
||||||
tempNoise = climat1,
|
|
||||||
humidityNoise = climat1,
|
|
||||||
},{
|
|
||||||
v(-300, 0, 300),
|
|
||||||
v(200, 0, -400),
|
|
||||||
})
|
|
||||||
|
|
||||||
mapGenerator:register2DPeaks('midgard',
|
|
||||||
{
|
|
||||||
landscapeNoise = land2,
|
|
||||||
tempNoise = climat2,
|
|
||||||
humidityNoise = climat2,
|
|
||||||
},{
|
|
||||||
v(200, 0, 100),
|
|
||||||
v(-300, 0, -200),
|
|
||||||
})--]]
|
|
||||||
|
|
||||||
for _, c in ipairs({'landscape', 'temp', 'humidity'}) do
|
for _, c in ipairs({'landscape', 'temp', 'humidity'}) do
|
||||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#4978c6', land1)
|
mapGenerator:registerLayerNoiseColor('midgard', c, '#4978c6', ocean[c])
|
||||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#77ea72', land2)
|
mapGenerator:registerLayerNoiseColor('midgard', c, '#81c948', common_lands[c])
|
||||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#46B331', land3)
|
mapGenerator:registerLayerNoiseColor('midgard', c, '#187726', foresty_lands[c])
|
||||||
--[[
|
mapGenerator:registerLayerNoiseColor('midgard', c, '#357a60', hilly_lands[c])
|
||||||
mapGenerator:register2DPeaks('midgard', c, {
|
mapGenerator:registerLayerNoiseColor('midgard', c, '#5a7269', low_mountains[c])
|
||||||
{
|
mapGenerator:registerLayerNoiseColor('midgard', c, '#773b18', high_mountains[c])
|
||||||
color = '#77ea72',
|
mapGenerator:registerLayerNoiseColor('midgard', c, '#a3a3a3', highest_peaks[c])
|
||||||
pos = vector.new(512, 0, 512)
|
mapGenerator:registerLayerNoiseColor('midgard', c, '#182077', rivers[c])
|
||||||
},
|
mapGenerator:registerLayerNoiseColor('midgard', c, '#06f5ff', lakes[c])
|
||||||
{
|
mapGenerator:registerLayerNoiseColor('midgard', c, '#677a48', rocky_shores[c])
|
||||||
color = '#4978c6',
|
mapGenerator:registerLayerNoiseColor('midgard', c, '#e4dc36', rocky_islands[c])
|
||||||
pos = vector.new(512, 0, -512)
|
mapGenerator:registerLayerNoiseColor('midgard', c, '#3b7718', swamp_land[c])
|
||||||
},
|
|
||||||
{
|
|
||||||
color = '#77ea72',
|
|
||||||
pos = vector.new(-512, 0, -512)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
color = '#4978c6',
|
|
||||||
pos = vector.new(-512, 0, 512)
|
|
||||||
},
|
|
||||||
})--]]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 32,{x=0, y=0}, 'landscape')
|
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 32,{x=0, y=0}, 'landscape')
|
||||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 150,{x=0, y=0}, 'temp')
|
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 32,{x=0, y=0}, 'temp')
|
||||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 200,{x=0, y=0}, 'humidity')
|
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 32,{x=0, y=0}, 'humidity')
|
||||||
|
|
||||||
--[[
|
-- [[
|
||||||
mapGenerator:registerCavern('midgard', 'cavern1', {
|
mapGenerator:registerCavern('midgard', 'cavern1', {
|
||||||
minY = -48,
|
minY = -48,
|
||||||
maxY = 50,
|
maxY = 100,
|
||||||
smoothDistance = 20,
|
smoothDistance = 20,
|
||||||
threshold = 0.2,
|
threshold = 0.1,
|
||||||
noiseParams ={
|
noiseParams ={
|
||||||
offset = 0,
|
offset = 0.2,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
spread = {x = 10, y = 250, z = 30},
|
spread = {x = 10, y = 250, z = 30},
|
||||||
seed = 5934,
|
seed = 5934,
|
||||||
@@ -188,6 +451,12 @@ mapGenerator:registerCavern('midgard', 'cavern1', {
|
|||||||
persistence = 0.4,
|
persistence = 0.4,
|
||||||
lacunarity = 2.0
|
lacunarity = 2.0
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{x=100, y=0, z=100},
|
||||||
|
{x=100, y=0, z=200},
|
||||||
|
{x=200, y=0, z=200},
|
||||||
|
{x=200, y=0, z=100},
|
||||||
})--]]
|
})--]]
|
||||||
|
|
||||||
-- --- Biomes ---
|
-- --- Biomes ---
|
||||||
@@ -213,8 +482,8 @@ local function generateRock(biome, mapGenerator, data, index, x, y, z)
|
|||||||
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
||||||
end
|
end
|
||||||
|
|
||||||
local noiseRocksValue = mathRound(rocksNoise:get_3d({x = x, y = y, z = z}))
|
local noiseRocksValue = (rocksNoise:get_3d({x = x, y = y, z = z}))
|
||||||
if noiseRocksValue == 1 then
|
--[[if noiseRocksValue == 1 then
|
||||||
data[index] = ids.malachite
|
data[index] = ids.malachite
|
||||||
elseif noiseRocksValue == 2 then
|
elseif noiseRocksValue == 2 then
|
||||||
data[index] = ids.hapcoryte
|
data[index] = ids.hapcoryte
|
||||||
@@ -230,6 +499,13 @@ local function generateRock(biome, mapGenerator, data, index, x, y, z)
|
|||||||
data[index] = ids.burcite
|
data[index] = ids.burcite
|
||||||
elseif noiseRocksValue == 8 then
|
elseif noiseRocksValue == 8 then
|
||||||
data[index] = ids.felhor
|
data[index] = ids.felhor
|
||||||
|
end--]]
|
||||||
|
if noiseRocksValue > 5 then
|
||||||
|
data[index] = ids.syliteBlack
|
||||||
|
elseif noiseRocksValue > 4.5 then
|
||||||
|
data[index] = ids.syliteGray
|
||||||
|
else
|
||||||
|
data[index] = ids.sylite
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -240,9 +516,13 @@ local function generateSoil(biome, mapGenerator, data, index, x, y, z)
|
|||||||
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
||||||
end
|
end
|
||||||
|
|
||||||
local noiseRocksValue = mathRound(rocksNoise:get_3d({x = x, y = y, z = z}))
|
local noiseRocksValue = (rocksNoise:get_3d({x = x, y = y, z = z}))
|
||||||
|
|
||||||
if noiseRocksValue > 4 then
|
if noiseRocksValue > 5 then
|
||||||
|
data[index] = ids.syliteBlack
|
||||||
|
elseif noiseRocksValue > 4.5 then
|
||||||
|
data[index] = ids.syliteGray
|
||||||
|
elseif noiseRocksValue > 4 then
|
||||||
data[index] = ids.sylite
|
data[index] = ids.sylite
|
||||||
else
|
else
|
||||||
data[index] = biome.groundNodesIDs.soil
|
data[index] = biome.groundNodesIDs.soil
|
||||||
@@ -256,9 +536,13 @@ local function generateTurf(biome, mapGenerator, data, index, x, y, z)
|
|||||||
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
||||||
end
|
end
|
||||||
|
|
||||||
local noiseRocksValue = mathRound(rocksNoise:get_3d({x = x, y = y, z = z}))
|
local noiseRocksValue = (rocksNoise:get_3d({x = x, y = y, z = z}))
|
||||||
|
|
||||||
if noiseRocksValue > 4 then
|
if noiseRocksValue > 5 then
|
||||||
|
data[index] = ids.syliteBlack
|
||||||
|
elseif noiseRocksValue > 4.5 then
|
||||||
|
data[index] = ids.syliteGray
|
||||||
|
elseif noiseRocksValue > 4 then
|
||||||
data[index] = ids.sylite
|
data[index] = ids.sylite
|
||||||
else
|
else
|
||||||
data[index] = biome.groundNodesIDs.turf
|
data[index] = biome.groundNodesIDs.turf
|
||||||
|
|||||||
Binary file not shown.
@@ -66,10 +66,10 @@ liquidFactory:registerItems({
|
|||||||
settings = {
|
settings = {
|
||||||
name = "liquids:water_flowing",
|
name = "liquids:water_flowing",
|
||||||
drawtype = "flowingliquid",
|
drawtype = "flowingliquid",
|
||||||
tiles = {"default_water.png"},
|
tiles = {"liquids_water.png"},
|
||||||
special_tiles = {
|
special_tiles = {
|
||||||
{
|
{
|
||||||
name = "default_water_flowing_animated.png",
|
name = "liquids_water_flowing.png",
|
||||||
backface_culling = false,
|
backface_culling = false,
|
||||||
animation = {
|
animation = {
|
||||||
type = "vertical_frames",
|
type = "vertical_frames",
|
||||||
@@ -79,7 +79,7 @@ liquidFactory:registerItems({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "default_water_flowing_animated.png",
|
name = "liquids_water_flowing.png",
|
||||||
backface_culling = true,
|
backface_culling = true,
|
||||||
animation = {
|
animation = {
|
||||||
type = "vertical_frames",
|
type = "vertical_frames",
|
||||||
|
|||||||
BIN
mods/GAME/ITEMS/liquids/textures/liquids_water_flowing.png
Normal file
BIN
mods/GAME/ITEMS/liquids/textures/liquids_water_flowing.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
@@ -24,16 +24,30 @@ local rockFactory = defaultRock:getFactory()
|
|||||||
---@type TileSheet
|
---@type TileSheet
|
||||||
local ts = TileSheet:new("rocks_sheet.png", 16, 16)
|
local ts = TileSheet:new("rocks_sheet.png", 16, 16)
|
||||||
|
|
||||||
rockFactory:registerNodesByShortDef({
|
local function registerRocksTypes(postfix, x)
|
||||||
{"sylite", {ts:t(0, 0)}},
|
rockFactory:registerNodesByShortDef({
|
||||||
{"tauitite", {ts:t(0, 2)}},
|
{"sylite"..postfix, {ts:t(x, 0)}},
|
||||||
{"iyellite", {ts:t(0, 4)}},
|
{"sylite_gray"..postfix, {ts:t(x, 1)}},
|
||||||
{"falmyte", {ts:t(0, 6)}},
|
{"sylite_black"..postfix, {ts:t(x, 2)}},
|
||||||
{"hapcoryte", {ts:t(0, 8)}},
|
{"tauitite_light"..postfix, {ts:t(x, 3)}},
|
||||||
{"burcite", {ts:t(0, 10)}},
|
{"tauitite_pink"..postfix, {ts:t(x, 4)}},
|
||||||
{"felhor", {ts:t(0, 12)}},
|
{"tauitite"..postfix, {ts:t(x, 5)}},
|
||||||
{"malachite", {ts:t(0, 14)}}
|
{"falmyte_light"..postfix, {ts:t(x, 6)}},
|
||||||
})
|
{"falmyte_yellow"..postfix, {ts:t(x, 7)}},
|
||||||
|
{"falmyte_red"..postfix, {ts:t(x, 8)}},
|
||||||
|
{"falmyte_dark"..postfix, {ts:t(x, 9)}},
|
||||||
|
{"iyellite"..postfix, {ts:t(x, 14)}},
|
||||||
|
{"falmyte"..postfix, {ts:t(x, 14)}},
|
||||||
|
{"hapcoryte"..postfix, {ts:t(x, 14)}},
|
||||||
|
{"burcite"..postfix, {ts:t(x, 14)}},
|
||||||
|
{"felhor"..postfix, {ts:t(x, 14)}},
|
||||||
|
{"malachite"..postfix, {ts:t(x, 14)}}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
registerRocksTypes('', 0)
|
||||||
|
registerRocksTypes('_block', 2)
|
||||||
|
registerRocksTypes('_bricks', 5)
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
rockFactory:registerItems({
|
rockFactory:registerItems({
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
Submodule util/ide-helper updated: 52c171aced...3eb0f97115
Reference in New Issue
Block a user