• 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 Making spell ITEM

empasor123

New Member
Joined
Jul 17, 2024
Messages
15
Reaction score
1
GitHub
empasor123
Hi guys!
Im trying to make a script on a local server. (TFS 1.4.2)


local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValues(player, level, skill)

local min = (level / 5) + (skill * 0.08) + 25
local max = (level / 5) + (skill * 0.18) + 50
return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
return combat:execute(creature, variant)
end





I want this spell to be cast "Exori Maximus" If you have used an item. The lua script for this is done. But i need get a storagevalue somewhere in here. The storagevalue on item you click is 847399. So not everybody can use it until you clicked this item. Tried with chatGPT, and it wont help haha, can someone help me?
 
LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(847399) > 0 then
        local combat = Combat()
        combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
        combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
        combat:setArea(createCombatArea(AREA_CIRCLE3X3))

        function onGetFormulaValues(player, level, skill)
            local min = (level / 5) + (skill * 0.08) + 25
            local max = (level / 5) + (skill * 0.18) + 50
            return -min, -max
        end

        combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

        function onCastSpell(creature, variant)
            return combat:execute(creature, variant)
        end
        
        return onCastSpell(player, target)
    else
        return false
    end
end

also 1.5 Lua Functions (https://otland.net/threads/1-5-lua-functions.288060/) give chat gpt those functions it will be way better at coding and adjust your logic multiple times explain to it exactly what you want in this case
player uses item
check storage x
if storage is true
cast spell
if not
say you can not use this item or return false
 
LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(847399) > 0 then
        local combat = Combat()
        combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
        combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
        combat:setArea(createCombatArea(AREA_CIRCLE3X3))

        function onGetFormulaValues(player, level, skill)
            local min = (level / 5) + (skill * 0.08) + 25
            local max = (level / 5) + (skill * 0.18) + 50
            return -min, -max
        end

        combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

        function onCastSpell(creature, variant)
            return combat:execute(creature, variant)
        end
       
        return onCastSpell(player, target)
    else
        return false
    end
end

also 1.5 Lua Functions (https://otland.net/threads/1-5-lua-functions.288060/) give chat gpt those functions it will be way better at coding and adjust your logic multiple times explain to it exactly what you want in this case
player uses item
check storage x
if storage is true
cast spell
if not
say you can not use this item or return false
that's the reason why u shouldn't use chatGpt : D
 
with item onUse
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, level, skill)
 local min = (level / 5) + (skill * 0.08) + 25 
 local max = (level / 5) + (skill * 0.18) + 50 
 return -min, -max 
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

local function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local variant = Variant(toPosition)
    return combat:execute(player, variant)
 
end

for onUse

LUA:
local combat = Combat()

combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)

combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)

combat:setArea(createCombatArea(AREA_SQUARE1X1))



function onGetFormulaValues(player, level, skill)
 local min = (level / 5) + (skill * 0.08) + 25 
 local max = (level / 5) + (skill * 0.18) + 50 
 return -min, -max 
end



combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")



local function onCastSpell(creature, variant)

    return combat:execute(creature, variant)

end



function onUse(player, item, fromPosition, target, toPosition, isHotkey)

local variant = Variant(creature:getPosition())

    return combat:execute(player, variant)

 

end
Post automatically merged:

ps also written with chatGpt anything else smart to say?
 
with item onUse
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, level, skill)
 local min = (level / 5) + (skill * 0.08) + 25
 local max = (level / 5) + (skill * 0.18) + 50
 return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

local function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local variant = Variant(toPosition)
    return combat:execute(player, variant)
 
end

for onUse

LUA:
local combat = Combat()

combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)

combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)

combat:setArea(createCombatArea(AREA_SQUARE1X1))



function onGetFormulaValues(player, level, skill)
 local min = (level / 5) + (skill * 0.08) + 25
 local max = (level / 5) + (skill * 0.18) + 50
 return -min, -max
end



combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")



local function onCastSpell(creature, variant)

    return combat:execute(creature, variant)

end



function onUse(player, item, fromPosition, target, toPosition, isHotkey)

local variant = Variant(creature:getPosition())

    return combat:execute(player, variant)

 

end
Post automatically merged:

ps also written with chatGpt anything else smart to say?

now remove the local function and you will be fine
 
Last edited:
data/spells.
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValues(player, level, skill)
    local min = (level / 5) + (skill * 0.08) + 25
    local max = (level / 5) + (skill * 0.18) + 50
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    local player = creature:getPlayer()
    if not player then
        return false
    end

    if player:getStorageValue(847399) ~= 1 then
        player:sendCancelMessage("You need to click on the special item before using this spell.")
        return false
    end

    return combat:execute(creature, variant)
end

data/actions.
LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local storageValue = player:getStorageValue(847399)

    if storageValue == 1 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have already learned the Exori Maximus spell.")
    else
        player:setStorageValue(847399, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You can now use the Exori Maximus spell!")
       
        --item:remove(1) --If you want the item to be removed when clicked, just uncomment this line.
    end
   
    return true
end
Post automatically merged:

ps also written with chatGpt anything else smart to say?
Because ChatGPT can’t read your mind or understand exactly what you want, it doesn’t know how to handle TFS scripts correctly. Now this GPT is useless. I prefer a human to carefully review and edit the script properly.
 
Last edited:
now remove the local function and you will be fine
nothing wrong with using local function it causes no error but yeah i just copied it from the other script.
if you give no explaination I wont care what you are talking about for its just useless post no knowledge shared just ignorance shown.
ah i see now the local function for spell?
well leave it there if he gonna want to make spell he will just copy it instead of coming here asking why is my spell not working. im pretty sure handling word local when comparing to other spells will give him that little bright light beacon above head and maybe increment the intelligence skill of this particular individual.
Angelapounder Makesocial Lightbulb GIF by clydesidesocial
 
Last edited:
nothing wrong with using local function it causes no error but yeah i just copied it from the other script.
if you give no explaination I wont care what you are talking about for its just useless post no knowledge shared just ignorance shown.
ah i see now the local function for spell?
well leave it there if he gonna want to make spell he will just copy it instead of coming here asking why is my spell not working. im pretty sure handling word local when comparing to other spells will give him that little bright light beacon above head and maybe increment the intelligence skill of this particular individual.
Angelapounder Makesocial Lightbulb GIF by clydesidesocial

Seems like u got some mental issues
 
Seems like u got some mental issues
ok then give him harder task if he is coming here to ask for help for spell onUse. since you believe he will be able to do it he is clearly used to people doing everything for him but maybe if he does just this one little thing by himself his confidence will raise still awating your 2 warning points for removing content which is against resources board btw. you coming here to laugh post and comment bs without doing anything so what is the point of you being on this forum? to leech ? to play smart? you could have written better script but instead you just tossing worthless opinions all the time.
 
yes :D

But nah for real, you just started being rude/weird because I said that's why u shouldn't use chatGpt :D
because you seem to follow every activity and put useless posts to increase your message count instead of being valuable feedback. perhaps one post here was that.
and I will keep using chatGpt its great because it actually explains all of the stuff and I learn from it more than I did from your mindless brainrot that you are posting recently.
 
because you seem to follow every activity and put useless posts to increase your message count instead of being valuable feedback. perhaps one post here was that.

Yeah man cant wait to reach the 5k so I can tell all my friends I got 5000 posts on otland

and I will keep using chatGpt its great because it actually explains all of the stuff and I learn from it

after months of using chatgpt your lua experience is still on egy level
Im not sure if chatgpt is the problem or you
 
Yeah man cant wait to reach the 5k so I can tell all my friends I got 5000 posts on otland



after months of using chatgpt your lua experience is still on egy level
Im not sure if chatgpt is the problem or you
well i posted the code not you so I get the internet fame
Post automatically merged:

seems like i have been wronged in all of this aswell.

I want this spell to be cast "Exori Maximus" If you have used an item.
not learned but casted
. So not everybody can use it until you clicked this item.

?????????????????????
 
Last edited:
Back
Top