Jump to content

Making a function toggle able?


Fabio(GNR)

Recommended Posts

  • Discord Moderators
EDIT: so if im right, a variable is something thats used alot? or by many scripts?

EDIT2: Or to who/what it's aimed?

EDIt3: Or something a script can recognize easily?

A variable is even a term used in basic maths at primary school

It stores a value under a name given.

ie.

  
a = 2 
b = 4 
c = a + b 
  
d = "hello" 
e = a 

you can store everything under variables, elements, object, tables, etc.

to toggle something, 50p described it pretty well. You need to set a variable to true when toggled, and perform the opposite when it's true and set it to false.

for example:

  
toggle = false 
  
function toggleTest() 
if not toggle == false then 
outputChatBox ("Toggled off.") 
toggle = false 
else 
toggle = true 
outputChatBox ("Toggled on.") 
end 
end 
addCommandHandler("toggle", toggleTest) 
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...