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

Action .::1-Row Slot Machine::. TFS [0.3/0.4/1.0/1.2]

I'm having trouble getting it work on TFS 1.3. The fruits don't appear. The console error says
[code = lua]
local fruit = doCreateItemEx(choose(FRUITS)) --HERE

for tile = 101, 103 do
doFruit(SETUP.POS[item.uid], tile, (tile-100)*SETUP.LIMIT) -- HERE
end
[/code]

Any ideas?
 
@Above post

Solved. The tiles of the fruits on TFS 1.3 cannot have action ID's. ONLY on the lever. I tried with the tile item ID 426. I'm not sure if its this way for ALL tiles or specifically this one but its honestly too much trouble to test other tiles with all the other features I have to work on with my server.

It works perfectly now (For anyone who wants to use this on TFS 1.3).
 

Attachments

@Above post

Solved. The tiles of the fruits on TFS 1.3 cannot have action ID's. ONLY on the lever. I tried with the tile item ID 426. I'm not sure if its this way for ALL tiles or specifically this one but its honestly too much trouble to test other tiles with all the other features I have to work on with my server.

It works perfectly now (For anyone who wants to use this on TFS 1.3).
:( not work fo me, not Actions on tiles if i use lever
13:32 You see an item of type 1094.
Item ID: 1094, Action ID: 100.
 
Let me see your slot.lua file and screenshot of your setup
 
Let me see your slot.lua file and screenshot of your setup
Sem título.png
Lua:
--[[
    .::1-Row Slot Machine::.
          For TFS 1.2
      by Cybermaster (cbrm)
]]--
--    1. FRUITS
TEMP, FRUITS = {
    ['APPLE'] = 2674,    ['BANANA'] = 2676,    ['BERRY'] = 2680,
    ['CHERRY'] = 2679,    ['LEMON'] = 8841,    ['MANGO'] = 5097,
    ['MELON'] = 2682,    ['ORANGE'] = 2675,    ['PUMPKIN'] = 2683
}, {}
for name, id in pairs(TEMP) do
    _G[name] = id
    table.insert(FRUITS, id)
end
--    2. CONFIGURATION
SETUP = {
    MONEY = 1000, --REQUIRED MONEY(gp) TO PLAY SLOT MACHINE
    TIME = 200, --MILLISECONDS TO SWITCH FRUITS
    LIMIT = 20, --COUNTER TO STOP CHANGING FRUIT IF PLAYER DOESN'T (decreases each SETUP.TIME)
    LEVER = {9825, 9826},
    WIN = {
    -- [FRUITS] = {PRIZE,#PRIZE}]
        --MIXED COMBINATIONS
            [{CHERRY,PUMPKIN,CHERRY}] = {2160,2},
            [{LEMON,MELON,LEMON}] = {2160,1},
        --TRIPLE COMBINATIONS
            [{BERRY,BERRY,BERRY}] = {2152,80},
            [{MANGO,MANGO,MANGO}] = {2152,60},
            [{PUMPKIN,PUMPKIN,PUMPKIN}] = {2152,80},
            [{MELON,MELON,MELON}] = {2152,50},
            [{BANANA,BANANA,BANANA}] = {2152,40},
            [{LEMON,LEMON,LEMON}] = {2152,25},
            [{CHERRY,CHERRY,CHERRY}] = {2152,20},
            [{ORANGE,ORANGE,ORANGE}] = {2152,30},
            [{APPLE,APPLE,APPLE}] = {2152,10},
        --ANY COMBINATIONS
            [{ANY,PUMPKIN,PUMPKIN}] = {2152,5},
            [{PUMPKIN,PUMPKIN,ANY}] = {2152,5},
            [{PUMPKIN,ANY,PUMPKIN}] = {2152,10},
            [{ANY,CHERRY,CHERRY}] = {2152,4},
            [{CHERRY,CHERRY,ANY}] = {2152,4},
            [{CHERRY,ANY,CHERRY}] = {2152,8},
            [{ANY,LEMON,LEMON}] = {2152,5},
            [{LEMON,LEMON,ANY}] = {2152,5},
            [{LEMON,ANY,LEMON}] = {2152,5},
        },
    MSG = {'Bingo!','Lucky!','Jackpot!','Win!'},
    POS = {    --[LEVER.UNIQUEID] = {direction to row, distance from lever to row, position of lever}
        [6297] = {direction = SOUTH, distance = 2, pos = Position(32349, 32229, 4)},
        [6299] = {direction = EAST, distance = 2, pos = Position(32353, 32223, 4)},
        [6300] = {direction = NORTH, distance = 2, pos = Position(32386, 32183, 8)},
        [6301] = {direction = NORTH, distance = 2, pos = Position(32390, 32183, 8)},
        [6302] = {direction = NORTH, distance = 2, pos = Position(32394, 32183, 8)},
        [6303] = {direction = WEST, distance = 2, pos = Position(32346, 32223, 4)},
    },
}
for lever, row in pairs(SETUP.POS) do
    local position = row.pos:getNextPosition(row.direction, row.distance)
    for tile = 0, 2 do
        if row.direction % 2 == 0 then
            SETUP.POS[lever][tile+101] = Position(position.x+tile, position.y, position.z, 1)
        else
            SETUP.POS[lever][tile+101] = Position(position.x, position.y+tile, position.z, 1)
        end
    end
end
--    3. FUNCTIONS
MAY_NOT_MOVE = 20155
function mayNotMove(cid, bool)
    Player(cid):setStorageValue(MAY_NOT_MOVE, bool and 1 or -1)
end
function choose(...)
    local arg, ret = {...}
    if type(arg[1]) == 'table' then
        ret = arg[1][math.random(#arg[1])]
    else
        ret = arg[math.random(#arg)]
    end
    return ret
end
local function switchLever(lev)
    return doTransformItem(lev.uid, lev.itemid == SETUP.LEVER[1] and SETUP.LEVER[2] or SETUP.LEVER[1])
end
local function verifyRow(cid, pos)
    local result = false
    for combo, profit in pairs(SETUP.WIN) do
        if (getTileItemById(pos[101], combo[1]).uid > 0) or (combo[1] == ANY) then
            if (getTileItemById(pos[102], combo[2]).uid > 0) or (combo[2] == ANY) then
                if (getTileItemById(pos[103], combo[3]).uid > 0) or (combo[3] == ANY) then
                    result = true
                    doPlayerAddItem(cid, profit[1], profit[2] or 1, true)
                    doCreatureSay(cid, choose(SETUP.MSG), TALKTYPE_ORANGE_1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Congratulations!! You won ' .. profit[2] .. ' ' .. getItemDescriptions(profit[1]).plural ..'!')
                    break
                end
            end
        end
    end
    for tile = 101, 103 do
        doRemoveItem(getTileThingByPos(pos[tile]).uid)
        doSendMagicEffect(pos[tile], result and CONST_ME_GIFT_WRAPS or CONST_ME_EXPLOSIONHIT)
    end
    return not result and doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You have lost in the Slot Machine :( Try again')
end
local function getDirectionTo(pos1, pos2)
    local dir = SOUTH
    if(pos1.x > pos2.x) then
        dir = WEST
        if(pos1.y > pos2.y) then
            dir = NORTHWEST
        elseif(pos1.y < pos2.y) then
            dir = SOUTHWEST
        end
    elseif(pos1.x < pos2.x) then
        dir = EAST
        if(pos1.y > pos2.y) then
            dir = NORTHEAST
        elseif(pos1.y < pos2.y) then
            dir = SOUTHEAST
        end
    elseif(pos1.y > pos2.y) then
        dir = NORTH
    elseif(pos1.y < pos2.y) then
        dir = SOUTH
    end
    return dir
end
--    4. SCRIPT
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if getDirectionTo(player:getPosition(), fromPosition) > 3 then
        return true
    end
      local pid = player:getId()
    local function getLever()
        for _, id in ipairs(SETUP.LEVER) do
            local lever = getTileItemById(fromPosition, id)
            if lever.uid > 0 then
                return lever
            end
        end     
    end
    if item.actionid == 0 then
        doSetItemActionId(item.uid, 100)
    end
    local function doFruit(pos, id, limit)
        if not player:isPlayer() then
            doSetItemActionId(item.uid, 100)
            for tile = 100, 103 do
                if getTileThingByPos(pos[tile]).uid > 0 then
                    doRemoveItem(getTileThingByPos(pos[tile]).uid)
                end
            end
            return true
        end
    
        if getTileThingByPos(pos[id]).itemid < 1 then
            doSendMagicEffect(pos[id], CONST_ME_POFF)
            local fruit = doCreateItemEx(choose(FRUITS))
            doSetItemActionId(fruit, 100)
            doTileAddItemEx(pos[id], fruit)
        else
            doTransformItem(getTileThingByPos(pos[id]).uid, choose(FRUITS))
        end
    
        if limit < 1 then
            doSendMagicEffect(pos[id], math.random(28, 30))
            doTransformItem(getTileThingByPos(pos[id]).uid, choose(FRUITS))
            switchLever(getLever())
            doSetItemActionId(getLever().uid, getLever().actionid+1)
        elseif getLever().actionid > id then
            doSendMagicEffect(pos[id], math.random(28, 30))
            doTransformItem(getTileThingByPos(pos[id]).uid, choose(FRUITS))
        else
            addEvent(doFruit, SETUP.TIME, pos, id, limit-1)
        end
    end
    if item.actionid == 100 then     
        if not player:removeMoney(SETUP.MONEY) then
            return player:sendTextMessage(MESSAGE_STATUS_WARNING, 'You need ' .. SETUP.MONEY ..' gps to play Slot Machine.')
        end
    
        doSetItemActionId(item.uid, 101)
        mayNotMove(pid, true)
        switchLever(item)
        player:say('-$' .. SETUP.MONEY, TALKTYPE_ORANGE_1)
        for tile = 101, 103 do
            doFruit(SETUP.POS[item.uid], tile, (tile-100)*SETUP.LIMIT)
        end
    elseif isInArray({101,102,103}, item.actionid) then
        switchLever(item)
        doSetItemActionId(item.uid, item.actionid+1)
    elseif item.actionid == 104 then
        switchLever(item)
        mayNotMove(pid, false)
        verifyRow(pid, SETUP.POS[item.uid])
        doSetItemActionId(item.uid, 100)
    end
    return true
end
 
Lua:
--Lines 49-56
    POS = {    --[LEVER.UNIQUEID] = {direction to row, distance from lever to row, position of lever}
        [6297] = {direction = SOUTH, distance = 2, pos = Position(32349, 32229, 4)},
        [6299] = {direction = EAST, distance = 2, pos = Position(32353, 32223, 4)},
        [6300] = {direction = NORTH, distance = 2, pos = Position(32386, 32183, 8)},
        [6301] = {direction = NORTH, distance = 2, pos = Position(32390, 32183, 8)},
        [6302] = {direction = NORTH, distance = 2, pos = Position(32394, 32183, 8)},
        [6303] = {direction = WEST, distance = 2, pos = Position(32346, 32223, 4)},
    },

should be

Lua:
    POS = {    --[LEVER.UNIQUEID] = {direction to row, distance from lever to row, position of lever}
-----------------------------V-HERE-V----------------------V-V--V--V-HERE-V--V--V---
        [6297] = {direction = NORTH, distance = 2, pos = Position(32349, 32229, 4)},
        [6299] = {direction = NORTH, distance = 2, pos = Position(32353, 32223, 4)},
        [6300] = {direction = NORTH, distance = 2, pos = Position(32386, 32183, 8)},
        [6301] = {direction = NORTH, distance = 2, pos = Position(32390, 32183, 8)},
        [6302] = {direction = NORTH, distance = 2, pos = Position(32394, 32183, 8)},
        [6303] = {direction = NORTH, distance = 2, pos = Position(32346, 32223, 4)},
    },

if all of your casino rooms are setup like your picture. Make sure your DIRECTION and POSITION are coded correctly.
 
Lua:
--Lines 49-56
    POS = {    --[LEVER.UNIQUEID] = {direction to row, distance from lever to row, position of lever}
        [6297] = {direction = SOUTH, distance = 2, pos = Position(32349, 32229, 4)},
        [6299] = {direction = EAST, distance = 2, pos = Position(32353, 32223, 4)},
        [6300] = {direction = NORTH, distance = 2, pos = Position(32386, 32183, 8)},
        [6301] = {direction = NORTH, distance = 2, pos = Position(32390, 32183, 8)},
        [6302] = {direction = NORTH, distance = 2, pos = Position(32394, 32183, 8)},
        [6303] = {direction = WEST, distance = 2, pos = Position(32346, 32223, 4)},
    },

should be

Lua:
    POS = {    --[LEVER.UNIQUEID] = {direction to row, distance from lever to row, position of lever}
-----------------------------V-HERE-V----------------------V-V--V--V-HERE-V--V--V---
        [6297] = {direction = NORTH, distance = 2, pos = Position(32349, 32229, 4)},
        [6299] = {direction = NORTH, distance = 2, pos = Position(32353, 32223, 4)},
        [6300] = {direction = NORTH, distance = 2, pos = Position(32386, 32183, 8)},
        [6301] = {direction = NORTH, distance = 2, pos = Position(32390, 32183, 8)},
        [6302] = {direction = NORTH, distance = 2, pos = Position(32394, 32183, 8)},
        [6303] = {direction = NORTH, distance = 2, pos = Position(32346, 32223, 4)},
    },

if all of your casino rooms are setup like your picture. Make sure your DIRECTION and POSITION are coded correctly.
not work =x
 
You didn't change anything. Of course its not going to work...
 
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/slot.lua:onUse
LuaScriptInterface::luaDoTileAddItemEx(). Item not found
stack traceback:
        [C]: in function 'doTileAddItemEx'
        data/actions/scripts/slot.lua:174: in function 'doFruit'
        data/actions/scripts/slot.lua:202: in function <data/actions/scripts/slot.lua:140>

Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
LuaScriptInterface::luaDoTileAddItemEx(). Item not found
stack traceback:
        [C]: in function 'doTileAddItemEx'
        data/actions/scripts/slot.lua:174: in function <data/actions/scripts/slot.lua:159>

I get these errors when I use the lever, it disappears but fruits go on. Then I can't stop it with lever and can't play again as I don't have lever, any ideas?
OTXServer by Malucoo (based on tfs 1.3)
 
@yug0 What tiles are you using? Where are you assigning the AID/UID? I had the same problem too so I can help you fix it.
 
when I use the lever, it disappears

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/slot.lua:onUse
LuaScriptInterface::luaDoTileAddItemEx(). Item not found
stack traceback:
        [C]: in function 'doTileAddItemEx'
        data/actions/scripts/slot.lua:174: in function 'doFruit'
        data/actions/scripts/slot.lua:202: in function <data/actions/scripts/slot.lua:140>

Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
LuaScriptInterface::luaDoTileAddItemEx(). Item not found
stack traceback:
        [C]: in function 'doTileAddItemEx'
        data/actions/scripts/slot.lua:174: in function <data/actions/scripts/slot.lua:159>

I get these errors when I use the lever, it disappears but fruits go on. Then I can't stop it with lever and can't play again as I don't have lever, any ideas?
OTXServer by Malucoo (based on tfs 1.3)


Code:
Lua Script Error: [Action Interface]
data/actions/scripts/slot.lua:onUse
...s/scripts/slot.lua:183: attempt to call global 'doCreateItemEx' (a nil value)
stack traceback:
        [C]: in function 'doCreateItemEx'
        ...s/scripts/slot.lua:183: in function 'doFruit'
        ...s/scripts/slot.lua:213: in function <...s/scripts/slot.lua:151>

when I use the lever, it disappears
I have the same problem with tfs 1.3
please help
 
I know this is an old thread but I've been trying this for HOURS now without progress of this error..
Lua:
2021-10-24 01:25:00 -  script loaded
2021-10-24 01:25:00 -  [2021-24-10 01:25:00.026] [error] Lua script error: /var/www/otbr/data/scripts/actions/custom/slot.lua 
2021-10-24 01:25:00 -  [2021-24-10 01:25:00.026] [error] /var/www/otbr/data/scripts/actions/custom/slot.lua:65: attempt to index local 'position' (a nil value)
2021-10-24 01:25:00 -  stack traceback:
2021-10-24 01:25:00 -      [C]: in function '__index'
2021-10-24 01:25:00 -      /var/www/otbr/data/scripts/actions/custom/slot.lua:65: in main chunk 
2021-10-24 01:25:00 -  [2021-24-10 01:25:00.026] [error] slot.lua 
2021-10-24 01:25:00 -  [2021-24-10 01:25:00.026] [error]

Code is the original one, exept that
Lua:
#3 function + others has been changed out into:
player:setMoveLocked(true)
player:setMoveLocked(false)

Ideas?
 
Is there a way to use this script twice?
Once to allow people to play with money, and another area to allow play to play with ItemID, quantity

When I tried to duplicate it and use diff lever UID and stuff, the first one stopped working. Any way to allow 2 different scripts/games

Also is it possible to make this so people cant manually use the lever to change the slots, and let the game auto-play it. They should only be able to start and end it, while the script does the clicking
Cheers
 
Last edited:
Back
Top