PDA

View Full Version : event_case - LUA


provocating
01-30-2015, 03:38 PM
How do I get the id or the name of the spell being cast?

This is in my global_player.lua

function event_cast(e)
e.self:Message(1, "Casting spell " .. e.other.Name());
end


I have tried e.spell and e.other. The Lua wiki is not really helping me, I normally have to guess a lot of incorrect times before I finally figure it out.

Kingly_Krab
01-30-2015, 04:15 PM
Here's what the Lua Parser reference says. event_cast
Client self;
Spell spell;

silvergrin46
02-02-2015, 09:26 PM
This is what i am using in my global_player.lua

Just a snippet from a rather long set of spell checks, can post more of the code if need be.


function event_cast(e)

local PLVL = e.self:GetLevel();

local Mana = e.self:GetMana();
local ManaCost = (PLVL*5);
local NewMana = (Mana - ManaCost);


local Spell_ID = e.spell:ID();
local Spell_Name = e.spell:Name();

local Target = e.self:GetTarget();
local Target_ID = Target:GetNPCTypeID();




if(Spell_ID == 12000) then --spell id check ------------------------------------------------

e.self:Message(5, "I CASTED SPELL: " ..Spell_ID);
e.self:Message(5, "I CASTED SPELL: " ..Spell_Name);

end
end

demonstar55
02-02-2015, 09:36 PM
You guys realize there is a spell quest system? "<zone>/spells/<spellid>.ext" and "global/spells/<spellid>.ext"

silvergrin46
02-02-2015, 10:59 PM
I tried until my eyes bled to get the global/spells/spellid to do what I wanted but could not get it to work right. See my post in this section if you haven't yet. I am using global_player until I can figure it out.

NatedogEZ
02-02-2015, 11:26 PM
Here is an example quest I use... the invis 100 is custom though..

SpellID.lua
11.lua

function event_spell_effect(e)
if(e.target) then
eq.get_entity_list():RemoveFromTargets(e.target, true);
e.target:SetInvisible(100);
e.target:Emote("vanishes into thin air.");
end
end


I just noticed you are using global_player.. so ya this would only work in... global /spells / spellid.lua

Much easier to keep track of spells this way though :p

provocating
02-02-2015, 11:30 PM
I had a typo was my problem....

. instead of a :

NatedogEZ
02-02-2015, 11:46 PM
This might help in the future for finding the correct variable names.

http://wiki.eqemulator.org/p?spell_Events
http://wiki.eqemulator.org/p?NPC_Events
http://wiki.eqemulator.org/p?player_Events

When using the global / spells / spellID.lua


function event_spell_effect(e)
e.target:Shout("Buff name is " .. e.self:Name() .. " Buff ID is " .. e.self:ID());
end