This commit is contained in:
MihailRis
2024-04-25 03:00:21 +03:00
parent 56a8226028
commit 8730b03a52
5 changed files with 19 additions and 7 deletions
+1 -1
View File
@@ -12,5 +12,5 @@ function on_open()
name=settings.generator_name(k)
}))
end
panel:add("<button padding='10' onclick='menu:back()'>@Back</button>")
panel:add("<button onclick='menu:back()'>@Back</button>")
end
+1 -1
View File
@@ -7,7 +7,7 @@
</textbox>
<label>@Seed</label>
<textbox id='seed_box' placeholder='-' padding='4'></textbox>
<button onclick='menu.page="generators"' id='generator_btn'>
<button onclick='save_state() menu.page="generators"' id='generator_btn'>
@World generator
</button>
<button onclick='create_world()' margin='1,20,1,1'>
+10 -1
View File
@@ -4,6 +4,11 @@ function world_name_validator(name)
return name:match("^[%w-\\.\\ ]+$") ~= nil and not world.exists(name)
end
function save_state()
settings.name = document.name_box.text
settings.seed = document.seed_box.text
end
function settings.generator_name(id)
local prefix, name = parse_path(id)
if prefix == "core" then
@@ -19,7 +24,9 @@ function create_world()
end
local name = document.name_box.text
local seed = document.seed_box.text
core.new_world(name, seed, settings.generator)
local generator = settings.generator
session.reset_entry('new_world')
core.new_world(name, seed, generator)
end
function on_open()
@@ -31,5 +38,7 @@ function on_open()
gui.str("World generator", "world"),
settings.generator_name(settings.generator)
)
document.name_box.text = settings.name or ''
document.seed_box.text = settings.seed or ''
document.seed_box.placeholder = tostring(math.random()):sub(3)
end