local playerRoll = math.random(100)
local houseRoll = math.random(90)
hudPrint("Player rolled "..playerRoll.." House rolled "..houseRoll)
if playerRoll < houseRoll then
For some reason I set this to whoever rolls lowest - dont ask me why - maybe thats why it looks wrong
function gamble()
if checkContents(alcove_bet, "torch_everburning") then
local playerRoll = math.random(90)
local houseRoll = math.random(100)
hudPrint("Player rolled "..playerRoll.." House rolled "..houseRoll)
if playerRoll > houseRoll then
hudPrint("You Win")
playSound("level_up")
alcove_win:addItem(spawn("boots_valor"))
else
hudPrint("You lose")
spawn("poison_cloud", party.level, party.x, party.y, 0)
end
end
lever_gamble:setLeverState("deactivated")
end
I have changed it round so that the highest roll wins, with the same bias as before though. Take out the hudPrint once your happy, or revert to the old code without the variables
Komag wrote:to create a "gambling" setup/machine, where you pay with a certain type of item, and then have a chance at winning a good thing or else get damaged:
--------------
example from Shroom:
I created 2 alcoves and a lever
function gamble()
if checkContents(alcove_bet, "torch_everburning") then
if math.random(100) < math.random(90) then
hudPrint("You Win")
playSound("level_up")
alcove_win:addItem(spawn("boots_valor"))
else
hudPrint("You lose")
spawn("poison_cloud", party.level, party.x, party.y, 0)
end
end
lever_gamble:setLeverState("deactivated")
end
function checkContents(location,item)
for object in location:containedItems() do
-- if you want to show the name of items you actually put in the alcove
-- then uncomment the hudPrint below
-- hudPrint(object.name)
if object.name == item then
--remove object (but havent worked out how yet!)
return true
end
end
return false
end
click on the lever and add a connector to the lua script - select "gamble" in the last combo box
As you can see, I have used the item "torch_everburning" as this is what the champion has in his hand when you hit preview. Put this in the alcove and pull the lever.
the math.random() dictate the win chances 1-100 vs 1-90, so not in characters favour.
Change these values as you want to, and code for which items etc.
One thing I couldn't see how to do was remove the bet item. If you want I can post a link with an example saved in the editor.
Hello Komag,
first, your scripts have been really helpful and have allowed me to begin making some great dungeons!
Second, I have a question about your gambling script above. How would you implement a timer so that players can't just pull the lever repeatedly until they win? I know you mentioned trying to remove the item being offered, but I figured a timer could be helpful as well.
sevenbirds wrote:
Hello Komag,
first, your scripts have been really helpful and have allowed me to begin making some great dungeons!
Second, I have a question about your gambling script above. How would you implement a timer so that players can't just pull the lever repeatedly until they win? I know you mentioned trying to remove the item being offered, but I figured a timer could be helpful as well.
First, thanks! Second, it's Shroom's script, not mine, so I really don't know the inner workings that well. Third, a timer could be part of the "circuit" which would make the lever ineffective for a little while, but the lever itself would still go up and down which might confuse the player why it's not working at the moment, but perhaps that might be okay
[quote="frankman2112"]Poker is very easy. The part you have to understand is what hand beats what hand. The important thing is to watch not only what you have, but what the others may have..
________
{old poker link was here - EDITED BY KOMAG}
OK, I admit it. This confuses me. Is this an extremely well directed spam, or just a rather odd comment to revive an old thread for.
'cause it is appropiatly placed like most spam bots would not bother with, yet pretty much an advertisement with nothing to actually say about the topic.
frankman2112 wrote:Poker is very easy. The part you have to understand is what hand beats what hand. The important thing is to watch not only what you have, but what the others may have..
________
{old poker link was here - EDITED BY KOMAG}
OK, I admit it. This confuses me. Is this an extremely well directed spam, or just a rather odd comment to revive an old thread for.
'cause it is appropiatly placed like most spam bots would not bother with, yet pretty much an advertisement with nothing to actually say about the topic.
The spambot just searches for any threads about "gambling" in this case and then auto-submits the spam post which may luckily (to them) seem to fit right in and be harder to detect as pure spam.