made the check for archetype better, fixed reposition into restart game

This commit is contained in:
lustlion 2022-03-10 18:37:19 +01:00
parent dbfae2f74e
commit 6dd970c1d4
2 changed files with 11 additions and 4 deletions

View File

@ -44,6 +44,7 @@ function stepGame()
end
if Keybind:checkPressed(Keybind.debug.reposition) then
restartGame()
end
if Keybind:checkPressed(Keybind.debug.reload) then

View File

@ -72,13 +72,19 @@ function promptSpawnArchetype()
input = spawn.archetype.type,
spawn = spawn,
func = function(prompt)
local arch = spawn.archetype
print("return "..prompt.input)
local f = loadstring("return "..prompt.input)
if f == nil then
if f ~= nil then
local succ, arch = pcall(f)
print(succ, arch)
if not succ
or type(arch) ~= "table"
or type(arch.type) ~= "string"
then
arch = spawn.archetype
end
print(succ, arch)
spawn.archetype = arch
else
spawn.archetype = f()
end
end,
})