|
Post by Tharak on Sept 25, 2019 4:08:48 GMT
Hello! I've been struggling with something so simple lately and can't figure out what the issue is, if anyone could shine a light on me. Spent more time on this than some other more advanced features haha I'm stuck! local k = 0; local c_quest = 0;
function testCounter(k) k = k + 5; end
testCounter(c_quest); toast(c_quest);
This is showing a 0 on the toast. Shouldn't the function parse the variable k as c_quest and increase it? Thank you!
|
|
|
Post by AnkuLua on Sept 25, 2019 10:31:49 GMT
You should return the value and assign the returned value to a variable.
local k = 0; local c_quest = 0;
function testCounter(k) k = k + 5; return k end
c_quest = testCounter(c_quest); toast(c_quest);
|
|
|
Post by Tharak on Sept 25, 2019 16:21:41 GMT
You should return the value and assign the returned value to a variable. local k = 0; local c_quest = 0;
function testCounter(k) k = k + 5; return k end
c_quest = testCounter(c_quest); toast(c_quest);
Omg! I tried with the return before but it didn't work, assign to a variable was the issue! Thank you!
|
|
|
Post by Tharak on Sept 26, 2019 7:34:47 GMT
You should return the value and assign the returned value to a variable. local k = 0; local c_quest = 0;
function testCounter(k) k = k + 5; return k end
c_quest = testCounter(c_quest); toast(c_quest);
Actually this is kind of defeating the purpose of the counter function. Is there no way better to make a simple counter function? Because if I have to type c_quest = testCounter(_cquest); after every counter then its easier to just type c_quest = c_quest + 5; instead of the whole thing. I'm just trying to be as efficient as possible hehe
|
|
|
Post by AnkuLua on Sept 26, 2019 8:00:39 GMT
Don't really catch what you want to do. But, c_quest = c_quest + 5 is the simpler way.
|
|