I was playing around with pulp with one of my games and realized that slot machines could be made in pulp.
Example code:
This only uses player code
source code
source JSON file.zip (3.4 KB)
on enter do // what the variable values start as
winner = 0
money = 50
slots1 = 0
slots2 = 0
slots3 = 0
pay = 0
begin = 1 // variable for starting the slot machine
end
on draw do // draws stuff on the screen, for example, the variables
label "tokens: {money}" at 0,0 // labels value of your cash
if begin==1 then
label "Press A to insert monies " at 0,14 // tells the player to press A
label "{slots1}" at 11,5 // labels the slot machine var "slots1"
label "{slots2}" at 12,5 // labels the slot machine var "slots2"
label "{slots3}" at 13,5 // labels the slot machine var "slots3"
end
if begin==2 then
label "{slots1}" at 11,5 // labels the slot machine var "slots1"
label "{slots2}" at 12,5 // labels the slot machine var "slots2"
label "{slots3}" at 13,5 // labels the slot machine var "slots3"
if begin==3 then
label "{slots1}" at 11,5 // labels the slot machine var "slots1"
label "{slots2}" at 12,5 // labels the slot machine var "slots2"
label "{slots3}" at 13,5 // labels the slot machine var "slots3"
end
if winner==1 then // if you actually win something
label "winner" at 10,10 // shows that you won
else
end
if pay==1 then // if you pay you will be able to crank
label " Crank handle to play " at 0,14
else
end
end
end
on confirm do // your A button
if begin==1 then // if begin = 1 then pressing A will make being = 2
tell event.player to // tells the player to call pay (on pay do)
call "pay"
begin = 2 // begin variable now = 2
end
else // else nothing happens
end
end
on pay do // if you paid, your money variable goes down by -1
pay = 1
money--
end
on crank do // if pay = 1 then you can crank and attempt to win again
if pay==1 then
pay = 0
tell event.player to // calls slots after paying
call "slots"
end
end
end
on slots do
if begin==2 then // the values of the slot1, slot2, and slot3 variables will randomize from 0,1,2, or 3
slots1 = random 0,3
slots2 = random 0,3
slots3 = random 0,3
wait 0 then // after randomizing each of the 3 variables once, it will wait 0 seconds then do again in a loop 7 more times
slots1 = random 0,3
slots2 = random 0,3
slots3 = random 0,3
wait 0 then
slots1 = random 0,3
slots2 = random 0,3
slots3 = random 0,3
wait 0 then
slots1 = random 0,3
slots2 = random 0,3
slots3 = random 0,3
wait 0 then
slots1 = random 0,3
slots2 = random 0,3
slots3 = random 0,3
wait 0 then
slots1 = random 0,3
slots2 = random 0,3
slots3 = random 0,3
wait 0 then
slots1 = random 0,3
slots2 = random 0,3
slots3 = random 0,3
wait 0 then
slots1 = random 0,3
slots2 = random 0,3
slots3 = random 0,3
tell event.player to // tells player to call match0 mmatch1, match2, and match3
call "match0"
call "match1"
call "match2"
call "match3"
end
end
end
end
end
end
end
end
end
end
on match0 do
begin = 1 //begin var goes back to 1
if slots1==1 then //if all the 3 variables = 0, your player gains 1 token
if slots2==1 then
if slots3==1 then
money ++ //money you earn
winner = 0 //text doesn't display that you won
end
end
end
end
on match1 do
begin = 1 //begin var goes back to 1
if slots1==1 then //if all the 3 variables = 1, your players money increases
if slots2==1 then
if slots3==1 then
money += 20 //money +20
winner = 1 //text displays from draw saying that you won
else
winner = 0 //text doesn't display that you won
end
end
end
end
on match2 do
begin = 1 //begin var goes back to 1
if slots1==2 then //if all the 3 variables = 2, your players money increases
if slots2==2 then
if slots3==2 then
money += 40 //money +50
winner = 1
else
winner = 0
end
end
end
end
on match3 do
begin = 1 //begin var goes back to 1
if slots1==3 then //if all the 3 variables = 3, your players money increases
if slots2==3 then
if slots3==3 then
money += 70 //money +70
winner = 1
else
winner = 0
end
end
end
end
You are free to use the code.