• 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 TFS 1.2 Tutorial Area

Tbol

Well-Known Member
Joined
Apr 7, 2019
Messages
592
Reaction score
64
Looking for tutorial area basically i have this script as an exit area of tutorial zone
LUA:
---# Movement script
local effects = {
    [14724] = 93,
    [14719] = 94,
    [14720] = 82,
    [14721] = 83,
    [14722] = 95,
    [14723] = 76,
    [14725] = 84
}

local config = {
    teleport = {x=663, y=396, z=7}
}

function onStepIn(creature, item)
    if creature:isPlayer() then
        local loadEffect = effects[item:getId()]
        if loadEffect then
            creature:teleportTo(config.teleport)
            creature:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations warrior, your game starts now!')
            creature:setStorageValue(66655, loadEffect)
        end
    end
    return true
end

function onStepOut(creature, item)
    if creature:isPlayer() then
        creature:setStorageValue(66655, -1)
    end
    return true
end
But would like to edit it a little bit and make it if player tries to step on ''14724,14719,14720,14721 etc.....'' he wont be able until he havent learned spell named "X'' and would say you have to learn spell X first to be able to exit this tutorial area.
 
LUA:
---# Movement script
local effects = {
    [14724] = {storageValue = 93, reqSpell = "Light Healing"},
    [14719] = {storageValue = 94, reqSpell = "Light Healing"},
    [14720] = {storageValue = 82, reqSpell = "Light Healing"},
    [14721] = {storageValue = 83, reqSpell = "Light Healing"},
    [14722] = {storageValue = 95, reqSpell = "Light Healing"},
    [14723] = {storageValue = 76, reqSpell = "Light Healing"},
    [14725] = {storageValue = 84, reqSpell = "Light Healing"}
}

local config = {
    storageKey = 66655,
    text = "Congratulations warrior, your game starts now!",
    teleport = {x=663, y=396, z=7},
}

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

    local loadEffect = effects[item:getId()]
    if not loadEffect then
        return false
    end

    if loadEffect.reqSpell and not player:hasLearnedSpell(loadEffect.reqSpell) then
        player:teleportTo(fromPosition, false)
        player:sendTextMessage(MESSAGE_STATUS_DEFAULT, string.format("You have to learn spell '%s' first to be able to exit this tutorial area.", loadEffect.reqSpell))
        return true
    end
 
    player:teleportTo(config.teleport)
    player:sendTextMessage(MESSAGE_INFO_DESCR, config.text)
    player:setStorageValue(config.storageKey, loadEffect.storageValue)
    return true
end

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

    player:setStorageValue(config.storageKey, -1)
    return true
end
 
Last edited:
LUA:
---# Movement script
local effects = {
    [14724] = {storageValue = 93, reqSpell = "Light Healing"},
    [14719] = {storageValue = 94, reqSpell = "Light Healing"},
    [14720] = {storageValue = 82, reqSpell = "Light Healing"},
    [14721] = {storageValue = 83, reqSpell = "Light Healing"},
    [14722] = {storageValue = 95, reqSpell = "Light Healing"},
    [14723] = {storageValue = 76, reqSpell = "Light Healing"},
    [14725] = {storageValue = 84, reqSpell = "Light Healing"}
}

local config = {
    storageKey = 66655,
    text = "Congratulations warrior, your game starts now!",
    teleport = {x=663, y=396, z=7},
}

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

    local loadEffect = effects[item:getId()]
    if not loadEffect then
        return false
    end

    if loadEffect.reqSpell and not player:hasLearnedSpell(loadEffect.reqSpell) then
        player:teleportTo(fromPosition, false)
        player:sendTextMessage(MESSAGE_STATUS_DEFAULT, string.format("You have to learn spell '%s' first to be able to exit this tutorial area.", loadEffect.reqSpell))
        return true
    end
 
    player:teleportTo(config.teleport)
    player:sendTextMessage(MESSAGE_INFO_DESCR, config.text)
    player:setStorageValue(config.storageKey, loadEffect.storageValue)
    return true
end

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

    player:setStorageValue(config.storageKey, -1)
    return true
end
Perfect
 
Back
Top