LUA Functions Request

Discussions on development of both the EQ2Emulator LUA Script Engine and Script specifications

Moderator: Team Members

Post Reply
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:

Post by John Adams » Fri Sep 19, 2008 12:11 am

Another LUA function we might need, unless MovementLoop() allows this;
Watching Courier Dirvel in Graystone yard - he walks to specific coordinates, and when he gets there, he stops, and says/animates/emotes a phrase before moving on to the next spot.
I am assuming the movement loop just sets coords, and is not a line-by-line execution... so I didn't think to insert the Say() commands in between the loop entries. Figured I'd just ask rather than waste time thinking I'm not doing it right.
Thanks

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Fri Sep 19, 2008 5:49 am

Yah you are right, the movement loop doesn't currently allow you to perform any actions when the NPC stops. Would adding a custom function name to call on the end of the function help? That way when a NPC stops, it will call your custom function (in the same file) and do whatever you want.

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:

Post by John Adams » Fri Sep 19, 2008 10:48 am

I was getting pretty tired last night and wasn't feeling creative heh, but let me visually display it, you tell me if this is how movement script works:

Code: Select all

function spawn(NPC)
   x = GetX(NPC)
   y = GetY(NPC)
   z = GetZ(NPC)
   MovementLoopAddLocation(NPC, x + 7 , y, z - 8 , 2, math.random(5, 15))
   say_1(NPC)
   MovementLoopAddLocation(NPC, x - 5 , y, z - 10, 2, math.random(5, 15))
   say_2(NPC)
   MovementLoopAddLocation(NPC, x - 10, y, z + 9 , 2, math.random(5, 15))
   say_3(NPC)
   MovementLoopAddLocation(NPC, x + 5 , y, z + 8 , 2, math.random(5, 15))
   say_4(NPC)
end
function say_1(NPC)
   Say("I am at the first spot!")
end
function say_2(NPC)
   Say("I am at the second spot!")
end
function say_3(NPC)
   Say("I am at the third spot!")
end
function say_4(NPC)
   Say("I am at the fourth spot!")
end
See, I assumed that when the LUA function read the "MovementLoopAddLocation()", it did them all at once and now they were all in memory in some array that were cycled through sequentially. But if that means a Function can be called between them, then that is the solution. And I like it. :)

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Fri Sep 19, 2008 11:09 am

I assumed that when the LUA function read the "MovementLoopAddLocation()", it did them all at once and now they were all in memory in some array that were cycled through sequentially
That is exactly how it works. My change would add an additional argument to MovementLoopAddLocation that would tell it a custom LUA spawn script function to call after it gets to that particular location.

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:

Post by John Adams » Fri Sep 19, 2008 11:21 am

I'll take it!

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Fri Sep 19, 2008 11:44 am

Could you test this when you get a sec? It should work once you get the latest.

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:

Post by John Adams » Fri Sep 19, 2008 11:57 am

Give me a few hours, got a repair guy here fixing the Maytag. :)
Guess he's not so lonely today.

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Fri Sep 19, 2008 12:25 pm

I just tested this and it seems to be doing the same thing that would happen if you just put the Say function in the spawn(). Here's what I'm doing:

Code: Select all

function spawn(NPC)
	MovementLoopAddLocation(NPC, 22.19, -6.86, 183.95, 2, 30, say1(NPC))
	MovementLoopAddLocation(NPC, 30.76, -6.33, 196.28, 2, 30, say2(NPC))
	MovementLoopAddLocation(NPC, 20.70, -6.85, 206.43, 2, 30, say3(NPC))
end
function respawn(NPC)
   spawn(NPC)
end
function say1(NPC)
   Say(NPC, "1")
end
function say2(NPC, Spawn)
   Say(NPC, "2")
end
function say3(NPC, Spawn)
   Say(NPC, "3")
end
When I do a /reload spawnscripts and /repop, the NPC is saying "1", "2", "3", right when she is spawned then starts moving and never says "1", "2", "3" again.
This script is for Gethe Huggs in the Outpost of the Overlord (paula marx counter-part).

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Fri Sep 19, 2008 12:29 pm

heh no, change MovementLoopAddLocation(NPC, 22.19, -6.86, 183.95, 2, 30, say1(NPC)) to
MovementLoopAddLocation(NPC, 22.19, -6.86, 183.95, 2, 30, "say1")

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Fri Sep 19, 2008 12:32 pm

Doh, I've been programming in C++ too much recently. I still find myself adding parenthesis in if statements :lol: I'll get right back to you with that.

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Fri Sep 19, 2008 12:36 pm

She moves now, but doesn't say anything at all. I have the function looking exactly how it should from your example.

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:

Post by John Adams » Fri Sep 19, 2008 12:38 pm

Scat, I do not think this is on the public SVN yet. Tess is still set up as Public. Do you need me to run the Dev code, or are you doing this on your own server?

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Fri Sep 19, 2008 12:43 pm

I just uploaded it to public SVN if either of you wants to grab it.

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Fri Sep 19, 2008 12:45 pm

Doh, there's my second brainfart today. I was doing it on your server. If you just want to test it on dev or upload it to public I'll do it. I don't have any spawns in my db at the moment but I could parse some if you're busy.

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:

Post by John Adams » Fri Sep 19, 2008 12:50 pm

Since LE committed it, give me 5 mins, I'll have Tess updated.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests