From 6dd970c1d481fb330e17fca3ccb63fe215d8f12f Mon Sep 17 00:00:00 2001 From: lustlion Date: Thu, 10 Mar 2022 18:37:19 +0100 Subject: [PATCH] made the check for archetype better, fixed reposition into restart game --- code/game.lua | 1 + code/spawn.lua | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/code/game.lua b/code/game.lua index 23c54fe..044bf1f 100644 --- a/code/game.lua +++ b/code/game.lua @@ -44,6 +44,7 @@ function stepGame() end if Keybind:checkPressed(Keybind.debug.reposition) then + restartGame() end if Keybind:checkPressed(Keybind.debug.reload) then diff --git a/code/spawn.lua b/code/spawn.lua index eb42fcf..f6d09b8 100644 --- a/code/spawn.lua +++ b/code/spawn.lua @@ -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, })