Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+2)

Hello! For Decker Fantasy Camp, I've been trying to make an old-school dungeon-crawler game. I don't have much programming experience, so this project is more to teach myself how to use Decker than make a good game. With that said, I think so far I've been learning pretty quickly.

I figured out how to use checkboxes to make a simple "turning and walking" system. You click on the up button, and if you are not already facing north, you turn north. If you are already facing north, you go north one card. I wanted to add a compass to make it easier to tell what direction you are facing, and here's where I'm running into trouble.

I wanted to make the compass a contraption that way I can simply copy and paste the contraption to each of the cards rather than needing to constantly copy and paste the same four compass canvases over and over. I made my little canvases to go in the contraption, copy and pasted them into the contraption, but they don't seem to be showing up the way they should. I was trying to make one of the canvases visible depending on the direction the player is facing and hide all the others, but changing directions doesn't seem to affect what canvases are shown or hidden at all. If I set the canvases to hidden in the contraption they stay hidden no matter what buttons I press and if I set them to visible they stay visible no matter what buttons I press.

Anyway, here is the code for the contraption. 

if deck.cards["f"].widgets.face_north.value=1
 compass_neutral.show:"none"
 compass_n.show:"transparent"
 compass_e.show:"none"
 compass_s.show:"none"
 compass_w.show:"none"
elseif deck.cards["f"].widgets.face_east.value=1
 compass_neutral.show:"none"
 compass_n.show:"none"
 compass_e.show:"transparent"
 compass_s.show:"none"
 compass_w.show:"none"
elseif deck.cards["f"].widgets.face_south.value=1
 compass_neutral.show:"none"
 compass_n.show:"none"
 compass_e.show:"none"
 compass_s.show:"transparent"
 compass_w.show:"none"
elseif deck.cards["f"].widgets.face_west.value=1
 compass_neutral.show:"none"
 compass_n.show:"none"
 compass_e.show:"none"
 compass_s.show:"none"
 compass_w.show:"transparent"
else
 compass_neutral.show:"transparent"
 compass_n.show:"none"
 compass_e.show:"none"
 compass_s.show:"none"
 compass_w.show:"none"
end
Thank you for any help you can give, and I'm sorry if my explanation isn't very clear. I'm still very new to Decker and programming in general.
(+1)

Here's a somewhat more compact approach that is roughly equivalent to your script:

dirs.face_north:compass_n
dirs.face_east :compass_e
dirs.face_west :compass_w
dirs.face_south:compass_s
 
each canvas name in dirs
 canvas.toggle["transparent" deck.cards.f.widgets[name].value]
end
 
compass_neutral.toggle["transparent" (!sum "transparent"=(range dirs)..show)]

If you want your contraption to update in response to a change in state elsewhere in the deck, you will need to somehow notify the contraption of that change. There are a number of ways to accomplish this. For example, if you wrapped the script you describe in an "on view do ... end" event handler defintion, you could also expose a way for code outside the contraption to fire that view event:

on get_update do
 view
end

And then fire it from the outside when appropriate:

mapArrowContraption.update[]

You could alternatively make a widget inside the contraption "animated" and use the view[] event that fires at 60hz to poll for changes to player direction on each frame, but this type of polling approach should be used sparingly; if lots of contraptions work this way it can add up to your game doing quite a bit of redundant work every frame!

You might also find this thread relevant.

Does any of that help point you in the right direction?

(+1)

Yeah, that worked! Thank you for your help!Although for some reason the compass contraption is only updating when I click the direction buttons twice.