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

do not destroy objects when not able to equip them

git-svn-id: http://svn.net-core.org/repos/t-engine4@588 51575b47-30f0-44d4-a5cc-537603b46e54
parent fb3d65aa
No related branches found
No related tags found
No related merge requests found
......@@ -281,7 +281,7 @@ function _M:wearObject(o, replace, vocal)
if vocal then game.logSeen(self, "%s wears: %s.", self.name:capitalize(), o:getName{do_color=true}) end
-- Warning: assume there is now space
self:addObject(self:getInven(o.offslot), o)
return false
return true
elseif replace then
local ro = self:removeObject(inven, 1, true)
......
......@@ -83,6 +83,24 @@ function _M:runInit(dir)
self:runStep()
end
--- Initializes running to a specific position
-- This does not use the normal running algorithm but instead an A*
function _M:runTo(x, y)
local block_left, block_right = false, false
self.running = {
to = {x=x, y=y},
block_left = block_left,
block_right = block_right,
cnt = 1,
dialog = Dialog:simplePopup("Running...", "You are running, press any key to stop.", function()
self:runStop()
end),
}
self:runStep()
end
--- Run a turn
-- For a turn based game you want in you player's act() something like that:<br/>
-- <pre>
......
......@@ -138,6 +138,7 @@ function _M:loaded()
end
function _M:onResolutionChange()
engine.Game.onResolutionChange(self)
print("[RESOLUTION] changed to ", self.w, self.h)
self:setupDisplayMode()
self.flash:resize(0, 0, self.w, 20)
......@@ -659,9 +660,15 @@ function _M:setupMouse()
if button == "right" then
local tmx, tmy = self.level.map:getMouseTile(mx, my)
-- DEBUG
if config.settings.tome.cheat then
game.player:move(tmx, tmy, true)
end
-- if config.settings.tome.cheat then
-- game.player:move(tmx, tmy, true)
-- else
local Astar = require"engine.Astar"
local a = Astar.new(self.level.map, self.player)
local path = a:CalcPath(a:CalcMoves(self.player.x, self.player.y, tmx, tmy))
print("A* from", self.player.x, self.player.y, "to", tmx, tmy)
for i, c in ipairs(path) do print("A*", c.x, c.y) end
-- end
-- Move map around
elseif button == "left" and xrel and yrel then
derivx = derivx + xrel
......
......@@ -319,7 +319,7 @@ function _M:doWear(inven, item, o)
local ro = self:wearObject(o, true, true)
if ro then
if type(ro) == "table" then self:addObject(inven, ro) end
elseif ro then
elseif not ro then
self:addObject(inven, o)
end
self:sortInven()
......
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