pasiak12
Well-Known Member
- Joined
- Jun 7, 2009
- Messages
- 261
- Solutions
- 13
- Reaction score
- 71
Hi!
I am learning LUA programming on tfs 1.2
For the first task I decided to modify the Haste spell. I want it to behave differently depending if the player is wearing boots of haste.
This is my code:
As you can see I dont receive in function onCastSpell(creature, variant) the players cid. I think I get it from creature:getId() because the function to send the message works correctly on the player executing the spell.
The function getPlayerSlotItem(x, 8) where x should be CID returns a bad item array. Every time its called it returns a different value (the player wears the same boots all time).
I think it's not the correct cid. How to get players boots id when the function has only creature variable?
I would be grateful if anyone could send me a documentation to lua funcions of TFS 1.2. I know its possible to read it from the sources but it takes a lot of time to check out the functions from there.
I am learning LUA programming on tfs 1.2
For the first task I decided to modify the Haste spell. I want it to behave differently depending if the player is wearing boots of haste.
This is my code:
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
local condition = Condition(CONDITION_HASTE)
condition:setParameter(CONDITION_PARAM_TICKS, 5000) -- standard time
condition:setFormula(0.3, 0, 0.3, 0) -- values
combat:setCondition(condition)
function onCastSpell(creature, variant)
x = creature:getId() -- player cid???
doPlayerSendTextMessage(x, MESSAGE_STATUS_CONSOLE_BLUE, "test msg")
local b = getPlayerSlotItem(x, 8)
print("ID: " .. x .. b)
if getPlayerSlotItem(x, 8) == 2195 then
print("got boh")
condition:setParameter(CONDITION_PARAM_TICKS, 10000) --10 sec
else
print("no bohs")
condition:setParameter(CONDITION_PARAM_TICKS, 1000) -- 1 sec
end
return combat:execute(creature, variant)
end
As you can see I dont receive in function onCastSpell(creature, variant) the players cid. I think I get it from creature:getId() because the function to send the message works correctly on the player executing the spell.
The function getPlayerSlotItem(x, 8) where x should be CID returns a bad item array. Every time its called it returns a different value (the player wears the same boots all time).
I think it's not the correct cid. How to get players boots id when the function has only creature variable?
I would be grateful if anyone could send me a documentation to lua funcions of TFS 1.2. I know its possible to read it from the sources but it takes a lot of time to check out the functions from there.