Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Else/If statements issue

Else/If statements issue

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Traz   (31 posts)  Bio
Date Mon 05 Mar 2018 01:53 AM (UTC)
Message
So I'm having an issue with a script and I'm not sure what's wrong. I've tried a few different formats but to save space I'm only going to share the first one because none of my transmutations worked anyways.


require "wait"
  if @Ki <= 100000 else
  if @Pl <= 500000 then
  if lastTriggerTime == nil or os.time () - lastTriggerTime >= 10 then
wait.make (function ()
  lastTriggerTime = os.time ()
Execute ("nmoff")
wait.time (10)
Execute ("senzu")
wait.time (2)
Execute ("nmon")
end)
end
end


At line 2, I get 'then' expected near 'else' but I can't for the life of me figure out how to fix it.
Top

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #1 on Mon 05 Mar 2018 03:39 AM (UTC)
Message
Please fix the code indentation so that we can better guess what you're trying to do.

What do you expect "if @Ki <= 100000 else" to do?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Traz   (31 posts)  Bio
Date Reply #2 on Mon 05 Mar 2018 04:35 AM (UTC)
Message
What I want is to check if Ki is lower than the amount OR if Pl is lower than the amount, do the actions beneath.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 05 Mar 2018 04:41 AM (UTC)
Message
In that case don't you mean:


  if @Ki <= 100000 or @Pl <= 500000 then

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Traz   (31 posts)  Bio
Date Reply #4 on Mon 05 Mar 2018 04:59 AM (UTC)
Message
That gives the error: [string "Trigger: "]:2: unexpected symbol near 'if'
Top

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #5 on Mon 05 Mar 2018 05:07 AM (UTC)

Amended on Mon 05 Mar 2018 05:14 AM (UTC) by Fiendish

Message
Traz said:

That gives


Always show the code that generates an error please. :)

Also, I absolutely hate @-notation instead of GetVariable. It frequently causes problems for new scripters because of when the @ is parsed.

What happens if you use this?


require "wait"
local Ki = tonumber(GetVariable("Ki"))
local Pl = tonumber(GetVariable("Pl"))
if (Ki <= 100000) or (Pl <= 500000) then
  if (lastTriggerTime == nil) or ((os.time() - lastTriggerTime) >= 10) then
    wait.make (function()
      lastTriggerTime = os.time()
      Execute("nmoff")
      wait.time(10)
      Execute("senzu")
      wait.time(2)
      Execute("nmon")
    end)
  end
end

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Traz   (31 posts)  Bio
Date Reply #6 on Mon 05 Mar 2018 05:14 AM (UTC)

Amended on Mon 05 Mar 2018 05:16 AM (UTC) by Traz

Message
With the new GetVariable script:
Run-time error
World: DragonBall Evolution
Immediate execution
[string "Trigger: "]:4: attempt to compare string with number
stack traceback:
[string "Trigger: "]:4: in main chunk
Top

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #7 on Mon 05 Mar 2018 05:16 AM (UTC)
Message
Traz said:


  if @Ki &lt;= 50000 or if @Pl &lt;= 500000 then




"if A or B then" not "if A or if B then"

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #8 on Mon 05 Mar 2018 05:25 AM (UTC)

Amended on Mon 05 Mar 2018 05:26 AM (UTC) by Fiendish

Message
Quote:
[string "Trigger: "]:4: attempt to compare string with number

Try it again. I think our boats crossed paths in the night. The current version uses tonumber.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Traz   (31 posts)  Bio
Date Reply #9 on Mon 05 Mar 2018 05:28 AM (UTC)
Message
It started working when I took the second 'if' out of line two, that was my fault.

Thanks for the help you guys. I just did a stupid.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #10 on Mon 05 Mar 2018 05:32 AM (UTC)
Message
Traz said:

That gives the error: [string "Trigger: "]:2: unexpected symbol near 'if'


You probably saw:


  if @Ki <= 100000 or @Pl <= 500000 then


But decided to ignore that and typed:


  if @Ki <= 100000 or if @Pl <= 500000 then

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


29,765 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.