Skip to content
Snippets Groups Projects
Commit f73df8c6 authored by dg's avatar dg
Browse files

Pausing the level loop for player input correctly pauses & restarts at the...

Pausing the level loop for player input correctly pauses & restarts at the right position in the actors list


git-svn-id: http://svn.net-core.org/repos/t-engine4@5071 51575b47-30f0-44d4-a5cc-537603b46e54
parent 06df837d
No related branches found
No related tags found
No related merge requests found
......@@ -97,6 +97,19 @@ end
function _M:tickLevel(level)
local i, e
local arr = level.e_array
if level.last_iteration then
i = nil
for ii = 1, #arr do if arr[ii] == level.last_iteration.e then i = ii + 1 break end end
if not i then i = level.last_iteration.i + 1 end
if i > #arr then i = 1 end
level.last_iteration = nil
-- print("=====LEVEL", level.level, level.sublevel_id, "resuming tick loop at ", i, arr[i].name)
end
for i = 1, #arr do
e = arr[i]
if e and e.act and e.energy then
......@@ -109,7 +122,7 @@ function _M:tickLevel(level)
end
end
-- print("<ENERGY", e.name, e.uid, "::", e.energy.value, self.paused, "::", e.player)
-- print("<ENERGY", e.name, e.uid, "::", e.energy.value, self.paused, "::", e.player)
if e.energy.value < self.energy_to_act then
e.energy.value = (e.energy.value or 0) + self.energy_per_tick * (e.energy.mod or 1) * (e.global_speed or 1)
end
......@@ -117,7 +130,13 @@ function _M:tickLevel(level)
e.energy.used = false
e:act(self)
end
-- print(">ENERGY", e.name, e.uid, "::", e.energy.value, self.paused, "::", e.player)
-- print(">ENERGY", e.name, e.uid, "::", e.energy.value, self.paused, "::", e.player)
if self.paused then
level.last_iteration = {i=i, e=e}
-- print("====LEVEL", level.level, level.sublevel_id, "pausing tick loop at ", i, e.name)
break
end
end
end
end
......
......@@ -1447,6 +1447,14 @@ function _M:setupMouse(reset)
-- Handle targeting
if self:targetMouse(button, mx, my, xrel, yrel, event) then return end
-- Cheat kill
if config.settings.cheat and button == "right" and core.key.modState("ctrl") and core.key.modState("shift") and not xrel and not yrel and event == "button" and self.zone and not self.zone.wilderness then
local tmx, tmy = game.level.map:getMouseTile(mx, my)
local target = game.level.map(tmx, tmy, Map.ACTOR)
target:die(game.player)
return
end
-- Handle Use menu
if button == "right" then
if event == "motion" then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment