IMPORTANT UPDATE! May 12 13, 2026



Tomorrow Today Last Wednesday, on the 13th of May, the manual Patrons group (the one that gives you your green username AND access to dedicated Patrons spaces on WSL) will be has been DELETED.

This means that your access to those spaces will be has been revoked until you connect your Patreon account to WSL using the link below, which will give you access to the NEW, future-proof Patrons+++ group.

With the imminent release of ZEPPO BETA 2 - tentatively planned for released Friday today yesterday (!!) - I wouldn't dawdle... with Beta 2 (i.e. all my late nights in the past month), Zeppo has become something truly special, battle-tested and multi-user hardened in an actual production.

Yes, there will be a Reactor release eventually, and no, it won't have all the bells and whistles - those are for Patrons, because they are the ones keeping WSL afloat, which is still only barely these days...

I'd better get back to prepping that done did release then!

Thank you,

Pieter


Set the state of a setting (such as a nest) using a button script?

User avatar
JustCropIt
Fusionator
Posts: 1254
Joined: 2 years ago
Reactions score: 296
Has thanked: 265 times
Been thanked: 286 times

Set the state of a setting (such as a nest) using a button script?

#1

Unread post by JustCropIt »

Let's say I have tool, any tool really, and I've added a "nest" to it using a custom LabelControl or NestControl called that I named...CustomNest.

I can set the state of the nest (opened or closed) by a simple expression like CustomNest == 0 (for closed) or CustomNest == 1 (for opened). That makes sense to my feeble brain.

But how (if possible... which ChatGPT believes it's not... though I don't trust it in this case...) would one go about setting the state of that nest using a script on a custom button control (that is on the same node). That is, clicking the button will set the nest to the closed state (or the open state if that's what the script is set up to do)?

For full transparency here... I'm not really using a button control but rather the snazzy new v20 INPS_ExecuteOnChange thingie.... but the principle should be the same (AFAIK).

by ShadowMaker SdR » 1 year ago

I am not 100% sure, but I think == is used for checking values i.e. iff something == something then etc, but to set the value you use a single =
But I could be wrong about this. I am a bit confused, because I seem to recall you opening and closing nests in almost every tool you've created so what's diffent in what you're trying to achieve here?

Go to full post

User avatar
Davy Alves
Fusioneer
Posts: 83
Joined: 2 years ago
Reactions score: 4
Real name: Davy Alves
Mood:
Has thanked: 2 times
Been thanked: 2 times

Re: Set the state of a setting (such as a nest) using a button script?

#2

Unread post by Davy Alves »

I believe a button only outputs 0 but you could create a function with an if statment that onClick outputs 1 and an else to return 0. To be able to achieve that you would have to create a variable and link it to your button.

Sorry I should provide you with the solution but everything is coming from my big head and I only know Python. I can try to get it done in Lua once I'm in front of a computer.


User avatar
JustCropIt
Fusionator
Posts: 1254
Joined: 2 years ago
Reactions score: 296
Has thanked: 265 times
Been thanked: 286 times

Re: Set the state of a setting (such as a nest) using a button script?

#3

Unread post by JustCropIt »

Davy Alves wrote: 1 year ago

I believe a button only outputs 0 but you could create a function with an if statment that onClick outputs 1 and an else to return 0. To be able to achieve that you would have to create a variable and link it to your button.

I can check the "state" of a setting using tool.NameOfaSetting[comp.CurrentTime] so I was thinking (being a non coder) that using that I should also be able to set the state. I have a script that checks the output of a MultiButtonControl and then (using an if then thingie) sets some attributes on a few settings and that's working fine. So checking the "state" of a setting seems to work fine, but I can't figure out how to set the "state" of a similar setting.

I would think something like this could work (which, when clicked, would close my custom nest depending on the output of another setting):

  1. if tool.NameOfaSetting.CurrentTime] == 0 then -- some setting like a MultiButtonControl or another nest
  2.     tool.CustomNest.CurrentTime] == 0 -- my custom nest
  3. end

But nope.


User avatar
ShadowMaker SdR
Fusionator
Posts: 2085
Joined: 11 years ago
Reactions score: 98
Has thanked: 6 times
Been thanked: 65 times

Re: Set the state of a setting (such as a nest) using a button script?

#4

Unread post by ShadowMaker SdR »

I am not 100% sure, but I think == is used for checking values i.e. iff something == something then etc, but to set the value you use a single =
But I could be wrong about this. I am a bit confused, because I seem to recall you opening and closing nests in almost every tool you've created so what's diffent in what you're trying to achieve here?


User avatar
Davy Alves
Fusioneer
Posts: 83
Joined: 2 years ago
Reactions score: 4
Real name: Davy Alves
Mood:
Has thanked: 2 times
Been thanked: 2 times

Re: Set the state of a setting (such as a nest) using a button script?

#5

Unread post by Davy Alves »

If you want to use button you could create 2 similar buttons. Inside the user control of these 2 buttons you add IC_Visible = false for 1 and IC_Visible = true for the other. Now if you create an expression inside Inputs = ordered(), you can toggle btw both of then. The 0 and 1 inside the Inputs will change them from true to false. Pretty sure it works.


User avatar
Davy Alves
Fusioneer
Posts: 83
Joined: 2 years ago
Reactions score: 4
Real name: Davy Alves
Mood:
Has thanked: 2 times
Been thanked: 2 times

Re: Set the state of a setting (such as a nest) using a button script?

#6

Unread post by Davy Alves »

sorry I should have finished. with 2 bottons created, you can now add a Label and add an expression to it to close and open using the 2 bottons. 1 will always open and the second will always close it.


User avatar
JustCropIt
Fusionator
Posts: 1254
Joined: 2 years ago
Reactions score: 296
Has thanked: 265 times
Been thanked: 286 times

Re: Set the state of a setting (such as a nest) using a button script?

#7

Unread post by JustCropIt »

Thanks @Davy Alves for helping out but it seems @ShadowMaker SdR cracked it (for me).

ShadowMaker SdR wrote: 1 year ago

I am not 100% sure, but I think == is used for checking values i.e. iff something == something then etc, but to set the value you use a single =
But I could be wrong about this. I am a bit confused, because I seem to recall you opening and closing nests in almost every tool you've created so what's diffent in what you're trying to achieve here?

Woop! Yep. That was it. Using a single = for setting the "state" worked. Ah, the struggles of not really knowing the basics of things.

It's like I always say, quietly to myself with clenched fists: Live and eventually, hopefully, maybe, perhaps, don't bet on it but who knows, possibly learn!

Now with my confusion out of the way, let's tackle yours:

On a general level I wanted to know how to do it since I've been messing around with the INPS_ExecuteOnChange thing. I know how simple expressions work (which is what I'm using, as you say, in probably every macro I've ever done). But scripts works differently and I find myself not being able to do even the most simple things. You know, due to a lack of coding skills.

Specifically by opening/closing the nest using a INPS_ExecuteOnChange on a MultiButtonControl I've gotten a bit more control over when that happens vs doing it using an expression like I usually do. At least I think I have more control:) Maybe I could get the thing I was trying to achieve to work using expressions (though I haven't been able to yet).

Basically using expressions to toggle nests has been fine but INPS_ExecuteOnChange has opened up some opportunities where expressions has not been working out for me.

I'll try to make sure to point out exactly where I used the thing (it's not super obvious) when I share my next macro (which is doing some "fancy" UI stuff using INPS_ExecuteOnChange).


User avatar
Joseuurdaneta
Posts: 6
Joined: 1 year ago
Reactions score: 0
Has thanked: 10 times
Been thanked: 2 times

Re: Set the state of a setting (such as a nest) using a button script?

#8

Unread post by Joseuurdaneta »

Hey! To get that output you can use:

Code: Select all

if tool:GetInput("CurrentInput_ID") == 0 then

  tool:SetInput("NestInput_ID", 0)

elseif tool:GetInput("CurrentInput_ID") == 1 then

  tool:SetInput("NestInput_ID", 1)
end

(This code works if the nest control is in the same node)
Swap out "CurrentInput_ID" with the ID of the input where you’re running the script.
Swap out "NestInput_ID" with the ID of the nest you want to tweak.

Btw, I’m super grateful for the tools you’ve created—they’ve been a huge help. If you run into any issues with the code, just let me know.


User avatar
JustCropIt
Fusionator
Posts: 1254
Joined: 2 years ago
Reactions score: 296
Has thanked: 265 times
Been thanked: 286 times

Re: Set the state of a setting (such as a nest) using a button script?

#9

Unread post by JustCropIt »

Joseuurdaneta wrote: 11 months ago

Hey! To get that output you can use:

I already got it "working", @ShadowMaker SdR pointed me in the right direction highlighting just how much, on a basic level, I suck at scripting:)

Basically I used == when I should have used =. But still, thanks for the... Input!

Joseuurdaneta wrote: 11 months ago

Btw, I’m super grateful for the tools you’ve created—they’ve been a huge help.

Always happy to hear my macros are getting some use, and the "thumbs up" are seen, appreciated and makes my day a little brighter<3