First of all I've created a new thread, because Jumper's thread isn't active since 2009...
Now the exception that I get is as follows
and at line 330 we find:
The thing is that the map that I pass on is correctly formated. See map.txt
[SOLVED] Jumper exception thrown not expected
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[SOLVED] Jumper exception thrown not expected
Last edited by nyenye on Tue Dec 27, 2016 1:32 pm, edited 1 time in total.
Re: Jumper exception thrown not expected
Sorry about repost, but couldn't attach game.love on the same entry, dunno why though.
- Attachments
-
- game.love
- (2.21 MiB) Downloaded 158 times
Re: Jumper exception thrown not expected
math.floor or ceil the input coordinates will fix the problem
outputs the integer (12,12) value of startX, startY instead of the real value (12.5, 12.5 or something like that)
Code: Select all
assert(startNode, ('Invalid location [%d, %d]'):format(startX, startY))
Re: Jumper exception thrown not expected
Doesn't that generates strings every time this functions is called? Because all (assert) function arguments are evaluated before it is called. That's hugely wasteful.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Jumper exception thrown not expected
Yes it does, assert is a really inefficient function since the string is evaluated regardless of being valid or not... I usually use simple checks
Which also lets you specify the start depth of the stack traceback
Code: Select all
if not startNode then
error(('Invalid location [%d, %d]'):format(startX, startY), 1)
end
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Jumper exception thrown not expected
Thanks for the tips, I'll give it a shot. About the performance problem, I thought that Jumper was the standard library for pathfinding in Lua/Love2D. Do you have any other recomendation? Or do you make your own implementation?
Re: Jumper exception thrown not expected
There's no "standard" anything in Lua, because it's a "there are many ways to do this" kind of language. But sure enough, generating strings in asserts will slow things down substantially for no reason. Not only creating an unique string is not a fast operation, but also the result is immediately discarded and becomes garbage thus contributing to runtime overhead, and all of that on top of never needing to do any of it in the first place.
Re: Jumper exception thrown not expected
Thanks for the info. Then do you have any "better" or different implementation for Pathfinding? Or maybe just change the code of the library to do what Positive07 said?raidho36 wrote:There's no "standard" anything in Lua...
Re: [SOLVED] Jumper exception thrown not expected
I don't have anything in my sights, so yes you could just replace wasteful asserts with less intensive checks, or even remove them altogether since they serve no practical function and only exist to assist debugging.
Who is online
Users browsing this forum: No registered users and 0 guests