LUA Functions Sticky
Moderator: Team Members
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
-
link2009
- Retired
- Posts: 390
- Joined: Fri Aug 10, 2007 5:59 pm
- Location: POrTal
- Contact:
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;
}
-Vecinu de la Patru
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
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
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
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
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.
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.
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
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!
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
I added a new function called SetPlayerProximityFunction(Spawn, range val, In Range Function, OOR Function). Example:
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.
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(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.
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
- 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
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.
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.
- ZexisStryfe
- Posts: 1026
- Joined: Thu Jul 26, 2007 6:39 am
- EQ2Emu Server: Sytherian Legends
- Location: Connecticut
- Contact:
Re: LUA Functions Sticky
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.
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.
- Xanibunib
- Retired
- Posts: 121
- Joined: Thu Mar 06, 2008 11:01 pm
- EQ2Emu Server: RENS
- Location: Colorado
Re: LUA Functions Sticky
How about a "follow" command that would go under the "spawn" function to make one NPC auto follow another... like ...
Would use this to make things like dogs follow guards...
Code: Select all
Follow(Spawn, NPC, NPC#)Village idiot...
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
Re: LUA Functions Sticky
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. 
Who is online
Users browsing this forum: No registered users and 0 guests



