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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Overriding variable in my plugin

Overriding variable in my plugin

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


Posted by Gore   (207 posts)  [Biography] bio
Date Mon 05 Dec 2005 08:58 PM (UTC)
Message
After I split up my plugin into 20 different files or so, I kept getting this error message

Line 218: overwriting existing variable contents (var_pipe_elm)


when trying to load that variable from the state file, after I set the variable while it's loaded. Any ideas?
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 05 Dec 2005 09:42 PM (UTC)
Message
You must have it declared in more than one place. For example, once in the plugin and once in the state file.

- Nick Gammon

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

Posted by Gore   (207 posts)  [Biography] bio
Date Reply #2 on Mon 05 Dec 2005 09:59 PM (UTC)
Message
I tried deleting the state file to see if that would solve the problem but it didn't.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Mon 05 Dec 2005 11:34 PM (UTC)

Amended on Mon 05 Dec 2005 11:35 PM (UTC) by Nick Gammon

Message
You need to delete the variable from the plugin file. This plugin will reproduce the problem:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Tuesday, December 06, 2005, 11:15 AM -->
<!-- MuClient version 3.71 -->

<!-- Plugin "variabletest" generated by Plugin Wizard -->

<muclient>
<plugin
   name="variabletest"
   author="Nick Gammon"
   id="d2be8865570f7729bd130584"
   language="Lua"
   purpose="tests a problem Gore has"
   save_state="y"
   date_written="2005-12-06 11:14:46"
   requires="3.60"
   version="1.0"
   >

</plugin>

<!--  Aliases -->

<aliases>
  <alias
   match="target *"
   enabled="y"
   variable="victim"
   send_to="9"
   sequence="100"
  >
  <send>%1</send>
  </alias>
</aliases>


<!--  Variables  -->

<variables>
  <variable name="victim">Gore</variable>
</variables>

</muclient>


Note how variable "victim" is declared in the plugin itself as Gore? Now if the plugin changes that, in this case you could do it by typing "target Nick", then it now has "Gore" in the plugin file, and "Nick" in the state file. Then you get the warning about overwriting a variable.

Basically variables that might change should not be declared in the main plugin file.

- Nick Gammon

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

Posted by Gore   (207 posts)  [Biography] bio
Date Reply #4 on Tue 06 Dec 2005 10:44 AM (UTC)
Message
So basically, any variable I might change I would manually put into the state file or? Do I just Setvariable "whatever", "whatever" without any sort of declared variable, and would it automaticly make it in the state file?
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #5 on Tue 06 Dec 2005 06:48 PM (UTC)
Message
As long as the plugin itself has the save_state field set to "y", then any use of setvariable will automatically save that value into the state file when it happens. Same with setting a variable through aliases, etc.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Tue 06 Dec 2005 07:51 PM (UTC)
Message
How would you manually put it into the state file?

Shadowfyr is right, simply set the variable, all variables in the plugin are saved to the state file. That is, all variables that exist at save time, not just the ones declared in the plugin file.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


21,462 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]