Hrm, that's intersting. Have you tried doing anything else in the condition? I'm wondering if it's your GetPlayerXY() rather than your actual KillMap() function. Maybe try printing or doing something that you know to work in that condition? At least then you would know for sure that it's an issue with KillMap().
I hypothesize that his GetPlayerXY() is not returning what he thinks. Perhaps its returning by pixel, while you are checking by tile. Perhaps its returning by pixel/tile onscreen?
--main.lua
function Main()
dofile("scripts/globals.lua")
dofile("scripts/menu.lua")
dofile("scripts/movement.lua")
dofile("scripts/events.lua")
dofile("scripts/functions.lua")
dofile("scripts/text.lua")
dofile("scripts/input.lua")
if ytile == 1 then
KillMap()
end
Input()
Events()
Text()
end
--main.lua
function Main()
dofile("scripts/globals.lua")
dofile("scripts/menu.lua")
dofile("scripts/movement.lua")
dofile("scripts/events.lua")
dofile("scripts/functions.lua")
dofile("scripts/text.lua")
dofile("scripts/input.lua")
if ytile > 1 then
KillMap()
end
Input()
Events()
Text()
end
This time it didn't work.
It's like it just checks the if-statement only once...
Wow, I really don't see anything. You are updating/calling GetPlayerXY() every frame, right? I don't see it in your main, but I'm assuming that it's happening in one of the dofile()s?
GyroVorbis wrote:You are updating/calling GetPlayerXY() every frame, right? I don't see it in your main, but I'm assuming that it's happening in one of the dofile()s?
Yeah, I update GetPlayerXY() every frame, I got another lua script for that which I include in the lua main function.
GyroVorbis wrote:Wow, I really don't see anything. You are updating/calling GetPlayerXY() every frame, right? I don't see it in your main, but I'm assuming that it's happening in one of the dofile()s?
trufun, do you see anything?
I'm wondering if it's bombing out when its executing all of the other scripts, and it never gets to the ytile > 1 condition.
My suggestion would be to write some debug messages to a file, so you can see how far its getting. You'll have a huge file if its being called every frame, but it will let you know what's going on.
--main.lua
file = io.open("debug.txt", "w")
function Debug(string)
file:write(string .. "\n-----\n")
end
function Main()
Debug("before includes")
dofile("scripts/globals.lua")
dofile("scripts/menu.lua")
dofile("scripts/movement.lua")
dofile("scripts/events.lua")
dofile("scripts/functions.lua")
dofile("scripts/text.lua")
dofile("scripts/input.lua")
Debug("after includes")
if y > 2 then
Debug("before KillMap() y: " .. y) -- i changed ytile to y and xtile to x
KillMap()
Debug("after KillMap() x: " .. x)
end
Input()
Events()
Text()
end
before includes
-----
after includes
-----
before includes
-----
after includes
-----
before includes
-----
after includes
-----
before includes
-----
after includes
-----
before includes
-----
after includes
-----
before includes
-----
after includes
-----
before includes
-----
after includes
-----
before KillMap() y: 3
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 3
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 3
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 3
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 3
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 4
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 4
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 4
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 4
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 5
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 5
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 5
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 5
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 6
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 6
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 7
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 7
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 7
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 7
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 7
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 8
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 8
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 8
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 8
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 9
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 9
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 9
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 9
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 9
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 9
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 9
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 9
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 9
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 9
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 9
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 9
-----
after KillMap() x: 1
-----
before includes
-----
after includes
-----
before KillMap() y: 9
-----
after KillMap() x: 1
-----
Okay... add a printf/cout/WriteToLog() to your C/++ KillMap() function just to make sure it's being called correctly. Also, post your KillMap() function (C/++ source (Map::close()) and wrapper).
edit: You can also try doing it in your C++ heartbeat like: