A very quick question about Lua and variable reassignment
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: A very quick question about Lua and variable reassignmen
Maybe the original question was partially answered, but i'll ask anyway, for my own understanding : why would you want to change the value of a certain variable through a setter function ? Or were you just wondering if it was possible to do so ?
- dizzykiwi3
- Citizen
- Posts: 58
- Joined: Tue Jan 14, 2014 2:03 am
Re: A very quick question about Lua and variable reassignmen
That still doesn't seem to be working... I'm testing it in the local console of Zerobrane Studio
To be specific I'm trying to do a function like this
val is going to be a field of a table
To be specific I'm trying to do a function like this
Code: Select all
function returntobase(val,i,base)
if val > base then
if val - i < base then
val = base
else
val = val - i
end
elseif val < base then
if val + i > base then
val = base
else
val = val + i
end
end
end
- DaedalusYoung
- Party member
- Posts: 413
- Joined: Sun Jul 14, 2013 8:04 pm
Re: A very quick question about Lua and variable reassignmen
Just return the desired variable in the function.
Code: Select all
x = 5
print(x) --5
x = setvar(x)
print(x) --10
function setvar(z)
z = 10
return z
end
Who is online
Users browsing this forum: No registered users and 3 guests