diff options
| author | orwell96 <mono96.mml@gmail.com> | 2017-01-12 17:33:43 +0100 |
|---|---|---|
| committer | orwell96 <mono96.mml@gmail.com> | 2017-01-12 17:33:43 +0100 |
| commit | dc8b47a066ff8b3251ad09d4b490647e3f057d10 (patch) | |
| tree | b0953a17adf450e8bff02395f71538472f85e393 /advtrains/advtrains/atc.lua | |
| parent | 04d14dc1bf4d7527635652e48493114254750dd3 (diff) | |
Unite all save data (except the track database) into a single save file
Diffstat (limited to 'advtrains/advtrains/atc.lua')
| -rw-r--r-- | advtrains/advtrains/atc.lua | 33 |
1 files changed, 4 insertions, 29 deletions
diff --git a/advtrains/advtrains/atc.lua b/advtrains/advtrains/atc.lua index bd02425..e015d47 100644 --- a/advtrains/advtrains/atc.lua +++ b/advtrains/advtrains/atc.lua @@ -2,37 +2,10 @@ --registers and controls the ATC system local atc={} --- ATC persistence table -atc.controllers = {} +-- ATC persistence table. advtrains.atc is created by init.lua when it loads the save file. +atc.controllers = advtrains.atc.controllers --contents: {command="...", arrowconn=0-15 where arrow points} -advtrains.fpath_atc=minetest.get_worldpath().."/advtrains_atc" -local file, err = io.open(advtrains.fpath_atc, "r") -if not file then - local er=err or "Unknown Error" - atprint("Failed loading advtrains atc save file "..er) -else - local tbl = minetest.deserialize(file:read("*a")) - if type(tbl) == "table" then - atc.controllers=tbl.controllers - end - file:close() -end -function atc.save() - --leave space for more save data. - local datastr = minetest.serialize({controllers = atc.controllers}) - if not datastr then - minetest.log("error", " Failed to serialize trackdb data!") - return - end - local file, err = io.open(advtrains.fpath_atc, "w") - if err then - return err - end - file:write(datastr) - file:close() -end - --call from advtrains.detector subprogram function atc.trigger_controller_train_enter(pos, train_id) @@ -290,5 +263,7 @@ function atc.execute_atc_command(id, train) atc.train_reset_command(id) end + + --move table to desired place advtrains.atc=atc |
