• 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 Roulette instead of dice

Yamo

New Member
Joined
Jun 8, 2008
Messages
77
Reaction score
2
Heyo all,

I want to learn to script in lua for ot's and I think the best way to learn is by just trying.
My first script is a modify on the actionscript of the dice, which makes it a roulette (table)
Feedback is appreciated.

Code:
[code=lua]
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(fromPosition.x ~= CONTAINER_POSITION) then
        doSendMagicEffect(fromPosition, CONST_ME_CRAPS)
    end

    local value = math.random(5700, 5736) - 5700
    local color = ""
    if(value == 0) then
        color = "green"
    elseif(value <= 10 and value % 2 == 0) then
        color = "black"
    elseif(value >= 11 and value <= 19 and value % 2 == 1) then
        color = "black"
    elseif(value >= 26 and value % 2 == 0) then
        color = "black"
    else
        color="red"
    end
  
    doCreatureSay(cid, getCreatureName(cid) .. ' rolled ' .. value .. ', ' .. color .. '!', TALKTYPE_ORANGE_1)
    return true
end
[/CODE]

EDIT:
Oops, I think I created this topic on the wrong (sub)forum
 
Last edited:
only thing i can see is
local value = math.random(5700, 5736) - 5700
can be
local value = math.random(0, 36)

rest looks fine xD

and if ur looking to learn to scripting i would suggest using tfs 1.x with metatables
 
only thing i can see is
local value = math.random(5700, 5736) - 5700
can be
local value = math.random(0, 36)

rest looks fine xD

and if ur looking to learn to scripting i would suggest using tfs 1.x with metatables
Yeah. The dice script had a math.random(5792, 5797) - 5791, so I suspected it had a reason. :3
I'll take a look at tfs 1.x, thanks :)
 
Yeah. The dice script had a math.random(5792, 5797) - 5791, so I suspected it had a reason. :3
I'll take a look at tfs 1.x, thanks :)
Yeah thats actual item id minus the first dice item id so the script knew which number to which dice item id..If im not wrong :p
 
Last edited:
Yeah thats actual item id minus the first dice item id so the script knew which number to which dice item id..If im not wrong :p
Ah, okay, thx :D I thought it might've been something with more accuracy with math.random() on higher digits, so thanks for the explaination :D
 
Back
Top