• 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 [Talkaction] Looping command !check

christx

New Member
Joined
Jun 25, 2017
Messages
24
Reaction score
2
Hi,
I've written a script that allow players to check blessings if they will spell command !check
After use that command player get info like this:
Code:
14:55 Received blessings:
Spark of the Phoenix
Embrace of World
Spiritual Shielding
Fire of the Suns
Wisdom of Solitude
Twist of Fate
But after one use, it is impossible to spell this command again. There is a missing loop I guess so want ask you, where is the problem?

LUA:
local blessings = {
    {id = 1, name = 'Spark of the Phoenix'},
    {id = 2, name = 'Embrace of World'},
    {id = 3, name = 'Spiritual Shielding'},
    {id = 4, name = 'Fire of the Suns'},
    {id = 5, name = 'Wisdom of Solitude'},
    {id = 6, name = 'Twist of Fate'}
}

function onSay(player, item, fromPosition, target, toPosition, isHotkey)
    local result, bless = 'Received blessings:'
    for i = 1, #blessings do
        bless = blessings[i]
        result = player:hasBlessing(bless.id) and result .. '\n' .. bless.name or result
    end

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 20 > result:len() and 'No blessings received.' or result)
    return true
end
 
Last edited:
Hmm exactly there is solution at the first post, nothing to change

I tested this with TFS 1.3 so I don't know is it gonna work or another versions.
SOLUTION:
LUA:
local blessings = {
    {id = 1, name = 'Spark of the Phoenix'},
    {id = 2, name = 'Embrace of World'},
    {id = 3, name = 'Spiritual Shielding'},
    {id = 4, name = 'Fire of the Suns'},
    {id = 5, name = 'Wisdom of Solitude'},
    {id = 6, name = 'Twist of Fate'}
}
function onSay(player, item, fromPosition, target, toPosition, isHotkey)
    local result, bless = 'Received blessings:'
    for i = 1, #blessings do
        bless = blessings[i]
        result = player:hasBlessing(bless.id) and result .. '\n' .. bless.name or result
    end
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 20 > result:len() and 'No blessings received.' or result)
    return true
end

example of talkactions.xml
Code:
<talkaction words="!check" event="script" script="checkbless.lua" />
 
Back
Top