zaniac10
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 10000 |
|
|
| 16 May 2017 02:58 AM |
example:
---------
active = false
while active == true do --code end
active = true
---------
the while code will not activate, since the "active" variable is being set to true AFTER the loop, is there any way to go around this? i.e. make the 'while' loop activate whenever and whereever the variable is set to true? |
|
|
| Report Abuse |
|
|
|
| 16 May 2017 03:13 AM |
It instantly sets active from false to true so it would work?
R$30,911 | aka CyanSparkleTime \ Evercyan \ Sparklexity |
|
|
| Report Abuse |
|
|
zaniac10
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 10000 |
|
|
| 16 May 2017 07:23 AM |
| not the case for me, i'm doing ## ## with idle/attack mode and i have a while loop along the lines of "while idle == true" and "while attack == true" and in the end of the attack loop (when player dies, leaves game etc) it sets attack to false and idle to true, and because the attack loop is further in the script (in terms of lines) than the idle loop, setting the idle variable to true does not trigger the idle loop, i'll elaborate more if i need to |
|
|
| Report Abuse |
|
|
zaniac10
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 10000 |
|
|
| 16 May 2017 07:25 AM |
| hashtags at the begnning is "an artificial intelligence" |
|
|
| Report Abuse |
|
|
zaniac10
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 10000 |
|
|
| 16 May 2017 07:38 AM |
for example this will not print anything
active = false
while active == true do wait(.1) print('test') end
active = true |
|
|
| Report Abuse |
|
|
|
| 16 May 2017 09:20 AM |
local active = false
function loop() print("activated")
while (active) do print("running") wait(1) end
print("deactivated") end
function turnOn() if (not active) then active = true spawn(loop) end end
function turnOff() active = false end |
|
|
| Report Abuse |
|
|