[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Evaluating client variables in script

Evaluating client variables in script

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


Posted by Cosine_Omerta   USA  (17 posts)  [Biography] bio
Date Fri 02 Jan 2015 01:07 AM (UTC)
Message
I've been scouring the forum for a few hours, I've watched a few videos, and I can't find a solution to what I'm sure is a simple problem. I'm sorry if this is the 300th time it's been posted.

I have created a miniwindow, with a rectangle, with a hotspot mapped to that rectangle, with a simple mouseup function that sends some text to the mud. I want a client variable to be evaluated against a condition, and depending on that send various text to the mud.

Everything seems to be fine, but I cannot get the conditional statement to evaluate to anything but false.

I have a variable on the client called char_name, which is set via trigger. This works fine. I click on the variables button on the client, it says "char_name Bob", no problems there.

When I try to evaluate this in my script (which is in an xml file and added via plugins) its always false. This is the exact format I've been using in the client, and it evaluates properly there. I'm sure I'm missing some little something.


if (GetVariable("char_name") == "Bob") then
 name = "Bob"
else
 name = "Dick"
end

function mouseup (flags, hs1)
  print(name)
end --mouseup


It always prints "Dick" even though the variable is set to "Bob".
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Fri 02 Jan 2015 02:18 AM (UTC)
Message
Variables in plug-ins and the main world are in different spaces.

Template:function=GetPluginVariable GetPluginVariable

The documentation for the GetPluginVariable script function is available online. It is also in the MUSHclient help file.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Cosine_Omerta   USA  (17 posts)  [Biography] bio
Date Reply #2 on Fri 02 Jan 2015 02:34 AM (UTC)
Message
Thank you.

How do you go back the other way? Use a call in the script to set a client variable? I don't see a SetPluginVariable type function. SetVariable doesn't work.
[Go to top] top

Posted by Cosine_Omerta   USA  (17 posts)  [Biography] bio
Date Reply #3 on Tue 06 Jan 2015 09:55 PM (UTC)
Message
Maybe a different question then. When one wants to share variables between scripts and the client (to have triggers and aliases in the client, and outside scripts or plugins all using the same variable), what is the preferred method?
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Wed 07 Jan 2015 02:25 AM (UTC)
Message
Cosine_Omerta said:

Thank you.

How do you go back the other way? Use a call in the script to set a client variable? I don't see a SetPluginVariable type function. SetVariable doesn't work.


Plugins are intended to be independent of each other and the main script file. Having plugins set each others variables does not work with that design concept. So there is no SetPluginVariable function, by design.

However you can work around this by having a plugin "Execute" some thing which an alias in the main world file picks up and changes a variable. I think someone else came up with a more sophisticated method a while back as well, can't remember what it was.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Cosine_Omerta   USA  (17 posts)  [Biography] bio
Date Reply #5 on Wed 07 Jan 2015 03:36 AM (UTC)
Message
Surely people do this though. Do they just keep any associated variables/triggers/aliases in the plugin file? Then just use multiple aliases that do the same thing for different plugins?
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Wed 07 Jan 2015 05:32 AM (UTC)

Amended on Wed 07 Jan 2015 05:34 AM (UTC) by Nick Gammon

Message
I seem to have answered your original question. Is this new question (setting variables rather than reading them) mere curiosity, or do you have an application in mind?

If so, what is it?

http://xyproblem.info/

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Cosine_Omerta   USA  (17 posts)  [Biography] bio
Date Reply #7 on Wed 07 Jan 2015 09:20 PM (UTC)
Message
Sorry. Just new to mushclient and trying to figure it out. Didn't mean to be a pest.
[Go to top] 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,458 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]