diff options
-rw-r--r-- | controller.lua | 6 | ||||
-rw-r--r-- | dispatcher.lua | 6 | ||||
-rw-r--r-- | doors.lua | 14 | ||||
-rw-r--r-- | drive_entity.lua | 4 | ||||
-rw-r--r-- | drive_null.lua | 4 | ||||
-rw-r--r-- | textures/celevator_door_glass_inventory.png | bin | 573 -> 244 bytes |
6 files changed, 34 insertions, 0 deletions
diff --git a/controller.lua b/controller.lua index 0a43eff..2921f81 100644 --- a/controller.lua +++ b/controller.lua @@ -645,7 +645,9 @@ end function celevator.controller.checkiqueue(dtime) for hash,iqueue in pairs(celevator.controller.iqueue) do local pos = minetest.get_position_from_hash(hash) + local noneleft = true for iid,time in pairs(iqueue) do + noneleft = false iqueue[iid] = time-dtime if iqueue[iid] < 0 then iqueue[iid] = nil @@ -655,6 +657,10 @@ function celevator.controller.checkiqueue(dtime) celevator.controller.run(pos,event) end end + if noneleft then + celevator.controller.iqueue[hash] = nil + celevator.storage:set_string("controller_iqueue",minetest.serialize(celevator.controller.iqueue)) + end end end diff --git a/dispatcher.lua b/dispatcher.lua index a8bcf1c..02533ff 100644 --- a/dispatcher.lua +++ b/dispatcher.lua @@ -422,7 +422,9 @@ end function celevator.dispatcher.checkiqueue(dtime) for hash,iqueue in pairs(celevator.dispatcher.iqueue) do local pos = minetest.get_position_from_hash(hash) + local noneleft = true for iid,time in pairs(iqueue) do + noneleft = false iqueue[iid] = time-dtime if iqueue[iid] < 0 then iqueue[iid] = nil @@ -432,6 +434,10 @@ function celevator.dispatcher.checkiqueue(dtime) celevator.dispatcher.run(pos,event) end end + if noneleft then + celevator.dispatcher.iqueue[hash] = nil + celevator.storage:set_string("dispatcher_iqueue",minetest.serialize(celevator.dispatcher.iqueue)) + end end end @@ -2,6 +2,12 @@ celevator.doors = {} celevator.doors.erefs = {} +--These get overwritten on globalstep and aren't settings. +--They're just set to true here so the globalstep functions run at least once, +--in case a door was moving when the server last shut down. +celevator.doors.hwdoor_step_enabled = true +celevator.doors.cardoor_step_enabled = true + local function placesill(pos,node) local erefs = minetest.get_objects_inside_radius(pos,0.5) for _,ref in pairs(erefs) do @@ -412,6 +418,7 @@ minetest.register_entity("celevator:hwdoor_moving",{ }) function celevator.doors.hwopen(pos,drivepos) + celevator.doors.hwdoor_step_enabled = true local hwdoors_moving = minetest.deserialize(celevator.storage:get_string("hwdoors_moving")) or {} local hash = minetest.hash_node_position(pos) if not hwdoors_moving[hash] then @@ -475,6 +482,7 @@ function celevator.doors.hwopen(pos,drivepos) end function celevator.doors.hwclose(pos,drivepos,nudge) + celevator.doors.hwdoor_step_enabled = true local hwdoors_moving = minetest.deserialize(celevator.storage:get_string("hwdoors_moving")) or {} local hash = minetest.hash_node_position(pos) if hwdoors_moving[hash] then @@ -513,6 +521,7 @@ function celevator.doors.hwclose(pos,drivepos,nudge) end function celevator.doors.hwstep(dtime) + if not celevator.doors.hwdoor_step_enabled then return end local hwdoors_moving = minetest.deserialize(celevator.storage:get_string("hwdoors_moving")) or {} local save = false for hash,data in pairs(hwdoors_moving) do @@ -587,11 +596,13 @@ function celevator.doors.hwstep(dtime) if save then celevator.storage:set_string("hwdoors_moving",minetest.serialize(hwdoors_moving)) end + celevator.doors.hwdoor_step_enabled = save end minetest.register_globalstep(celevator.doors.hwstep) function celevator.doors.carstep(dtime) + if not celevator.doors.cardoor_step_enabled then return end local cardoors_moving = minetest.deserialize(celevator.storage:get_string("cardoors_moving")) or {} local save = false for hash,data in pairs(cardoors_moving) do @@ -663,6 +674,7 @@ function celevator.doors.carstep(dtime) if save then celevator.storage:set_string("cardoors_moving",minetest.serialize(cardoors_moving)) end + celevator.doors.cardoor_step_enabled = save end minetest.register_globalstep(celevator.doors.carstep) @@ -708,6 +720,7 @@ function celevator.doors.spawncardoors(pos,dir,doortype,replace) end function celevator.doors.caropen(pos) + celevator.doors.cardoor_step_enabled = true local cardoors_moving = minetest.deserialize(celevator.storage:get_string("cardoors_moving")) or {} local hash = minetest.hash_node_position(pos) local cartimer = minetest.get_node_timer(pos) @@ -770,6 +783,7 @@ function celevator.doors.caropen(pos) end function celevator.doors.carclose(pos,nudge) + celevator.doors.cardoor_step_enabled = true local cardoors_moving = minetest.deserialize(celevator.storage:get_string("cardoors_moving")) or {} local hash = minetest.hash_node_position(pos) if cardoors_moving[hash] then diff --git a/drive_entity.lua b/drive_entity.lua index 0ddd4c4..532b919 100644 --- a/drive_entity.lua +++ b/drive_entity.lua @@ -9,6 +9,7 @@ celevator.drives.entity = { carsoundstate = {}, entityinfo = {}, sheaverefs = {}, + step_enabled = true, --Not a setting, is overwritten on globalstep, true here to check for running drives on startup } local playerposlimits = {} @@ -459,6 +460,7 @@ function celevator.drives.entity.entitiestonodes(refs,carid) end function celevator.drives.entity.step(dtime) + if not celevator.drives.entity.step_enabled then return end local entitydrives_running = minetest.deserialize(celevator.storage:get_string("entitydrives_running")) or {} local save = false for i,hash in ipairs(entitydrives_running) do @@ -644,6 +646,7 @@ function celevator.drives.entity.step(dtime) if save then celevator.storage:set_string("entitydrives_running",minetest.serialize(entitydrives_running)) end + celevator.drives.entity.step_enabled = save end minetest.register_globalstep(celevator.drives.entity.step) @@ -704,6 +707,7 @@ function celevator.drives.entity.moveto(pos,target,inspection) end end if not running then + celevator.drives.entity.step_enabled = true table.insert(entitydrives_running,hash) celevator.storage:set_string("entitydrives_running",minetest.serialize(entitydrives_running)) --Controller needs to see something so it knows the drive is running diff --git a/drive_null.lua b/drive_null.lua index 1a22e22..2664d47 100644 --- a/drive_null.lua +++ b/drive_null.lua @@ -3,6 +3,7 @@ celevator.drives.null = { description = "Simulation only, no movement, for testing and demonstration", nname = "celevator:drive_null", soundhandles = {}, + step_enabled = true, --Not a setting, is overwritten on globalstep, true here to check for running drives on startup } local function update_ui(pos) @@ -90,6 +91,7 @@ minetest.register_node("celevator:drive_null",{ }) function celevator.drives.null.step(dtime) + if not celevator.drives.null.step_enabled then return end local nulldrives_running = minetest.deserialize(celevator.storage:get_string("nulldrives_running")) or {} local save = false for i,hash in ipairs(nulldrives_running) do @@ -146,6 +148,7 @@ function celevator.drives.null.step(dtime) if save then celevator.storage:set_string("nulldrives_running",minetest.serialize(nulldrives_running)) end + celevator.drives.null.step_enabled = save end minetest.register_globalstep(celevator.drives.null.step) @@ -163,6 +166,7 @@ function celevator.drives.null.moveto(pos,target) end end if not running then + celevator.drives.null.step_enabled = true table.insert(nulldrives_running,hash) celevator.storage:set_string("nulldrives_running",minetest.serialize(nulldrives_running)) end diff --git a/textures/celevator_door_glass_inventory.png b/textures/celevator_door_glass_inventory.png Binary files differindex 4ebf6f9..2538465 100644 --- a/textures/celevator_door_glass_inventory.png +++ b/textures/celevator_door_glass_inventory.png |