Merge pull request #565 from andreyplus/new-world-placeholder

Add auto-increment placeholder for the new worlds
This commit is contained in:
MihailRis 2025-07-23 12:20:33 +03:00 committed by GitHub
commit a2b89e635f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 5 deletions

View File

@ -2,7 +2,7 @@
<label>@Name</label>
<textbox id='name_box'
validator='world_name_validator'
placeholder='New World'
placeholder='-'
padding='4'>
</textbox>
<label>@Seed</label>

View File

@ -24,6 +24,16 @@ function create_world()
core.new_world(name, seed, generator)
end
function world_name_placeholder()
local name = "New World"
local number = 0
while world.exists(name) do
number = number + 1
name = "New World " .. tostring(number)
end
return name
end
function on_open()
document.content_btn.text = string.format(
"%s [%s]", gui.str("Content", "menu"), #pack.get_installed()
@ -38,6 +48,7 @@ function on_open()
settings.generator_name(generation.get_generators()[settings.generator])
)
document.name_box.text = settings.name or ''
document.name_box.placeholder = world_name_placeholder()
document.seed_box.text = settings.seed or ''
document.seed_box.placeholder = tostring(math.random()):sub(3)
end