Page 1 of 2
Need help with making a "gambling machine"
Posted: Thu Sep 13, 2012 10:46 am
by Shadowfied
Snip: removed
Re: Need help with making a "gambling machine"
Posted: Thu Sep 13, 2012 10:54 am
by Lmaoboat
Re: Need help with making a "gambling machine"
Posted: Thu Sep 13, 2012 11:03 am
by Fistchandeles
Another thing to think about . . .
It's not much of a gamble if it's a rock. Perhaps a loss of life or hunger?
Re: Need help with making a "gambling machine"
Posted: Thu Sep 13, 2012 11:09 am
by Komag
You could have the pressure plate respond only to items (not monsters or the party), although this would allow other objects to work and not just rocks
Re: Need help with making a "gambling machine"
Posted: Thu Sep 13, 2012 11:11 am
by Shadowfied
Snip: removed
Re: Need help with making a "gambling machine"
Posted: Thu Sep 13, 2012 1:24 pm
by Komag
one crazy way is to have the plate connect to a script that toggles a lever, then you can always check the lever state with "mylever:getLeverState()"
- make plate
- make script (lua):
Code: Select all
-- plate lever toggle
function platetoggle()
mylever:toggle()
end
- in plate Inspector, create connection to script, with "platetoggle" as the action
so far, this gets the pressure plate to activate a lever. Test it by placing a lever nearby (even on the wall right in front of the plate) to just see if it works right, making the lever go down and up when placing a rock on and off the plate)
Then you can move the lever to some little room far away so it isn't heard
- then make a script that checks the lever state and does something if it's activated
Code: Select all
-- do something special script
function leveraction()
if mylever:getLeverState() == "activated" then
superdoor:open()
else
superdoor:close()
end
end
- go into mylever inspector and create a connection to the new script with "leveraction" as the Action
this would then open the door you have called "superdoor", so you can set this up for a test
So if you want it to do something else, you can change "superdoor:open()" to some other action
This whole setup above is ridiculous though because it's easy to just link a plate to a door. But it just illustrates how you can do some things with scripts.
Re: Need help with making a "gambling machine"
Posted: Thu Sep 13, 2012 3:47 pm
by Shroom
You could use
entitiesAt(level, x, y)
in order to find out what they are 'betting'.
So, for example, use a lever activate a teleport which just moves objects to a holding area - this hits a floor trigger which runs the code to scan the contents. Do some random rolling and then create winnings at another location next to them, before finally destroying the 'bets'
edit: just found this while looking through the references
Alcove:containedItems()
so no need for teleporters etc
Re: Need help with making a "gambling machine"
Posted: Fri Sep 14, 2012 11:05 am
by Shadowfied
Snip: removed
Re: Need help with making a "gambling machine"
Posted: Fri Sep 14, 2012 1:40 pm
by Shroom
Sure
I created 2 alcoves and a lever
alcove_bet
alcove_win
lever_gamble
Added an lua entity and put this code in it
Code: Select all
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.
Re: Need help with making a "gambling machine"
Posted: Sun Sep 16, 2012 2:39 pm
by Shadowfied
Snip: removed