zub74
|
  |
| Joined: 13 Sep 2008 |
| Total Posts: 489 |
|
|
| 08 Jun 2014 05:04 PM |
if workspace.Cash.Value>= workspace.Limit.Value then --stuff
else while wait(1) do workspace.Cash.Value=workspace.Cash.Value+workspace.Rate.Value until workspace.Cash.Value>= workspace.Limit.Value end end
The until line is underlined in red. What's wrong with it? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 08 Jun 2014 05:05 PM |
repeat-until repeat workspace.Cash.blah = blh until workspace.Cash.Value >= blah |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 08 Jun 2014 05:06 PM |
repeat wait (1) workspace.Cash.Value=workspace.Cash.Value+workspace.Rate.Value until workspace.Cash.Value>= workspace.Limit.Value end end
while wait (1) do end does something every 1 second forever unless broken. |
|
|
| Report Abuse |
|
|
zub74
|
  |
| Joined: 13 Sep 2008 |
| Total Posts: 489 |
|
|
| 08 Jun 2014 05:08 PM |
| And would the script resume if the cash value was once again lowered below the limit value? |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 08 Jun 2014 05:08 PM |
No, that's where the while loop comes in
while wait () do repeat -- stuff until -- condition end |
|
|
| Report Abuse |
|
|
zub74
|
  |
| Joined: 13 Sep 2008 |
| Total Posts: 489 |
|
|
| 08 Jun 2014 05:15 PM |
| It doesn't stop upon reaching the condition. |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 08 Jun 2014 05:18 PM |
What? It should!
Describe in detail what happens with these added print statements:
while wait () do print 'checking' repeat --stuff print 'adding' until --condition print 'achieved!' end |
|
|
| Report Abuse |
|
|
|
| 08 Jun 2014 05:19 PM |
while (workspace.Cash.Value < workspace.Limit.Value) and Wait(1) do workspace.Cash.Value = workspace.Cash.Value+workspace.Rate.Value end |
|
|
| Report Abuse |
|
|
BladeXE
|
  |
| Joined: 22 Dec 2012 |
| Total Posts: 3857 |
|
|
| 08 Jun 2014 05:20 PM |
repeat --code until --statement
or While statement~=bool do --code end |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 08 Jun 2014 05:21 PM |
| Knightmare's method is better because if Cash.Value is more than limit.Value before hand, it won't add any/ |
|
|
| Report Abuse |
|
|
|
| 08 Jun 2014 05:24 PM |
| You might want to set it to the limit afterwards as it could go above it if the limit isn't divisible by the rate. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 08 Jun 2014 05:26 PM |
wow, I'm stupid. Knightmare's is a great method. |
|
|
| Report Abuse |
|
|