• 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!

Help with xikini script fortfs 1.3

Diarreamental

Well-Known Member
Joined
Jul 6, 2015
Messages
453
Solutions
1
Reaction score
80
Hello

I'm trying to use an script made by @Xikini for tfs 1.3
im using tfs 1.3 downgraded by nekiro
but it has error in console im tryng to test 1 action of the script
this is the original script
Lua:
--[[
    "object" -> anything that is not a floor tile.
    "floor" floor tiles (roof/ground/hole)
    
    "add" / "remove" -> tells the script what to do when lever is on the left. (after it flops, it will do the opposite)
    "replace" -> transforms an item into another item, instead of adding/removing
    
]]--

local levers = {left = 1945, right = 1946}
local config = {
-- [actionid] = {"object", "add", position, itemid, relocate_direction}
-- [actionid] = {"object", "remove", position, itemid, relocate_direction}
-- [actionid] = {"object", "replace", position, {itemid_from, itemid_to}}

    [45001] = {"object", "add", Position(94, 93, 7), 1026, "south"},
    [45002] = {"object", "remove", Position(96, 93, 7), 1026, "south"},
    [45003] = {"object", "replace", Position(98, 93, 7), {1026, 1050}},
    
-- [actionid] = {"floor", "add", position, itemid}
-- [actionid] = {"floor", "remove", position, itemid}
-- [actionid] = {"floor", "replace", position, {itemid_from, itemid_to}, {relocate_from, relocate_to}}

    [45004] = {"floor", "add", Position(100, 93, 7), 406},
    [45005] = {"floor", "remove", Position(102, 93, 7), 406},
    [45006] = {"floor", "replace", Position(104, 93, 7), {406, 407}, {false, false}},
    [45007] = {"floor", "replace", Position(106, 93, 6), {461, 462}, {false, true}}, -- true means YES do relocate.
}

local relocateDirections = {
    ["north"] = {0, -1},
    ["east"]  = {1, 0},
    ["south"] = {0, 1},
    ["west"]  = {-1, 0},
}

local function transposeFields(fromPosition, toPosition, transpose)
    local tile = Tile(fromPosition)
    if tile then
        local items = tile:getItems()
        if items then
            for i, item in ipairs(items) do
                if transpose == true then
                    item:moveTo(toPosition)
                else
                    item:remove()
                end
            end
        end
    end
end

local leverActions = Action()

function leverActions.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local item_id = item.itemid
    local index = config[item.actionid]
    local tile = Tile(index[3])
    
    -- add
    if index[2] == "add" and item_id == levers.left or index[2] == "remove" and item_id == levers.right then
        if index[1] == "object" then
            local relocatePosition = Position(index[3].x + relocateDirections[index[5]][1], index[3].y + relocateDirections[index[5]][2], index[3].z)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, true)
            Game.createItem(index[4], 1, index[3])
        elseif index[1] == "floor" then
            Game.createTile(index[3], true)
            Game.createItem(index[4], 1, index[3])
        end
        
    -- remove
    elseif index[2] == "remove" and item_id == levers.left or index[2] == "add" and item_id == levers.right then
        if index[1] == "object" then
            local object = tile:getItemById(index[4])
            object:remove()
        elseif index[1] == "floor" then
            local relocatePosition = Position(index[3].x, index[3].y, index[3].z + 1)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, false)
            tile:getGround():remove()
        end
        
    -- replace
    elseif index[2] == "replace" then
        local transformTo = tile:getItemCountById(index[4][1]) > 0 and 2 or 1
        local object = tile:getItemById(transformTo == 2 and index[4][1] or index[4][2])           
        object:transform(index[4][transformTo])
        if index[1] == "floor" and index[5][transformTo] == true then
            local relocatePosition = Position(index[3].x, index[3].y, index[3].z + 1)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, false)
        end
        
    end


    
    item:transform(item_id == levers.left and levers.right or levers.left)
    return true
end

for k, v in pairs(config) do
    leverActions:aid(k)
end
leverActions:register()


i have only change 1 cordinate and the action ids and "south" code to "east"
Code:
    [25001] = {"object", "add", Position(94, 93, 7), 1026, "east"},
    [25002] = {"object", "remove", Position(32566, 32119, 7), 1026, "east"},
    [25003] = {"object", "replace", Position(98, 93, 7), {1026, 1050}},
    
-- [actionid] = {"floor", "add", position, itemid}
-- [actionid] = {"floor", "remove", position, itemid}
-- [actionid] = {"floor", "replace", position, {itemid_from, itemid_to}, {relocate_from, relocate_to}}

    [25004] = {"floor", "add", Position(100, 93, 7), 406},
    [25005] = {"floor", "remove", Position(102, 93, 7), 406},
    [25006] = {"floor", "replace", Position(104, 93, 7), {406, 407}, {false, false}},
    [25007] = {"floor", "replace", Position(106, 93, 6), {461, 462}, {false, true}}, -- true means YES do relocate.
}
and i removed function is hotkey
Code:
function leverActions.onUse(player, item, fromPosition, target, toPosition)
Code:


this is the error in console when i use the leve acton id 25002 and the other action ids are not registered on the map yet



this is the whole error that i have in console when i use the lever
Code:
Lua Script Error: [Scripts Interface]
C:\Users\felip\Desktop\Desktop-OT\TFS772 1.3\data\scripts\triangle_tower_switch_near_temple.lua:callback
...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: attempt to index local 'object' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: in function <...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:57>
Post automatically merged:

function leverActions.onUse(player, item, fromPosition, target, toPosition) <<<line 57
object:remove() <<<line78
 
Last edited:
Solution
Hello

I'm trying to use an script made by @Xikini for tfs 1.3
im using tfs 1.3 downgraded by nekiro
but it has error in console im tryng to test 1 action of the script
this is the original script
Lua:
--[[
    "object" -> anything that is not a floor tile.
    "floor" floor tiles (roof/ground/hole)
  
    "add" / "remove" -> tells the script what to do when lever is on the left. (after it flops, it will do the opposite)
    "replace" -> transforms an item into another item, instead of adding/removing
  
]]--

local levers = {left = 1945, right = 1946}
local config = {
-- [actionid] = {"object", "add", position, itemid, relocate_direction}
-- [actionid] = {"object", "remove", position, itemid, relocate_direction}
-- [actionid] = {"object"...
Hello

I'm trying to use an script made by @Xikini for tfs 1.3
im using tfs 1.3 downgraded by nekiro
but it has error in console im tryng to test 1 action of the script
this is the original script
Lua:
--[[
    "object" -> anything that is not a floor tile.
    "floor" floor tiles (roof/ground/hole)
  
    "add" / "remove" -> tells the script what to do when lever is on the left. (after it flops, it will do the opposite)
    "replace" -> transforms an item into another item, instead of adding/removing
  
]]--

local levers = {left = 1945, right = 1946}
local config = {
-- [actionid] = {"object", "add", position, itemid, relocate_direction}
-- [actionid] = {"object", "remove", position, itemid, relocate_direction}
-- [actionid] = {"object", "replace", position, {itemid_from, itemid_to}}

    [45001] = {"object", "add", Position(94, 93, 7), 1026, "south"},
    [45002] = {"object", "remove", Position(96, 93, 7), 1026, "south"},
    [45003] = {"object", "replace", Position(98, 93, 7), {1026, 1050}},
  
-- [actionid] = {"floor", "add", position, itemid}
-- [actionid] = {"floor", "remove", position, itemid}
-- [actionid] = {"floor", "replace", position, {itemid_from, itemid_to}, {relocate_from, relocate_to}}

    [45004] = {"floor", "add", Position(100, 93, 7), 406},
    [45005] = {"floor", "remove", Position(102, 93, 7), 406},
    [45006] = {"floor", "replace", Position(104, 93, 7), {406, 407}, {false, false}},
    [45007] = {"floor", "replace", Position(106, 93, 6), {461, 462}, {false, true}}, -- true means YES do relocate.
}

local relocateDirections = {
    ["north"] = {0, -1},
    ["east"]  = {1, 0},
    ["south"] = {0, 1},
    ["west"]  = {-1, 0},
}

local function transposeFields(fromPosition, toPosition, transpose)
    local tile = Tile(fromPosition)
    if tile then
        local items = tile:getItems()
        if items then
            for i, item in ipairs(items) do
                if transpose == true then
                    item:moveTo(toPosition)
                else
                    item:remove()
                end
            end
        end
    end
end

local leverActions = Action()

function leverActions.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local item_id = item.itemid
    local index = config[item.actionid]
    local tile = Tile(index[3])
  
    -- add
    if index[2] == "add" and item_id == levers.left or index[2] == "remove" and item_id == levers.right then
        if index[1] == "object" then
            local relocatePosition = Position(index[3].x + relocateDirections[index[5]][1], index[3].y + relocateDirections[index[5]][2], index[3].z)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, true)
            Game.createItem(index[4], 1, index[3])
        elseif index[1] == "floor" then
            Game.createTile(index[3], true)
            Game.createItem(index[4], 1, index[3])
        end
      
    -- remove
    elseif index[2] == "remove" and item_id == levers.left or index[2] == "add" and item_id == levers.right then
        if index[1] == "object" then
            local object = tile:getItemById(index[4])
            object:remove()
        elseif index[1] == "floor" then
            local relocatePosition = Position(index[3].x, index[3].y, index[3].z + 1)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, false)
            tile:getGround():remove()
        end
      
    -- replace
    elseif index[2] == "replace" then
        local transformTo = tile:getItemCountById(index[4][1]) > 0 and 2 or 1
        local object = tile:getItemById(transformTo == 2 and index[4][1] or index[4][2])         
        object:transform(index[4][transformTo])
        if index[1] == "floor" and index[5][transformTo] == true then
            local relocatePosition = Position(index[3].x, index[3].y, index[3].z + 1)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, false)
        end
      
    end


  
    item:transform(item_id == levers.left and levers.right or levers.left)
    return true
end

for k, v in pairs(config) do
    leverActions:aid(k)
end
leverActions:register()


i have only change 1 cordinate and the action ids and "south" code to "east"
Code:
    [25001] = {"object", "add", Position(94, 93, 7), 1026, "east"},
    [25002] = {"object", "remove", Position(32566, 32119, 7), 1026, "east"},
    [25003] = {"object", "replace", Position(98, 93, 7), {1026, 1050}},
  
-- [actionid] = {"floor", "add", position, itemid}
-- [actionid] = {"floor", "remove", position, itemid}
-- [actionid] = {"floor", "replace", position, {itemid_from, itemid_to}, {relocate_from, relocate_to}}

    [25004] = {"floor", "add", Position(100, 93, 7), 406},
    [25005] = {"floor", "remove", Position(102, 93, 7), 406},
    [25006] = {"floor", "replace", Position(104, 93, 7), {406, 407}, {false, false}},
    [25007] = {"floor", "replace", Position(106, 93, 6), {461, 462}, {false, true}}, -- true means YES do relocate.
}
and i removed function is hotkey
Code:
function leverActions.onUse(player, item, fromPosition, target, toPosition)
Code:


this is the error in console when i use the leve acton id 25002 and the other action ids are not registered on the map yet



this is the whole error that i have in console when i use the lever
Code:
Lua Script Error: [Scripts Interface]
C:\Users\felip\Desktop\Desktop-OT\TFS772 1.3\data\scripts\triangle_tower_switch_near_temple.lua:callback
...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: attempt to index local 'object' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: in function <...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:57>
Post automatically merged:

function leverActions.onUse(player, item, fromPosition, target, toPosition) <<<line 57
object:remove() <<<line78
Is the wall at position 32566, 32119, 7, itemid 1026?

If I remember triangle tower, it is a brick wall that faces west/east and is itemid 1025. 1026 is the north/south wall.

Lua:
[25002] = {"object", "remove", Position(32566, 32119, 7), 1026, "east"}, -- old
[25002] = {"object", "remove", Position(32566, 32119, 7), 1025, "east"}, -- new
 
Solution
Back
Top