Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)
"if somethinghappened.value
specialbutton.locked:rect.overlaps[me specialbutton]
end
end"

Ok! everything are set up (with notes thing only)! But I dont understand how to make buttons unlock when the notes are overlapping them BUT are hidden since there is a button to hide and reveal notes....

I already tried different ways i couldve come up with like:

if me.show = "none"
 each button in buttonset
  button.locked:rect.overlaps[me button]0 (like i would done when unlocking a normal button to unlock it?)
 end

So i dont know...

Also a question... how would i make the window appear on each button in the same place with the same size and copying text from the previous one to everyone else on every card?.. I know it might be very hard but i have an idea to save its x and y on separate sliders and size on separate slider, and then the text saves to a special field. All of the sliders and fields for it would be on a separate card, from witch a window would take the information, but is there an easier way (if there is then please describe me only this one), if there isnt, please tell me how i can make and script the one i've come up with!

Thank you for all the hard work, I really appreciate it and will put you in the credits ofcourse, duuhh

(+1)

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.