Need help with making a "gambling machine"
- Shadowfied
- Posts: 47
- Joined: Wed Apr 11, 2012 10:42 pm
Need help with making a "gambling machine"
Snip: removed
Last edited by Shadowfied on Sun Feb 17, 2019 4:30 pm, edited 1 time in total.
Re: Need help with making a "gambling machine"
I think I saw stuff about random numbers here:
http://www.grimrock.net/modding/save-ga ... variables/
http://www.grimrock.net/modding/save-ga ... variables/
-
- Posts: 23
- Joined: Wed Sep 12, 2012 10:02 pm
Re: Need help with making a "gambling machine"
Another thing to think about . . .
It's not much of a gamble if it's a rock. Perhaps a loss of life or hunger?
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"
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
Finished Dungeons - complete mods to play
- Shadowfied
- Posts: 47
- Joined: Wed Apr 11, 2012 10:42 pm
Re: Need help with making a "gambling machine"
Snip: removed
Last edited by Shadowfied on Sun Feb 17, 2019 4:30 pm, edited 1 time in total.
Re: Need help with making a "gambling machine"
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):
- 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
- 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.
- make plate
- make script (lua):
Code: Select all
-- plate lever toggle
function platetoggle()
mylever:toggle()
end
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
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.
Finished Dungeons - complete mods to play
Re: Need help with making a "gambling machine"
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
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
- Shadowfied
- Posts: 47
- Joined: Wed Apr 11, 2012 10:42 pm
Re: Need help with making a "gambling machine"
Snip: removed
Last edited by Shadowfied on Sun Feb 17, 2019 4:30 pm, edited 1 time in total.
Re: Need help with making a "gambling machine"
Sure
I created 2 alcoves and a lever
alcove_bet
alcove_win
lever_gamble
Added an lua entity and put this code in it
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.
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
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.
- Shadowfied
- Posts: 47
- Joined: Wed Apr 11, 2012 10:42 pm
Re: Need help with making a "gambling machine"
Snip: removed
Last edited by Shadowfied on Sun Feb 17, 2019 4:30 pm, edited 1 time in total.