Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

ahmwma

634
Posts
9
Topics
441
Followers
263
Following
A member registered Mar 18, 2017 · View creator page →

Creator of

Recent community posts

Thank you so much for taking a look!!

You've got some good answers already but here's another style of moving canvases around.

If you'd like to have things visibly move from one location to another, like a smooth slide across the screen, I sometimes use the Ease module for that. You can find ease.deck in the examples folder that comes along with Decker. You'll need to transfer the ease module from that example deck into your project.

An example of creating this kind of animation with the Ease module might look like this:

on click do
 time:60
 each i in range time
  mycanvas.pos: ease.lerp[i/time-1  startref.pos  endref.pos]
  sleep[]
 end
end

To explain what's going on here:

The "time: 60" creates a temporary variable called time which is used to set how many frames the animation should take. Decker runs at 60 frames per second so this example goes pretty fast. Feel free to change the number to whatever you want.

The "each" loop will run repeatedly, for as many loops as the number in our "time" variable.

The mycanvas.pos: part starts just like the other examples in the thread, by setting the position of the image (canvas) you want to move... 

But in this example I'm calling on the ease module to help do the math for a specific style of movement. There's a bunch of different functions representing different kinds of movement in the module. Smooth, elastic, bouncy, etc. You can see all the included possibilities if you open up ease.deck. I chose lerp for this because it's smooth and simple but you can replace lerp with any of the other options.

The startref.pos and endref.pos inside of the brackets are our start and end positions. I wrote it as if they were referencing other widgets like Internet Janitor mentioned or they could be replaced with pairs of coordinates.

sleep[] pauses for a frame on each step of movement while the "each" loop is running. This is needed to make the animation take the amount of time we set earlier.

Then the two ends close off the "each" loop and the original "on click do" event handler.

I hope this makes some sense. It may not be what you're looking for right now, I just wanted to mention it.

It's almost a year since this first came out and there's been some small additions over that time.

New pages about:

  • The different ways widgets use the .value and .pattern attributes
  • Resizing your Deck by changing the .size attribute and changing the size of the window with .esize
  • Two "More Resources" page which links to various fonts and utilities made by the community. My list in the book is a little different from the Grand Unified Decker Resource Index here in the forums, because Phinxel points out some useful things from the contraption bazaar and various sound toys that are cool examples of working with audio in decker.

There's also various corrections, edits and doodles.

Thank you again to anyone who has read it and found something useful in it! I've still got more plans for things to add in the future.

Thank you for playing and for your kind words, Salty! I appreciate it a lot.

Could you explain more about what you're doing?

I've been playing with the changes in this version and I'm still getting release[] events from canvases even when there's another widget below them.

Alright, things are getting more complicated here but I think I have code snippets that answer most of your concerns. I may have missed something along the way. I'm really concerned I've missed something or not thought something through all the way on this one. Things are really getting more specific to the needs of your project and I can only write code for the things I know about it! I may have guessed wrong!

I'm going to switch to referring to the MacWindows as macFieldWindows now, since I think that's the version you're using (the resizable draggable one from the bazaar) and I'm going to be referring to them by the contraption name (def.name="macFieldWindow") in the scripts.

Also, it hadn't occurred to me when I was writing my last post that you could also "lock" plot buttons by hiding them (show: "none" is pretty much the same as locking a button to the player).

So, if you're hiding your plot buttons (show:"none") then buttonset could be a list of all buttons that lock/unlock  together. 

The "plot-related lock" would be their visibility, in that case.

But if you want your special plot buttons to be visible AND locked until they're ready then we'll still need to create a list of normal buttons that doesn't include the special one, and then do something special for the special button. 

It's just something that occurred to me while I was writing this up. Feel free to ignore it.

I'm going to try to do both things at once by automating the list of all buttons and also removing "specialbutton" from that list when we come back to the new "buttoncheck[]" function later in this post.

And just because it's useful to know, this kind of line:

button.locked:rect.overlaps[me button]

...is kind of like writing button.locked:0 or 1, except it gets the 0 or 1 from checking if those two things are overlapping. 

button.locked gets 0 if false and 1 if true.

Okay, hopefully I've got all my snippets in order for the real stuff! For macFieldWindow... We're going to make some new functions that will make them all match each other whenever there's a change, and we'll also need to make a tiny edit to the contraption again.

The edit to the contraption:

Open any macFieldWindow properties and then click [Prototype...] to go inside the contraption prototype area. Then use the menu [Prototype > Script] and put this line anywhere that's not inside of another script:

on get_animate do view end

This lets us send animate[]  to the mac windows to refresh their appearance. This avoids the widget visibly updating in front of your player when they move around your project after something about the mac windows has changed.

That's all we need to do here, so close the script viewer then use [Prototype > Close] to leave this area.

Making the macFieldWindows match:

These two new scripts should go in the Deck level script, because they need to be visible from everywhere.

This first one, "posupdate[]", makes a list of all the macFieldWindow contraptions and then makes them match the size and position of the specific widget that called the function (that's what it's referring to as "me" in the script). 

on posupdate do
 instances:raze each card in range deck.cards
  extract value where value..def.name="macFieldWindow" from card.widgets
 end
 (me drop instances)..pos:me.pos
 (me drop instances)..size:me.size
 instances..event.buttoncheck[]
 instances..animate[]
end

The second one, "noteupdate[]" lets you set the written section of the macFieldWindows to whatever you put inside the brackets.

on noteupdate x do
 instances:raze each card in range deck.cards
  extract value where value..def.name="macFieldWindow" from card.widgets
 end
 instances..value:x
 instances..animate[]
end

If it's just simple text you can write it as a string inside of quotes for short notes or if you want to prepare something longer with special formatting you can copy the contents of an existing field into them.

To use this in scripts anywhere in your project:

noteupdate["To Do: Investigate the Building"] # for short notes
noteupdate[anExistingField.value] # copies the contents of an existing field

That's all we need to do in the Deck Script, I think....

Changes to the script for the individual macFieldWindows:

on release do
 posupdate[]
end

on buttoncheck do
 buttonset:extract value where value..type="button" from card.widgets
 if me.show="none"
  buttonset..locked:0
 else
  each button in buttonset
   button.locked:overlaps[me button]
  end
 end
end

Now when a window is released (from moving or resizing) it will call the posupdate[] function (the thing we added up in the deck script) to make the others match. And that posupdate[] function we added also tells all the mac windows in your project to check if they're overlapping any buttons on their cards with their own personal buttoncheck[] functions.

The buttoncheck[] above is a generic one, which can be used on cards if you don't have any "specialbutton"s to worry about, and this is an example of a version of buttoncheck[] that does create an exception for a special button:

on buttoncheck do
 buttonset:extract value where value..type="button" from card.widgets
 if me.show="none"
  buttonset..locked:0
 else
  each button in buttonset
   button.locked:overlaps[me button]
  end
 end

 if somethinghappened.value & (me.show="none")
  specialbutton.locked:0
 elseif (somethinghappened.value=0)
  specialbutton.locked:1
 else
  specialbutton.locked:rect.overlaps[me specialbutton]
 end
end

This new version defines "buttonset" as all the things of type="button" on the card, like before, and then we check specialbutton again specifically.  This way you only need to write specific code for for the exceptions, and those exceptions can be different for each card's macFieldWindow.

The if statements after that look at different possible situations your specialbutton could be in:

  • If something happened and me(the macFieldWindow) is hidden, then the special button should be unlocked.
  • If something didn't happen then it should always be locked.
  • Else, if the above statements weren't true, then it'll check if the macFieldWindow is overlapping it and decide whether or not it should be locked based on that.

It's a little more complicated! But I hope you can follow along.

The last thing that I think you need right now, is how to tell the button that toggles your macFieldWindow's visibility that it should also cause a buttoncheck[] to happen.

And in a very simple case, for only the current card, it could look like this:

on click do
 macFieldWindow1.toggle["solid"]
 macFieldWindow1.event.buttoncheck[]
end

But maybe you want it to update the visibility of all the notes on all the cards?

I'm out of time for now, but feel free to let me know. Hopefully this is enough for you to work with for now! (And hopefully I wrote things correctly!)

For this last one I assumed the mac window had the default name when it's created: "macFieldWindow1", but if not then please change that to match your actual widget name. Anything that says "def.name="macFieldWindow" doesn't need to be changed. That kind of script is looking at the name of the prototype, not the individual widgets made from it.

And of course, specialbutton and somethinghappened are just placeholders for whatever you're really working on. :)

It's really lovely to see little glimpses of your project coming together from the questions you're asking.

Hooray! :D I'm glad!

Thank you! 🤍

Hi! Sorry for the delay, it's been a busy week. But I am so glad to see you back and working on your project!

This might be a little confusing but I'll do my best... we're going to change the MacWindow contraption a little bit. I'll explain the changes, and also just post a code block for the modified version afterwards in case that's more helpful to you.

There are two draggable canvases inside of the MacWindow contraption.
One is at the top and lets you move the window around the screen. The other is the one in the bottom corner that lets you  resize the window.

Inside of the scripts for both of these internal canvases they already have on release do event handlers that are doing something else. 

But since we'd also like them to do something when people "release" the contraption on the card (checking for buttons, then locking them) we can add a line saying "card.event.release" to both of the scripts:

on release pos do
field.locked:card.locked
card.event.release # This is the new line
end

This lets the release event from these canvases (when the window is moved or resized) also bubble up to the script for the MacWindow that you have on the card. And that lets us write another "on release do" event handler there, which does something specific to the card it's on.

Or, alternatively, here's the modified version in a codeblock:

%%WGT0{"w":[{"name":"macFieldWindow1","type":"contraption","size":[134,93],"pos":[193,184],"locked":1,"script":"on close do\n \nend\n\non resize do\n \nend\n\nbuttonset:button1,button2,button3\n\non release do\n each button in buttonset\n  button.locked:rect.overlaps[me button]\n end\nend","def":"macFieldWindow","widgets":{"close":{},"resize":{"pos":[113,4]},"title":{"size":[37,17],"pos":[48,1],"value":"Hello"},"drag_resize":{"pos":[118,77]},"field":{"size":[133,59],"locked":1,"value":{"text":["I am a draggable and resizeable window sporting a rich text field!\n","Try me!"],"font":["","menu"],"arg":["",""]}},"bar":{"size":[134,19]}}}],"d":{"macFieldWindow":{"name":"macFieldWindow","size":[59,71],"resizable":1,"margin":[22,34,33,33],"description":"a window frame in the style of MacOS 6, sporting a field as well as supporting dragging and resizing! The internal field is available  at x.field\nThis version has added an \"on release do\" event.","version":1,"script":"on get_title do title.text end\non set_title x do title.text:x end\non get_field do field end\non get_value do field.value end\non set_value x do field.value: x end\n\non view do\n field.locked:card.locked\n t:get_title[]\n if count t\n  title.font:\"menu\"\n  s:first title.font.textsize[t]\n  title.size:(s+10),title.size[1]\n  title.pos :(.5*card.size[0]-title.size[0]),title.pos[1]\n  title.show:\"solid\"\n else\n  title.show:\"none\"\n end\nend","template":"on close do\n \nend\n\non resize do\n \nend\n\non release do\n\nend","image":"%%IMG3ADsARwbAgHBILBqPyKSyCGo6n9CodEqtgobWrHYbxXK/YCnWeFWWl2Mz2dulBsLvZ/w6TRPp9TP6PW/O+UxsUH2DcIV+dUJ6ioRyi0t4Tn+PZ3mWX4STYoyBbo9qZIhrimKeYI2SiYB3qKJ7jJ6jra2RXLSznKygr5+6vmHAwILBxFbDxchdr8vMzADP0NHS09TV0rSDQtbb3NyNqEPd4uPPmbV+2uTq1n2akunr8dHuiO8B8vjl9Ydn+fh8psL5i8dEjp2BBFM5sodwHb1aAhuOe9gOnsRuf0Khu3dRHDaDHDt62xJRJLtmJkdqKZly2keGLau93BhTJkmLNaHN7JfzGsqe826GBApgJ8ueGQvSJKpvn9OjOSmCZNr0XMWhQJVuXEW16LmFUGvGAQeTqdSyRNspRJu10DecSNsowxp3ZbO7eI+U4ndp7cIsx0j97YtOLmDBogwTpmPuUza1i5zuLQi5sT2/Cj+O3Ysn06+v9TRLzix50piAxkan2vx3lerOqUHDtrpaMFnZpA2P1eg68x3coX9DVt17tWLOxgeTDfwttkHFyxFjBv719tZA0k1pd24sr3e8Rb+LRxME","attributes":{"name":["title","value"],"label":["Title","Text"],"type":["string","rich"]},"widgets":{"close":{"type":"button","size":[11,11],"pos":[9,4],"script":"on click do\n card.event[\"close\"]\nend","style":"invisible"},"resize":{"type":"button","size":[11,11],"pos":[38,4],"script":"on click do\n card.event[\"resize\"]\nend","style":"invisible"},"title":{"type":"field","size":[8,17],"pos":[-12,1],"locked":1,"font":"menu","show":"none","border":0,"style":"plain","align":"center"},"drag_resize":{"type":"canvas","size":[14,14],"pos":[43,55],"script":"on click pos do\n field.locked:1\nend\n\non drag pos do\n card.size:(me.offset-card.pos-16)|(title.size[0]+57),85\n view[]\n field.locked:1\nend\n\non release pos do\n card.event.release\n field.locked:card.locked\nend","show":"transparent","border":0,"draggable":1,"scale":1},"field":{"type":"field","size":[58,37],"pos":[0,18],"border":1,"scrollbar":1},"bar":{"type":"canvas","size":[59,19],"pos":[0,0],"script":"on click pos do\n field.locked:1\nend\n\non drag pos do\n card.pos:me.offset\nend\n\non release pos do\n field.locked:card.locked\n card.event.release\nend","show":"transparent","border":0,"draggable":1,"scale":1}}}}}

No more worrying about the contraption! Back to your cards, where we can modify the scripts inside each instance of the MacWindow in your project.

buttonset:button1,button2,button3

on release do
 each button in buttonset
  button.locked:rect.overlaps[me button]
 end
end

AND we need to do some important setup to define "rect.overlaps" and to customize "buttonset" for your project.

To get the rect module, we'll need to transfer it over from examples/draggable.deck. 

Decker > Resources... then select draggable.deck in the example folder and transfer "rect" to your current project.

To customize buttonset, you'll need to modify the list of the buttons that you want to lock/unlock when the MacWindow is over them. I just wrote a generic list while testing.

buttonset:button1,button2,button3

This can be in the MacWindow's widget script if there's only one mac window per card, or you can put it in the Card script if you have multiple MacWindows and they all need to lock/unlock the same set of buttons.

The reason why I'm defining the set of buttons this way instead of looking for every button on the card is because I figured that you might have some buttons that need to stay locked until something specific happens in the story... And if you do have special buttons like that, then you can put those specific button in a separate If statement.

on release do
 each button in buttonset
  button.locked:rect.overlaps[me button]
 end
 if somethinghappened.value
  specialbutton.locked:rect.overlaps[me specialbutton]
 end
end

Hopefully that will stop your story-related buttons from unlocking before they're supposed to.

I think you're all set on the zazz.wave stuff? So moving on to the music...

You might be able to skip the slider, but in either case, we're using grid.row to find the currently selected row.

If you want to move that value (the number of the selected row) over to a slider and use it from there, then you could do something like this inside the Grid's script:

on click row do
songslider.value:songgrid.row 
end

 And then inside the button you can do something like this if you're using the slider... (Remember that numbers start counting at 0!)

on click do
 if songslider.value=0
  play["firstsong"]
 elseif songslider.value=1
  play["secondsong"]
 end
end

Or if you'd like to skip the slider you can check the selected grid row from inside of your button like this:

on click do
 if songgrid.row=0
  play["firstsong"]
 elseif songgrid.row=1
  play["secondsong"]
 end
end

 Depending on the number of songs you're dealing with you may have a lot of elseif elseif elseif to add to your button script,  and if that's true then you might want to switch over to using a table instead at some point...  but if it's only a couple of them then this should be fine.

I'm also not sure what you're doing with your music, so I just put the generic play[] function there for now.

As always, change the names to the actual names of your widgets and songs and I'll try to be around to answer any more questions you may have!

Well, it's not a built-in feature (as far as I know) but it should be possible to create a script which imports an image and does other stuff with it at the same time. 

I don't have much direct advice on how, since I haven't done that kind of thing, but I do know that in the Array Interface section of the Decker manual there's an example of reading/using information from an imported image. Just in case that's useful to you.

This is so beautiful and ambitious! All the interactive elements weaving into the writing, the animations of the water, and all your clever contraption work. Amazing.

I use an external program when I want to record a gif to explain something. I'm using ScreenToGif on Windows right now, though I'm sure there are other programs that do the same thing.

Oh oof. But your work is beautiful, as always.

Knowing that this reached someone who could use it, who it spoke to, is an incredible gift. Thank you.

This is so thoughtfully presented, and a wonderful opportunity to get to know these artworks in detail. Really beautiful work!

This is absolutely beautiful, and so cool! I love your artwork.

I really didn't know much about the technicalities of sound when I started but this was really impressive to click through. Amazing

Ahh! :'D Thank you very much for reading!

Thanks so much for reading, Fiz! :'3

I'm glad to hear it. And thank you!

Thank you very much!

Thank you for reading, K_Y!

Thank you very much, MindApe.

I haven't seen the new Cronenberg yet but from the synopsis I can see why you mentioned it! I should check it out sometime.

Yaay! :D I really enjoy making things with that kind of nostalgia now and then, so I'm glad it worked for other people too.

Thank you thank you caskethouse!

Congrats on your Eggbug! And thank you for playing :D

Thank you very much for playing, Fiz! ^^

It seemed like a gentler reason to start a new egg than some other options, haha.

I'm sure they're having a wonderful adventure out there, and thinking kindly of the one who clicked the buttons to raise them.

Eggbug forever! :D Thank you for playing.

Thank youuu! 🥚

Yep! That's the one! Thank you so much!

Oops! Me too. I got this jam mixed up with another one that goes until tomorrow.

(2 edits)

Thank you Houdinis for the things you do. Cool skeleton thumbs up emoji.

Yeah, you've found that there's a bit more card up under the menu bar which becomes fully visible in a locked deck.

There's a couple ways to handle this. 


One is to adjust/re-import your artwork using the normal tools.

If you hit "m" on your keyboard while in drawing mode it will hide the menu and you can adjust/re-import your background artwork to go up all the way up to the top of the card. 

If you don't have the toolbars on yet, they help a lot while the menu is hidden. Decker > Toolbars

If adjusting your artwork really won't work, then another option is to resize the deck to be shorter.

You'll need to move your current art all the way up to the top so the empty white bar is at the bottom instead. 

Then you can snip the bottom off by resizing the deck. 

(Resizing doesn't work for snipping off the top part of card, because the size of everything always starts at the top left corner)

The current method to resize a deck is by opening the .deck file in a text editor:

{deck}
version:1
card:1
size:[512,342]
name:"mydeck.deck"

At the top of your file you'll see something like this.  size: [ ] defines the size of the cards in your deck. The second number is the height.

You can reduce the height by a few pixels by lowering that second number. It's not as many pixels as you think. 15 or 16 pixels, probably.

Then reopen your file and see how it looks.

Be warned: Any artwork on the background that is outside of the new size will be lost forever, so only do this if you're sure you've prepared your project to be resized. Maybe save a second copy of your file if you're unsure. All your widgets will still exist where you left them.

Hopefully this has been helpful. :D

These brushes are so cool! This is just a doodle while I'm getting to know them but I'm really enjoying them so far! Thank you so much!

Happy 4th Birthday Decker! 

(And thank you for your kind words about Phinxel and his little book)

The group project has hit a few logistical delays, so I'll be trying to whip up a solo thing instead. :'D The group project will continue, but over a longer period of time.

I am greatly comforted by the possibility of it being okay to submit a late entry, thank you! But I'll do my best to get things done.

You've made so many neat sculptures :O 

I loved hearing the instruments too!

Cheers to finding people who want the same things you do!

And well done on all the different visual compositions for the different conversations!

Hello! Your screenshot looks really cool already! There's a lot of questions and clarifications from me for now, but I think everything you need is possible.

Part 1: The Buttons

Technically, the buttons are working as intended right now: buttons are clickable even if they're under other widgets. But there are ways to work around that.

One option (not always the best one!) is to use an on click do event handler inside of a canvas instead -- canvases can't be clicked if they're covered by something else. 

But... they also don't look like buttons unless you put an image of a button inside of them, and the cursor doesn't automatically change to make it clear that this is a clickable object like it does with buttons so it can make things confusing for players.

On the other hand, we could use something like the rect module for this. (It lives inside draggable.deck in the examples folder). 

This module gives us tools to see if two objects are overlapping, or if one is contained inside another. I suspect there would be a couple small changes to set up the MacWindow contraption to be able to be used with rect, but we can probably figure that out if this is what you want.

You can play around with this idea inside the draggable deck by putting a script like this inside a normal draggable canvas and then dragging it on top of a button in interact mode (I called it "button1" in the example). It should lock the button when you release the canvas.

on release do
 if rect.overlaps[me button1]
  button1.locked:1
  else
  button1.locked:0
 end
end

And these are the questions I have about whether or not this method with rect would work for what you want:

  • Do you want the player to be able to move the MacWindow note around freely?
  • Do you want buttons to lock (become unclickable) if the MacWindow is overlapping them?
  • Is it okay if buttons lock if they're only partially covered by MacWindow?

Part 2: The Waving Notes

I'm guessing a little bit about what you need, so let me know if I'm wrong!

One of the overlooked things about zazz.wave (I always forget this too) is that you can name the specific widgets you want to wave around, and it will only use those. The first argument inside the [] brackets is the target. When it says "card" it looks for everything that applies. Let's change it to a list of the things you want to use zazz.wave[] with instead.

So the part that currently says

zazz.wave[card b1 0.0029]
zazz.wave[card b2 0.0029]

could be changed to

zazz.wave[(musicnote1,musicnote2,musicnote3) b1 0.0029]
zazz.wave[(musicnote4,musicnote5,musicnote6) b2 0.0029]

Or whatever else you're calling your widgets. :) You'll have to write out the lists yourself but hopefully this works for you.

Part 3: Scripts after selecting an option

For the last thing, I'm assuming that you're using a Grid widget (it looks like a listbox when there's only one column/ it looks like a spreadsheet when there's multiple columns) and.... for this one I'm going to have to clarify more about what you want to do, I think!

  • Do you want a script to happen immediately when the player chooses a selection? 
  • Or do you want them to choose something on the list and then click a button to confirm?
  • Is your goal to always change the value of a slider to the same number that was selected in the grid? 
  • Or is there a variety of possible scripts you like to run depending on what your player chooses?

Any more information about what you need makes it easier to write specific examples to help. :D

I love the art in this one. 10/10 would dig out of the soil again.