[FIXED]LUA looping error
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
[FIXED]LUA looping error
Here's an unlikely scenario for regular users, but we probably should fix it for Devs.
I dropped a breakpoint in my new Interrupt() LUA function and was stepping through the code to see what was wrong. My client disconnected of course, but World started to flip out behind me. Even after my character completely lost connection.
I dropped a breakpoint in my new Interrupt() LUA function and was stepping through the code to see what was wrong. My client disconnected of course, but World started to flip out behind me. Even after my character completely lost connection.
You do not have the required permissions to view the files attached to this post.
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
Re: LUA looping error
Ahh, this is not about my breakpoint... i think it's the script I'm trying. Edited, it looks like this:
Edit: And, once again comes down to user error because I have no idea how anything works anymore :p I put this script on my foe, and there are 50 of them spawned in the area and none of them were mad at me at the time 
Maybe this exposed a bug in the Brain? Not that anyone would ever use the Brain int his manner but us.
Code: Select all
function spawn(NPC)
SetLuaBrain(NPC)
SetBrainTick(NPC, 500)
end
function respawn(NPC)
spawn(NPC)
end
function Think(NPC)
if GetTarget(NPC) ~= nil then
CastSpell(GetTarget(NPC), 30000, 4, NPC)
end
endMaybe this exposed a bug in the Brain? Not that anyone would ever use the Brain int his manner but us.
-
Jabantiz
- Lead Developer
- Posts: 2912
- Joined: Wed Jul 25, 2007 2:52 pm
- Location: California
Re: LUA looping error
The "if GetTarget(NPC) ~= nil then" should probably be in another if to check to see in the npc is in combat. However that if should prevent CastSpell from being called with no target.
Out of curiosity could you try the following when you get a chance
Out of curiosity could you try the following when you get a chance
Code: Select all
function Think(NPC)
target = GetTarget(NPC)
if target ~= nil then
CastSpell(target, 30000, 4, NPC)
end
end
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
Re: LUA looping error
Same thing, Jab.
-
Jabantiz
- Lead Developer
- Posts: 2912
- Joined: Wed Jul 25, 2007 2:52 pm
- Location: California
Re: LUA looping error
Odd, have to ask but are you sure on the spell id? No clue why the target it is getting past the if but failing in the CastSpell function... will have to look into this tomorrow if I can get enough free time.
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
Re: LUA looping error
Yup, definitely 30,000. It is the first spell of a Guardian (class_id * 10,000). Tier 4 info is in place all the way down the line. I can cast the same spell on the NPC, and when using it as a spawn_npc_spell list, they can cast it on me.
It's also the only spell in my local database, so it's kinda hard even for me to mess that one up
It's also the only spell in my local database, so it's kinda hard even for me to mess that one up
-
Jabantiz
- Lead Developer
- Posts: 2912
- Joined: Wed Jul 25, 2007 2:52 pm
- Location: California
Re: LUA looping error
I figured it was right just had to ask to make sure as the error says target or spell id. I am going to rewrite the function locally to the style I have been doing my recent functions to provided better error messages to try and pinpoint the problem, do you want me to put the changes on svn as well?
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
Re: LUA looping error
Might as well. Anything to avoid loopy red text in the console. I don't want to scare anyone 
-
Jabantiz
- Lead Developer
- Posts: 2912
- Joined: Wed Jul 25, 2007 2:52 pm
- Location: California
Re: LUA looping error
still get the error message they are just more specific then target or spell id is not valid.
Rewrote it already on my end and this is where the CastSpell lua function is failing
I am at a loss now because if target is null then in the lua script it should never get past this if
even tried putting the target into its own variable and checking that but I get the same results, it gets past the if in the lua but fails in the c++ code...
Rewrote it already on my end and this is where the CastSpell lua function is failing
Code: Select all
if (!target) {
lua_interface->LogError("LUA CastSpell command error: target is not a valid spawn");
return 0;
}Code: Select all
if GetTarget(NPC) ~= nil then-
Jabantiz
- Lead Developer
- Posts: 2912
- Joined: Wed Jul 25, 2007 2:52 pm
- Location: California
Re: LUA looping error
Ok figured it out, was a bug with GetTarget() lua function. I think I would just confuse people explaining the details so I will just say that it was always returning a valid pointer to lua even if the spawn didn't have a target.
Committed the fix for it.
Also want to point out that lua brain we were testing with won't actually do anything as the spawns target gets set in the AI and we are overriding it with that script and never setting a target ourself.
Committed the fix for it.
Also want to point out that lua brain we were testing with won't actually do anything as the spawns target gets set in the AI and we are overriding it with that script and never setting a target ourself.
- thefoof
- Retired
- Posts: 630
- Joined: Wed Nov 07, 2012 7:36 pm
- Location: Florida
Re: LUA looping error
Ah that's interesting, didn't know the brain was on that deep of a levelJabantiz wrote:Also want to point out that lua brain we were testing with won't actually do anything as the spawns target gets set in the AI and we are overriding it with that script and never setting a target ourself.
Who is online
Users browsing this forum: No registered users and 0 guests