[FIXED]LUA looping error

Old bugs stored here for reference.
Locked
User avatar
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

Post by John Adams » Fri Aug 02, 2013 9:24 pm

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.
CastSpellError.jpg
You do not have the required permissions to view the files attached to this post.

User avatar
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

Post by John Adams » Fri Aug 02, 2013 9:35 pm

Ahh, this is not about my breakpoint... i think it's the script I'm trying. Edited, it looks like this:

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
    end
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.

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: LUA looping error

Post by Jabantiz » Fri Aug 02, 2013 9:54 pm

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

Code: Select all

function Think(NPC)
    target = GetTarget(NPC)
    if target ~= nil then
        CastSpell(target, 30000, 4, NPC)
    end
end

User avatar
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

Post by John Adams » Fri Aug 02, 2013 10:11 pm

Same thing, Jab.

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: LUA looping error

Post by Jabantiz » Fri Aug 02, 2013 10:24 pm

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.

User avatar
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

Post by John Adams » Fri Aug 02, 2013 11:31 pm

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 :)

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: LUA looping error

Post by Jabantiz » Sat Aug 03, 2013 11:56 am

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?

User avatar
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

Post by John Adams » Sat Aug 03, 2013 1:11 pm

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

Post by Jabantiz » Sat Aug 03, 2013 1:19 pm

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

Code: Select all

if (!target) {
		lua_interface->LogError("LUA CastSpell command error: target is not a valid spawn");
		return 0;
	}
I am at a loss now because if target is null then in the lua script it should never get past this if

Code: Select all

if GetTarget(NPC) ~= nil then
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...

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: LUA looping error

Post by Jabantiz » Sat Aug 03, 2013 2:13 pm

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.

User avatar
thefoof
Retired
Posts: 630
Joined: Wed Nov 07, 2012 7:36 pm
Location: Florida

Re: LUA looping error

Post by thefoof » Sat Aug 03, 2013 2:18 pm

Jabantiz 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.
Ah that's interesting, didn't know the brain was on that deep of a level

Locked

Who is online

Users browsing this forum: No registered users and 0 guests