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 ➜ Lua ➜ How to use CallPlugin with gmcpval

How to use CallPlugin with gmcpval

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


Posted by Whininguser   Canada  (30 posts)  Bio
Date Thu 17 Nov 2011 12:43 AM (UTC)

Amended on Thu 17 Nov 2011 12:56 AM (UTC) by Whininguser

Message
The client I'm using is right on Aardwolf's homepage.

If I ran this:

print(CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","char.vitals.hp"))

The output would be 0 100, and 100 is my hp. But how can I store this 100 in a script that's not a plugin? I tried doing s = (CallPlugin...) and print(s), and it simply printed 0.

Thanks for any help.
Top

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #1 on Thu 17 Nov 2011 02:29 AM (UTC)

Amended on Thu 17 Nov 2011 02:52 PM (UTC) by Fiendish

Message
instead of s = (CallPlugin...) do
err,s = CallPlugin...
to get the second returned value put into s instead of the first.

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

Posted by Whininguser   Canada  (30 posts)  Bio
Date Reply #2 on Thu 17 Nov 2011 03:42 AM (UTC)

Amended on Thu 17 Nov 2011 04:13 AM (UTC) by Whininguser

Message
I hardly know any Lua, so could you elaborate?

I just tried

err,s = (CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","char.vitals.hp"))

and print(s) showed nil.

I must be doing something wrong, but I have no idea what it is. More help please.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 17 Nov 2011 04:28 AM (UTC)
Message
Lose the brackets around CallPlugin. That forces Lua to throw away all returned values except the first. For example:


function foo ()
  return 1, 2
end 

a, b = foo ()

print (a, b)   --> prints: 1, 2

a, b = (foo ())

print (a, b)   --> prints: 1, nil


- Nick Gammon

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

Posted by Whininguser   Canada  (30 posts)  Bio
Date Reply #4 on Thu 17 Nov 2011 04:33 AM (UTC)
Message
Got it. Thanks guys.
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.


17,478 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.