Login
Community
DARK THEME

Buttons?

You might have seen a lot of button tools like mine.But there's something wrong,they can't run functions that are big or functions that are in big file sized games.They can run functions like score += 1,score -= 1 or score = 90 but cannot run functions like if selected == 1 then selected = 2 elsif selected == 2 then selected = 1 end.I've been having these problems in making a button tool.

This will last forever, in my opinion. And what is this condition for?

if selected == 1 then selected = 2 elsif selected == 2 then selected = 1 end

I understand that it is necessary that if the "selected" variable has a value of 1, then it must have a value of 2. And vice versa. But with this code in the console, this variable will be unpredictable: either 2 or 1.

I quite don't understand what the problem is. Can you clarify it or maybe build an example showing how it goes wrong with a large function? The size of the function shouldn't matter.

Like a button that creates a bunch of particles or just changing the game mode to playing.

Here is an example with keys: how to activate or deactivate something by pressing a single P key. Maybe it will help somehow if you do the same, just for the mouse.

local prP = keyboard.press.P

local relP = keyboard.release.P

activator = false

keyP // 0 or 1

if prP and keyP == 0 then activator = true end

if relP and activator == true then keyP = 1 end

if prP and keyP == 1 then activator = false end

if relP and activator == false then keyP = 0 end

Can't look into the details right now (on the phone), but maybe have a look at the example I did a while ago:

https://microstudio.dev/projects/spritebuttons/code/

I'm using function calls too and had no problems so far.


Live Long And Tinker

Might be my laptop.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community