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.
Entire forum
➜ MUSHclient
➜ Plugins
➜ Overriding variable in my plugin
Overriding variable in my plugin
|
Posting of new messages is disabled at present.
Refresh page
Posted by
| Gore
(207 posts) 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? | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) 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 | Top |
|
Posted by
| Gore
(207 posts) 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) 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 | Top |
|
Posted by
| Gore
(207 posts) 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? | Top |
|
Posted by
| Shadowfyr
USA (1,788 posts) 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) 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 | 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.
23,708 views.
Posting of new messages is disabled at present.
Refresh page
top