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
➜ GetVariable from Plugin question
|
GetVariable from Plugin question
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Erendir
Germany (47 posts) Bio
|
| Date
| Fri 17 Sep 2010 08:26 PM (UTC) |
| Message
| The question may sound stupid, but i can't figure how to get a world variable from plugin inside?
What i do is:
1. Set variable `var` to `test` in the world properties-window
2. type `/print(GetVariable('var'))` in command input window (`/` is the script prefix)
I get `test` as expected
3. After that, i install some plugin with
<script>
<![CDATA[
Note(world.GetVariable('var'), GetVariable('var'))
]]>
</script>
4. The output i get is `nilnil`, and expected was `testnil` or `testtest`
So, what am i doing wrong? | | Top |
|
| Posted by
| Twisol
USA (2,257 posts) Bio
|
| Date
| Reply #1 on Fri 17 Sep 2010 08:29 PM (UTC) Amended on Fri 17 Sep 2010 08:30 PM (UTC) by Twisol
|
| Message
| There is actually no difference between world.SomeFunction and SomeFunction. Without going into the details, the 'world' table is basically the default context of the script.
What you want is GetPluginVariable("", "var"). Using "" as the plugin ID for GetPluginVariable tells it to check the world instead.
[EDIT]: If you want to make it slightly more obvious, you can do this:
function GetWorldVariable(name)
return GetPluginVariable("", name)
end
Note(GetWorldVariable("var"))
This doesn't change what happens, it just hides it behind a new function. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | | Top |
|
| Posted by
| Erendir
Germany (47 posts) Bio
|
| Date
| Reply #2 on Fri 17 Sep 2010 08:42 PM (UTC) |
| Message
| Oh, that's great!
Thank You for such quick response!
Another question (don't want to start other topic yet):
can I get rid of VBscript, JScript etc. examples in the help? I'm interested only in Lua examples. | | Top |
|
| Posted by
| Twisol
USA (2,257 posts) Bio
|
| Date
| Reply #3 on Fri 17 Sep 2010 08:44 PM (UTC) |
| Message
| | No, the help files are entirely static. The examples are pretty similar in each language though; the difference is usually down to syntax. And some topics don't have Lua examples, if I remember correctly. It's not that big of a deal, in my experience. :) |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | | Top |
|
| Posted by
| Erendir
Germany (47 posts) Bio
|
| Date
| Reply #4 on Fri 17 Sep 2010 08:58 PM (UTC) |
| Message
| | It's just so that in just every topic i open in the help i usually scroll down to the Lua examples, and this is really annoying. | | Top |
|
| Posted by
| Erendir
Germany (47 posts) Bio
|
| Date
| Reply #5 on Fri 17 Sep 2010 10:22 PM (UTC) |
| Message
| |
| Posted by
| Twisol
USA (2,257 posts) Bio
|
| Date
| Reply #6 on Fri 17 Sep 2010 10:37 PM (UTC) |
| Message
| Well, keep in mind: if you compile your own set of help files, you'll have to edit and recompile it every time Nick releases a new version with documentation changes.
Go to your start menu and look for an HTML Help Workshop folder. I think it comes with Windows by default, but frankly I'm not entirely sure. That's what you'd use to compile the help docs. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | | Top |
|
| Posted by
| Erendir
Germany (47 posts) Bio
|
| Date
| Reply #7 on Fri 17 Sep 2010 10:44 PM (UTC) |
| Message
| |
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #8 on Fri 17 Sep 2010 10:55 PM (UTC) |
| Message
|
Erendir said:
I'm interested only in Lua examples.
He has a point. In version 4.62 I revamped the order so that Lua comes first (and the return codes next). I agree you usually have to scroll down to find the stuff you really want.
As an example of how it will look, I re-did the online version, so check this out:
http://www.gammon.com.au/scripts/doc.php?function=ColourNote
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Erendir
Germany (47 posts) Bio
|
| Date
| Reply #9 on Fri 17 Sep 2010 11:20 PM (UTC) |
| Message
| Exactly what i mean!
Maybe - i'm not sure - `Return value` before `Lua example` would be better. | | Top |
|
| Posted by
| Twisol
USA (2,257 posts) Bio
|
| Date
| Reply #10 on Fri 17 Sep 2010 11:21 PM (UTC) |
| Message
| Ahh, good idea Nick!
I agree, moving the return value section to before the examples would be a lot better. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #11 on Fri 17 Sep 2010 11:45 PM (UTC) |
| Message
| | Check it out now. |
- 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.
41,230 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top