This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
jamesscape2's profile picture

[lua][question] how change the value of a variable

Started by jamesscape2, 26 April 2012 - 11:39 AM
jamesscape2 #1
Posted 26 April 2012 - 01:39 PM
for my program i have the default value of my variable set to 'false'

but in my code i want it to be set to 'true' if a certain condition is meet

eg. if the correct username is enter
set USERCORRECT to true
end

that i basicly what i what the code to do but i dont know what to really right to do that
at the moment i have this

if inputUser == user then
print(" Username correct ")
setUsercorrect = true
end

will this work

if not what shoudl i right instead to make it work

Thanks.
PyromancerVx #2
Posted 26 April 2012 - 02:14 PM
That should work, Im not a pro though.
jamesscape2 #3
Posted 26 April 2012 - 03:15 PM
Thank anyway but i have done it a different way using functions and stuff

but to does work
Kolpa #4
Posted 26 April 2012 - 03:26 PM
for my program i have the default value of my variable set to 'false'

but in my code i want it to be set to 'true' if a certain condition is meet

eg. if the correct username is enter
set USERCORRECT to true
end

that i basicly what i what the code to do but i dont know what to really right to do that
at the moment i have this

if inputUser == user then
print(" Username correct ")
setUsercorrect = true
end

will this work

if not what shoudl i right instead to make it work

Thanks.
its realy easy the point is u are even doing to much work :)/>/>

Declaring stuff
inputUser = read()
user = "test"
Usercorrect = false

set to correct or not :)/>/>

if inputUser == user then
print(" Username correct ")
Usercorrect = true
end