• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Make a player cast spell

Astir Lotus

Well-Known Member
Joined
Sep 14, 2018
Messages
47
Solutions
1
Reaction score
96
TFS 1.3 10.98

So I have been looking back and forth trying to find a way to make a player basically force cast a spell.
Something like player:castSpell("SpellName"), is something I'm looking for to say.

Is there a built in way to do this to the engine, or do I have to edit sources for this?
 

Thank you.

But I might just be stupid, unless something needs to be added.
I added everything that contained "castSpell" to luascript.cpp and luascript.h

Now to what results I get and how I get there.
I made a talkaction to test it out with the code below.
I get no errors with this code.
And nothing happens.

No compile errors.

Lua:
function onSay(player, words, param)

    player:castSpell("Buzz", param)
    
    return true
end
 

So, I've been looking through the C++ code to my best of knowlegde, which is next to nothing, and I guess it's implemented correctly, or not.
And unless Spell and playeris true inside sources, it will push nil to lua, if I understood it correctly.
 
Last edited:
I tested printing out inside the sources right before the if statement to check if player and spell is true.
The two top rows is player userdata, and second row is spell userdata. I've tried with spellname, id userdata, and I can't get it to work.
The last row is from the printing made inside the method "int LuaScriptInterface::luaPlayerCastSpell(lua_State* L)", where I just printed the variable spell, aswell as player.

Not sure if that helps much, but it seems like it's not passing the spell correctly.

Code:
userdata: 0x0c70dba0

userdata: 0x0c640c30

0000000000000000 <-- Spell : Player --> 0000021CD061EC20
 
Back
Top