LUA Functions Sticky

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

Moderator: Team Members

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

Post by LethalEncounter » Sun Jun 01, 2008 6:26 pm

Yah, those are bugs/things that haven't been implemented yet. Could you post these in the bugs forums so that I don't forget about them?

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Post by Zcoretri » Sun Jun 01, 2008 11:05 pm

Sure, I will copy post to bugs forum :)
Image

link2009
Retired
Posts: 390
Joined: Fri Aug 10, 2007 5:59 pm
Location: POrTal
Contact:

Post by link2009 » Fri Jun 13, 2008 8:24 pm

I don't know if you did this deliberately LE, but it seems that you're missing a SetX function, seeing as how you already included SetY and SetZ.

Code: Select all

int EQ2Emu_lua_SetY(lua_State* state){
	Spawn* spawn = lua_interface->GetSpawn(state);
	float value = lua_interface->GetFloatValue(state, 2);
	lua_interface->ResetFunctionStack(state);
	if(spawn)
		spawn->SetY(value);
	return 0;
}
int EQ2Emu_lua_SetZ(lua_State* state){
	Spawn* spawn = lua_interface->GetSpawn(state);
	float value = lua_interface->GetFloatValue(state, 2);
	lua_interface->ResetFunctionStack(state);
	if(spawn)
		spawn->SetZ(value);
	return 0;
}
Image
-Vecinu de la Patru

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

Post by LethalEncounter » Sat Jun 14, 2008 7:10 am

You are using old code, as none of the SetX/SetY/SetZ exist anymore. They were replaced with SetPosition(spawn, x, y, z)

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 Aug 08, 2008 11:27 pm

I am planning on updating the LUA functions list tomorrow, and thought of a new command we could use during zone development. I didn't see it in the code yet, but I'd like a function that generates an animation on the NPC.
Paula Marx wanders the grassy area, stops and gathers for a moment, before moving on. I assume the gathering is a visual_state (2809 gathering_search, 2810 gathering_success).
Thanks
-J

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 » Sat Aug 09, 2008 5:56 pm

Back to this real quick. If I wanted to spawn an NPC and have it's script "remember" it's spawn coordinates, could I use:
x=GetX(NPC)
y=GetY(NPC)
z=GetZ(NPC)
?
The script I am trying to make will wander an NPC from it's spawn point, to another few points, then return to IT's spawn point - and I was hoping to use 1 script for many spawns. Maybe I need a LUA script reference guide.

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 » Sat Aug 09, 2008 6:02 pm

Actually, nevermind. I was just being impatient as usual. I am being thrown off by some odd behavior with movement, so LE when you get a chance, come check out my movements for the Sapswill invaders that approach the guard post on the goodie island.
Things appear to be "sticking" and warping. But the GetX thingy, worked like a champ!

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

Post by LethalEncounter » Sat Sep 20, 2008 7:20 am

I added a new function called SetPlayerProximityFunction(Spawn, range val, In Range Function, OOR Function). Example:

Code: Select all

function spawn(NPC)
	SetPlayerProximityFunction(NPC, 10, "InRange", "LeavingRange")
end
function InRange(NPC, Player)
	Say(NPC, GetName(Player) .. " is in range with a distance of: " .. GetDistance(NPC, Player))
end
function LeavingRange(NPC, Player)
	Say(NPC, GetName(Player) .. " is now out of range with a distance of: " .. GetDistance(NPC, Player))
end
gives the output:
(1221919684)[Sat Sep 20 09:08:04 2008] \aPC 2 Marv Boilfist:Marv Boilfist\/a says, "Lethal is in range with a distance of: 7.551794052124"
(1221919708)[Sat Sep 20 09:08:28 2008] \aPC 2 Marv Boilfist:Marv Boilfist\/a says, "Lethal is now out of range with a distance of: 11.774223327637"
Note that the distance is recalculated every 2 seconds to avoid too much processing, so be sure to make your ranges large enough to fire before the player enters the range and then leaves it. The OOR function is also optional. The use I see for this function is specifically for all the proximity chatting that occurs when you run in range of an NPC, but I designed it to be a little more flexible for anything you can think of.

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 » Sat Sep 20, 2008 10:08 am

Wicked! Can't wait to test this bad boy out. Thanks LE!

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 » Sat Sep 20, 2008 11:21 am

Very nice indeed, thank you!

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 » Sat Sep 20, 2008 10:01 pm

This works perfectly. Very nice indeed!

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 Functions Sticky

Post by John Adams » Sat Feb 28, 2009 12:00 pm

Scat/LE, I have updated the LUA Functions Wiki - so hopefully we can change the opening post to point to this Wiki page now, and do our function updates there.

This first page is a list of the functions, and each one has a drill-down to the function page itself. I will provide a few examples, so if anyone else out there has time to spare, let's fill these pages in. LUA is one of the cores to our server customization, and without adequate docs, we'll be answering questions all day instead of developing servers. ;)

User avatar
ZexisStryfe
Posts: 1026
Joined: Thu Jul 26, 2007 6:39 am
EQ2Emu Server: Sytherian Legends
Location: Connecticut
Contact:

Re: LUA Functions Sticky

Post by ZexisStryfe » Mon Mar 09, 2009 8:34 pm

Looking over these lists something occured to me. We need two more Set functions- SetAdventureClass and SetTradeskillClass.

In tradeskilling choosing you class is done through conversations with the trainers, and I would also like the Set Adventure Class function so that I can have an adventuring trainer do the same.
~ EQ2 Emulator Project Manager

Image
Image
Image
"Zexis, from this day forth, you shall be known as... '3 of 6'" - John Adams

User avatar
Xanibunib
Retired
Posts: 121
Joined: Thu Mar 06, 2008 11:01 pm
EQ2Emu Server: RENS
Location: Colorado

Re: LUA Functions Sticky

Post by Xanibunib » Thu Mar 26, 2009 2:00 am

How about a "follow" command that would go under the "spawn" function to make one NPC auto follow another... like ...

Code: Select all

Follow(Spawn, NPC, NPC#)
Would use this to make things like dogs follow guards...
Village idiot...

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

Re: LUA Functions Sticky

Post by LethalEncounter » Fri Mar 27, 2009 6:50 pm

It is on svn now. Btw you might notice "Combined Packet!" and "Combined App Packet!" being printed to your console window. It is normal. I'm just trying to track down the desync issue. If you think you see a client sending a bunch of jibberish packets could you please make a post with your console text? I'd really be interested in it. :)

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests