Problem in my game

It’s my first pulp game and I’m having a little bit at trouble.

I am making a game that sometimes when playing you need to turn the crank five times to continue. There are 5 boxes, and the each time the crank is cracked I want one to fill and become a square. I have tried everything: events, variables, everything I can think of. I just can't figure it out. If anyone knows how to do this pls let me know! :pray:

Well, you can set the boxes up via sprites, they need to look like nothing (or items with an empty collect event to make it walk-through), and then, add a custom event to it, that when called will turn it into the black tile, and in order to check the cranking, and tell the boxes to fill, use this code (on the player script):

on crank do
crank_angle += event.ra
//the 360 on the angle check can be changed
if crank_angle>=360
crank_angle = 0
cranked += 1
call “fill_boxes
end
end

on fill_boxes do
if cranked==1 then
emit “box1fillEvent”
elseif cranked==2 then
emit “box2fillEvent”
//repeat 3 times with three more fill events
end
end
end
end
end
end

This code should work, reply to this message if you have problems with this code.

Ok, incase you are having problems with my code from before, I made a little prototype, and this new code worked:

Player Script:

on crank do
crank_angle += event.ra
if crank_angle>=360 then
crank_angle = 0
cranked += 1
call "box_logic"
end

end

on box_logic do
if cranked==1 then
emit "box1fillEvent"
elseif cranked==2 then
emit "box2fillEvent"
elseif cranked==3 then
emit "box3fillEvent"
elseif cranked==4 then
emit "box4fillEvent"
elseif cranked==5 then
cranked = 0
emit "box5fillEvent"
end
end

box 1 script:

on box1fillEvent do
play "black"
end

box 2 script:

on box2fillEvent do
play "black"
end

box 3 script:

on box3fillEvent do
play "black"
end

box 4 script:

on box4fillEvent do
play "black"
end

box 5 script:

on box5fillEvent do
play "black"
end

1 Like