The original script was made by @Darkhaos and can be found here: TalkAction - Command "/attr" in lua-script talkaction, you can add more functions. (https://otland.net/threads/command-attr-in-lua-script-talkaction-you-can-add-more-functions.33438/)
Added the functions I think most users will have a need for, if you need anything else then you can request it here in the thread or via pm to me.
If you find any bugs send me a pm or write it here in the thread.
I have only tested a few of them, but those that I tested worked.
Thanks to @yogiikke who tested the script for me
Usage: /attr desc, Hello world
Installation
talkactions.xml
attributes.lua
Added the functions I think most users will have a need for, if you need anything else then you can request it here in the thread or via pm to me.
If you find any bugs send me a pm or write it here in the thread.
I have only tested a few of them, but those that I tested worked.
Thanks to @yogiikke who tested the script for me
Usage: /attr desc, Hello world
Installation
talkactions.xml
XML:
<talkaction words="/attr" separator=" " script="attributes.lua" />
attributes.lua
Lua:
local itemFunctions = {
["actionid"] = { isActive = true, targetFunction = function (item, target) return item:setActionId(target) end },
["action"] = { isActive = true, targetFunction = function (item, target) return item:setActionId(target) end },
["aid"] = { isActive = true, targetFunction = function (item, target) return item:setActionId(target) end },
["description"] = { isActive = true, targetFunction = function (item, target) return item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, target) end },
["desc"] = { isActive = true, targetFunction = function (item, target) return item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, target) end },
["remove"] = { isActive = true, targetFunction = function (item, target) return item:remove() end },
["decay"] = { isActive = true, targetFunction = function (item, target) return item:decay() end },
["transform"] = { isActive = true, targetFunction = function (item, target) return item:transform(target) end },
["clone"] = { isActive = true, targetFunction = function (item, target) return item:clone() end }
}
local creatureFunctions = {
["health"] = { isActive = true, targetFunction = function (creature, target) return creature:addHealth(target) end },
["mana"] = { isActive = true, targetFunction = function (creature, target) return creature:addMana(target) end },
["speed"] = { isActive = true, targetFunction = function (creature, target) return creature:changeSpeed(target) end },
["droploot"] = { isActive = true, targetFunction = function (creature, target) return creature:setDropLoot(target) end },
["skull"] = { isActive = true, targetFunction = function (creature, target) return creature:setSkull(target) end },
["direction"] = { isActive = true, targetFunction = function (creature, target) return creature:setDirection(target) end },
["maxHealth"] = { isActive = true, targetFunction = function (creature, target) return creature:setMaxHealth(target) end },
["say"] = { isActive = true, targetFunction = function (creature, target) creature:say(target, TALKTYPE_SAY) end }
}
local playerFunctions = {
["fyi"] = { isActive = true, targetFunction = function (player, target) return player:popupFYI(target) end },
["tutorial"] = { isActive = true, targetFunction = function (player, target) return player:sendTutorial(target) end },
["guildnick"] = { isActive = true, targetFunction = function (player, target) return player:setGuildNick(target) end },
["group"] = { isActive = true, targetFunction = function (player, target) return player:setGroup(Group(target)) end },
["vocation"] = { isActive = true, targetFunction = function (player, target) return player:setVocation(Vocation(target)) end },
["stamina"] = { isActive = true, targetFunction = function (player, target) return player:setStamina(target) end },
["town"] = { isActive = true, targetFunction = function (player, target) return player:setTown(Town(target)) end },
["balance"] = { isActive = true, targetFunction = function (player, target) return player:setBankBalance(target + player:getBankBalance()) end },
["save"] = { isActive = true, targetFunction = function (player, target) return target:save() end },
["type"] = { isActive = true, targetFunction = function (player, target) return player:setAccountType(target) end },
["skullTime"] = { isActive = true, targetFunction = function (player, target) return player:setSkullTime(target) end },
["maxMana"] = { isActive = true, targetFunction = function (player, target) return player:setMaxMana(target) end },
["addItem"] = { isActive = true, targetFunction = function (player, target) return player:addItem(target, 1) end },
["removeItem"] = { isActive = true, targetFunction = function (player, target) return player:removeItem(target, 1) end },
["premium"] = { isActive = true, targetFunction = function (player, target) return player:addPremiumDays(target) end }
}
function onSay(player, words, param)
if not player:getGroup():getAccess() then
return true
end
if player:getAccountType() < ACCOUNT_TYPE_GOD then
return false
end
local split = param:split(",")
if not split[1] then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
return false
end
local position = player:getPosition()
position:getNextPosition(player:getDirection(), 1)
local itemFunction = itemFunctions[split[1]]
local creatureFunction = creatureFunctions[split[1]]
local playerFunction = playerFunctions[split[1]]
if itemFunction and itemFunction.isActive then
local targetItem = Tile(position):getTopVisibleThing(player)
if not targetItem or not targetItem:isItem() then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Item not found.")
return false
end
if itemFunction.targetFunction(targetItem, split[2]) then
position:sendMagicEffect(CONST_ME_MAGIC_GREEN)
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You cannot add that attribute to this item.")
end
elseif creatureFunction and creatureFunction.isActive then
local targetCreature = Tile(position):getTopCreature()
if not targetCreature or not targetCreature:isCreature() then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Creature not found.")
return false
end
if creatureFunction.targetFunction(targetCreature, split[2]) then
position:sendMagicEffect(CONST_ME_MAGIC_GREEN)
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You cannot add that attribute to this creature.")
end
elseif playerFunction and playerFunction.isActive then
local targetPlayer = Tile(position):getTopCreature()
if not targetPlayer or not targetPlayer:getPlayer() then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.")
return false
end
if playerFunction.targetFunction(targetPlayer, split[2]) then
position:sendMagicEffect(CONST_ME_MAGIC_GREEN)
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You cannot add that attribute to this player.")
end
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Unknow attribute.")
end
return false
end
Last edited by a moderator: