I’m not sure what you want to do. Do you want to return a value or change a variable?
You can create functions that are conditions, actions, expressions, expression & condition or action with operator
Expressions return values, conditions return true/false which is used to decide whether actions get triggered. Actions are just that actions.
You can add a parameter as type “scene variable” and then copy the variable to another variable, modify that variable and then copy that variable back to the variable in the parameter.
It all depends on what you want to do. Instead of a standalone function. You also create behaviors that you assign to objects just like the “platform” or draggable" behaviors. That’s a bit more complex.
I want it to be like, you select a variable in the events window, let’s say I have 5 variables, for each of them I need it so that when I select a particular variable ingame, it changes the text to the last pressed key, easy but annoying to do manually. But I want it all to be with 1 event for each variable (because it takes alot of events to do all the mouse button clicks)
Honestly I have no idea how to explain
Logic would be like this
Events, conditions: cursor on object “”, actions: extension, select any variable.
Wanted outcome, ingame with these events, if the cursor is on specified object (conditions don’t matter, just the logic) and when any keyboard key is pressed, the text of the selected variable will change to last pressed key, or for mouse buttons I also have built in logic for that, the variables will be set to “leftclick” for left click, “rightclick” for rightclick, same goes for all other available mouse buttons, but the outcome is just confusion, because I don’t know how to make it like this, I could do it manually, but that takes so many events for the logic of all mouse buttons to work.
I might be closer to understanding. Do you want a sort of last mouse condition similar to last key pressed expression? What would you do if multiple keys were pressed? Either the first or last could have priority or I guess you could use an array and add all of the actions. IDK.
You would still need to do something with the information in the variable. It kind of seems like you’re adding a middle man or extra step. I don’t see your vision.
A different direction might be to include the actions in the function instead of returning a variable and then have to do things based on the variable. Whether that would be setting an objects variable or moving the object or deleting it. If you add an object parameter then you could make changes directly to the object.
What exactly do you want this for? What is supposed to happen when one of the buttons is clicked?
They currently work like how controls are supposed to, it’s just that they take forever to make another control. I can show you pictures of the events I have to use right now for inputting controls, they’re hella annoying - also I don’t need a last mouse button pressed expression, I have already set that up
And doing this over and over again is so time consuming, I want to be able to do all keyboard registration and mouse in 1 event, but I would need to make it a selectable variable in the event s window for it to be any good, but idk how to make a text go into the selected variable, I hope this gives a good understanding.
You can set a parameter to the type scene variable then copy the variable in the parameter to a variable that the function changes it and then copy that variable back to the supplied variable in the action.
If you only want to set the variable then you could skip the parameter to variable and only use the variable to parameter.
It doesn’t seem to matter what the variable is.
I don’t think it works with global variables but you can use JSON to convert the scene variable to global.
See this post
To convert a scene variable to a global variable in the scene after the function.
I don’t mean to confuse you. I kind of switched strategies. One involves using a scene variable to return the variable values and then converting the scene variable to global. I think I might have assumed you were using global variables based on the keybindChangeable variable. I apologize for that.
The other uses a text parameter to build a structure name. This is very similar to your existing events.
I think I’m making it more complex than it needs to be. I’m make assumptions because I’m not clear on the purpose. Let’s start over.
It’s tough to understand the concept from seeing snippets. There are multiple strategies. I still don’t know what you’re trying to ultimately do.
If you could either explain what the project is, post a screenshot of the game scene or a link to a playable version. Something because I don’t think we’re on the same page. To help you move this forward, I would even be willing to look at the project if you share a link to it on a file share site.
I want to help but I’m just not understanding the whole picture.
you’re checking a variable of a text object and a global keybindChangable
(I don’t know what keybindChangable is)
You’re checking keys and mouse events.
You’re setting variables based on the events
The “keybind changeable” variable isn’t irrelevant, that checks what keybind your trying to change, though. That could probably be made better, but that’s not the problem. But I’m gonna think about the best way to explain this.
(Maybe this could help you understand, it would be like how normal actions are, you select a text of any type, then the action will change that variable according to the wanted text)
An example would be easier for me to explain but here’s a rough idea until I have more time and my pc.
The function could be type expression and style string(text) the first event would be to set some string variable to “” to clear the previous key.
If a key or mouse button is pressed then set that variable like you do to the key or mouse action.
At the end of the function return this value
When one of the boxes that show which key/mouse is currently set is clicked then change it to “press key or mouse … something”
Set a variable like waitingForKey to true
Set a variable that you can use to reference the text object later and save the preference.
If the variable waitingForKey is true then
Action: set variable to expressionName()
Sub event: if the previous variable ≠ “”
Action: set text return value under [other actions] [event functions]
You can then set the waitingForKey to false
That’s really all i have at the moment. I’m better with doing it in the app then in my head alone.
You then use the ine variable to repick the text object. Change its twxt to the value from your extension and using the previous variable set when the setting box is clicked to the new preset.
I realize this part is missing details. I don’t have everything.
Somewhere in there you need to check if another action has the key from your expression. And then decide if you’re going to overide the other preference or ask first.
You then have to update the conflicting one.
Again, an example would be an easier way for me to explain it. But that’s going to have to wait. Hopefully, I didn’t confuse the situation more.
Ok, here’s a rough mockup. The scene is just to test the extension. It’s a bit rough. There’s also an issue with the mouse click because my version will repick a setting. It’s not error free. It’s just an example.
It doesn’t save the new key or mouse click. It just changes the text object but it wouldn’t take much to have it change a structure variable. I might work on that part sometime tomorrow just to learn.
try me: It only does keyboard or mouse left or right.
source: (click green [code]button and then download zip, extract and open JSON file)
This is the extension, it currently has no parameters
This is in the scene part. Once the customizeKey variable is set to true, it triggers the function/expression until it doesn’t equal “”. The text object that is being changed has a Boolean selected set to true.