diff --git a/StartBackend.bat b/StartBackend.bat index 0dd6b81..2086b42 100644 --- a/StartBackend.bat +++ b/StartBackend.bat @@ -1,4 +1,7 @@ @echo off +set savefolder=savedata +if not exist %savefolder% mkdir %savefolder% +set saveloc=%cd%\%savefolder%\ cd "sim" -luajit "main.lua" +luajit "main.lua" %saveloc% pause \ No newline at end of file diff --git a/sim/main.lua b/sim/main.lua index 5dd6d86..69b21d2 100644 --- a/sim/main.lua +++ b/sim/main.lua @@ -1,9 +1,15 @@ + +OPT_SAVE_DIR = arg[1] or error("must specify save location") +OPT_SAVE_DIR = OPT_SAVE_DIR:gsub("\\$", "").."\\" +print("Save location set to \""..OPT_SAVE_DIR.."\"") + dofile("simulation.lua") dofile("group.lua") dofile("wire.lua") dofile("gatedef.lua") dofile("gate.lua") dofile("port.lua") +dofile("save.lua") OPT_TICK_ENABLED = true OPT_TICK_TIME = 0 @@ -108,6 +114,8 @@ while 1 do local data = {} local i = 1 line = line:gsub(";;", "; ;") + line = line:gsub(";$", "; ") + for str in string.gmatch(line, "([^;]+)") do data[i] = str or "" i = i + 1 @@ -264,6 +272,11 @@ while 1 do sim:queuegateinput(gate, argv) i = i+2+argc + elseif data[i] == "SAVE" then + print("saving all data") + logicsave() + else + print("invalid data "..data[i]) end i = i + 1 diff --git a/sim/utility.lua b/sim/utility.lua index f57ce49..a5f5034 100644 --- a/sim/utility.lua +++ b/sim/utility.lua @@ -65,3 +65,4 @@ function tobitstring(num, len) return bitstring end +