-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathparsetext.lua
33 lines (29 loc) · 1.09 KB
/
parsetext.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
-- Modify the parameters in parameter.lua!
----------------------------
-- Text Parser for BLOCKS --
----------------------------
-- Minetest library
function string:split(sep)local sep,fields=sep or ",",{} local pattern=string.format("([^%s]+)", sep) self:gsub(pattern,function(c)fields[#fields+1]=c end) return fields end
function file_exists(filename)local f=io.open(filename, "r") if f==nil then return false else f:close() return true end end
function sflat.parsetext(text)
if text:split(";")[2] ~= nil then
local options = text:split(";")[2]:split(",")
if options[1] ~= nil or options[1] ~= "" then
sflat.options.biome = options[1]
if options[2] == "decoration" then
sflat.options.decoration = true
end
end
end
local text, layers = text:split(";")[1]:split(","), {}
local y = sflat.Y_ORIGIN
for a = 1, #text do
local node, amount = string.match(text[a], "^([a-zA-Z0-9_:]+)=?([0-9]*)$")
if node ~= nil and amount ~= nil then
if amount == "" then amount = 1 end
y = y + amount
layers[#layers + 1] = {node, sflat.get_content_id(node), y}
end
end
return layers
end