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.
 Entire forum ➜ MUSHclient ➜ Lua ➜ Variables wiped on Reinstall

Variables wiped on Reinstall

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


Posted by Mat   (14 posts)  Bio
Date Tue 27 May 2014 01:54 PM (UTC)
Message
I modified the Reconnect plugin to fit the mud I play, but when I SetVariable and Reinstall the plugin, the variable is no longer there. Before I Reinstall GetVariable does bring them back, but Reinstall for whatever reason wipes the variables clean.
On my VBScript plugin the variables remain throughout Reinstall, so I can't understand what I'm doing wrong here.
Please let me know if you know what it is:


<?xml Version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient [
  <!ENTITY interval "5" >
  <!ENTITY quit_command "quit" >
  <!ENTITY Connect_command "connect" >
  <!ENTITY noconnect_command "NOCONNECT" >
]>

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

<!--
1. Change the entity above "interval" to be the number of seconds
between retries.

2. Change the entity above "quit_command" to be the command you
type to quit (eg. quit, QUIT, @quit or whatever)

3. Change the entity above "Connect_command" to be the command you
type to enable connection checking.

4. Change the entity above "noconnect_command" to be the command you
type to disable connection checking.

-->

<muclient>
<plugin
   name="Reconnecter"
   author="Nick Gammon"
   id="dc8cb4a314674db813c12c90"
   language="Lua"
   purpose="Reconnects when disconnected"
   date_written="2007-12-12 11:30:00"
   requires="3.80"
   version="2.0"
   >
<description Trim="y">
<![CDATA[
This plugin will automatically reconnect you when you are disconnected, at a user-configurable interval (say, every 5 seconds)
]]>

Reconnecter:Help - this Help screen

&Connect_command;  - enable reconnection (eg. after using &noconnect_command;)

&noconnect_command; - disable reconnection (eg. if you are leaving the PC)

</description>

</plugin>


<!--  Timers  -->

<timers>
  <timer name="ConnectCheckTimer" 
         script="OnConnectCheckTimer" 
         second="&interval;" 
         active_closed="y" 
         enabled="y">

  </timer>
</timers>

<!--  Aliases  -->

<aliases>
  <alias
   script="OnQuit"
   match="&quit_command;"
   enabled="y"
  >
  </alias>

  <alias
   script="OnConnect"
   match="&Connect_command;"
   enabled="y"
  >
  </alias>
  <alias
   script="OnNoConnect"
   match="&noconnect_command;"
   enabled="y"
  >
  </alias>
  <alias
   script="setCharNum"
   match="setchar *"
   enabled="y"
  >
  </alias>
  <alias
   script="getCharNum"
   match="getchar"
   enabled="y"
  >
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[
--Set your character name, password and the number selection for your char on login

local charName, charPass, charNum
charName = "***"
charPass = "***"
charNum = 2

function setCharNum (name, line, wildcards)
	charNum = wildcards[1]
	Note ("Character Number set to: " .. charNum)
	SetVariable ("char", charNum)
end

function getCharNum (name, line, wildcards)
	Note(charNum)
	for k, v in pairs (GetVariableList()) do 
	    Note (k, " = ", v) 
	end
end


local retry, did_quit, temp

retry = 0
did_quit = false

function OnConnectCheckTimer (sName)
  
  --
  --  If currently connecting, leave it to do that ...
  --
  
  if GetInfo (107) then 
    return
  end -- if
  
  
  --
  --  If currently connected, we don't need to check any more
  --
  
  if IsConnected () then
    Note "World is connected, disabling disconnection check"
    EnableTimer (sName, false)
    return
  end -- if
Top

Posted by Mat   (14 posts)  Bio
Date Reply #1 on Tue 27 May 2014 01:54 PM (UTC)
Message

  
  --
  --  If deliberate quit, we don't need to check any more
  --
  if did_quit then
    Note "Deliberate quit, disabling disconnection check"
    EnableTimer (sName, false)
    return
  end -- if
  
  --
  --  OK, we need to Connect now ...
  --
  
  retry = retry + 1
  
  Note ("Connecting to world, attempt # " .. retry)
  Connect ()

end -- function

function OnPluginDisconnect ()
  --
  --  If deliberate quit, we don't need to enable the connection check
  --
  
  if did_quit then  
    return
  end -- if
  
  --
  --  We have been disconnected, we need to try connecting again
  --

  Note "Connection checker enabled"
  EnableTimer ("ConnectCheckTimer", true)
  
end -- function

function OnPluginConnect ()
  
	--
	--  Now we are connected, no need to keep trying to Connect
	--
	retry = 0
	EnableTimer ("ConnectCheckTimer", false)
	if IsTrigger("logging_in") == 0 then
		EnableTrigger ("logging_in", true)
	else
		AddTrigger("logging_in", "Players Online: d*", "", 33, custom_colour.Custom15, 0, "", "loggingIn")
	end
	if IsTrigger("logging_in2") == 0 then
		EnableTrigger ("logging_in2", true)
	else
		AddTrigger("logging_in2", ".*That character is already playing.", "y", 33, custom_colour.Custom15, 0, "", "")
	end
	if IsTrigger("logging_in3") == 0 then
		EnableTrigger ("logging_in3", true)
	else
		AddTrigger("logging_in3", ".*You already have a different character in the game.", "", 33, custom_colour.Custom13, 0, "", "addCharNum")
	end
	if IsTrigger("logging_in4") == 0 then
		EnableTrigger ("logging_in4", true)
	else
		AddTrigger("logging_in4", ".*That is not an option!", "", 33, custom_colour.Custom13, 0, "", "resetCharNum")
	end
	--
	--  No deliberate quit yet
	--
	  
	did_quit = false
    
end -- function

function loggingIn (name, line, wildcards)
	EnableTrigger ("logging_in", false)
	EnableTrigger ("logging_in2", false)
	EnableTrigger ("logging_in3", false)
	EnableTrigger ("logging_in4", false)
	Send (charName)
	Send (charPass)
	
	Send (charNum)
end

function addCharNum (name, line, wildcards)
	charNum = charNum + 1
	SetVariable ("char", charNum)
end

function resetCharNum (name, line, wildcards)
	charNum = 1
	SetVariable ("char", charNum)
end

function OnPluginInstall ()
  DoAfterNote (1, "Connection checker installed.")
  DoAfterNote (1, "")
  DoAfterNote (1, "Use 'setchar *' to set the character number to login to.")
  
	for k, v in pairs (GetVariableList()) do 
	    Note (k, " = ", v) 
	end
	temp = GetVariable ("char")
	if temp ~= charNum and temp ~= nil then
		charNum = temp
	else
		SetVariable ("char", charNum)
	end
	SetVariable ("char2", "blah")
	SetVariable ("char3", "blah2")
	SetVariable ("char4", "blah3")
	SetVariable ("char5", "blah4")
	Note(temp)
	Note(charNum)
end -- function

function OnPluginEnable ()
	for k, v in pairs (GetVariableList()) do 
	    Note (k, " = ", v) 
	end
end
]]>

function OnQuit (sName, sLine, wildcards)
  --did_quit = true
  Send ("&quit_command;") --  Send to world so it does it
  Note "Deliberate quit (&quit_command;), reconnect disabled"
end -- function

function OnConnect (sName, sLine, wildcards)
  Note "Connection checker enabled"
  EnableTimer ("ConnectCheckTimer", true)
  did_quit = false
end -- function

function OnNoConnect (sName, sLine, wildcards)
  Note "Connection checker disabled"
  EnableTimer ("ConnectCheckTimer", false)
  did_quit = true
end -- function


</script>


<!--  Plugin Help  -->

<aliases>
  <alias
   script="OnHelp"
   match="Reconnecter:Help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
function OnHelp (sName, sLine, wildcards)
  Note (GetPluginInfo (GetPluginID, 3))
end -- function
]]>
</script> 

</muclient>
Top

Posted by Mat   (14 posts)  Bio
Date Reply #2 on Tue 27 May 2014 02:21 PM (UTC)
Message
I apologize, I should search more in depth before asking a question.
I found the answer in another post in this forum.

The plugin didn't have 'save_state="y"' at the top.
Fixed now.
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.


10,152 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.