|
The functions must use the same variable values even if they are changed during the function's job.
Example
function a() -- because the problem is in the functions
print(b)
-- (had to make this a comment due to the under 13 censorship) [put in this line "wait" then "1" in "()"]
print(b)
end
b = 1
spawn(a) -- making this happen in a thread because it is a part of the problem
wait(0.5)
b = 2+3
Results
How is it
1
5
How should it be
1
1
I think it should happen because now there are some complications caused by this. After this happening the problems would be solved and some new but easier problems would happen.
Because of the current problem this simple concept became unnecesarily complicated to make. https://forum.roblox.com/Forum/ShowPost.aspx?PostID=194051652 |
|
|
|
"Wrong Subforum"
What is this subforum for then? It does not have to be a suggestion for the normal Lua, it can also be for the ROBLOX Lua. |
|
ThrowYouJoin Date: 2015-07-23 Post Count: 3764 |
You go to the subforum "Scripters" for this stuff
|
|
|
|
"You go to the Scripter subforum for this stuff"(you probably know why changed)
No. This is a suggestion for ROBLOX.
"https://forum.roblox.com/Forum/ShowPost.aspx?PostID=193916819
Read the third post"
This will work with common routines(this probably too) too. |
|
|
|
I hope there will not be any more people who wrongly think this thread belongs to the scripter subforum. |
|
|
|
How should it be 1 1 if you're changing b to 5.... |
|
|
Lua already has functions.
IronForumer | ⚡ TEAM INSTINCT ⚡
|
|
|
" How should it be 1 1 if you're changing b to 5.... "
Keep the old value. |
|
|
Am I the only one who wants easier developing? |
|
|
The code works fine and you just need to learn basic programming principles. ROBLOX isn't going to modify Lua's logic because of your nonsensical needs.
No support. |
|
httpwebJoin Date: 2008-08-13 Post Count: 613 |
Support.
|
|
|
"nonsensical needs"
Did you read my reasoning or forgot it? I showed the sense. |
|
|
I read it, it's just your reasoning is stupid. Expecting to index a variable (which I might remind you is part of a table called an environment) and getting an old value isn't right. If the environment changes, you'll get a different value. If you want to keep an old environment, look into setfenv/getfenv. |
|
|
The reason that your code is not working is because of the thread scheduler. After you spawn function a, function a prints the value of b, then 0.5 seconds are waited before changing the value of b to 5, but the spawned function a waits 1 second (which is more than .5 seconds) to print the value of b again, so by the time the function a prints the value of b, the value of b has already changed to 5.
I believe what you are trying to accomplish is using scope: http://wiki.roblox.com/index.php?title=Scope
B.T.W: Why would you think that wait(1) is inappropriate for kids under 13 years old???
|
|
|
Sorry, link to roblox wiki didn't work because roblox annoyingly changes http liks to https. Here is the working like:
wiki.roblox.com/index.php?title=Scope
|
|
|
"I believe what you are trying to accomplish is using scope" Now I am thinking about making a thread about the most forgotten stuff in Lua. @my idea No support, use local variables. "B.T.W: Why would you think (this) is inappropriate for kids under 13 years old???" Me? Me?! The censorship for under 13 players thinks so! |
|
|
I am very doubtful that roblox has rules about censoring wait(1), so please post a link to your source for this information. |
|
|
"I am very doubtful that roblox has rules about censoring wait(1), so please post a link to your source for this information."
Under 13 players still have got a whitelist(except liars who have blacklist) even though it is harder to notice now! Somehow it does not work. And do not except everyone over 12 to have their ages set to over 12!
According to the new Terms of Service you must not ever lie about your age, so trying to verify my information by yourself is not going to be simple. And you have to prepare your parent(or yourself if you are over 17) to leave a voicemail to get back to your age.
IT WAS NOT ME, IT WAS THE WHITELIST ON THE TWENTIETH OF JULY. IF YOU WANT PROOF IT WAS LIKE THIS(WHICH YOU SHOULD NOT EXCEPT AT ALL) THEN LOOK AT THESE: https://web.roblox.com/1-item?id=465008000 https://web.roblox.com/2-item?id=465008123. IF YOU STILL DO NOT BELIVE ME THEN LEAVE THIS THREAD UNLESS YOU HAVE GOT SOMETHING ELSE TO ADD.
|
|
|
|