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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Plugin Just stopped working

Plugin Just stopped working

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


Posted by Zyn   (7 posts)  Bio
Date Sat 18 Aug 2018 10:10 PM (UTC)

Amended on Sun 19 Aug 2018 12:02 AM (UTC) by Zyn

Message

<triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="It is the (\d+)th of (\w+) in the year (\d+)."
   name="Date"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable("T_Date", %1)
SetVariable("T_Month", "%2")
SetVariable("T_Year", %3)</send>
  </trigger>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="It is the hour of the (\d+)(..) toll."
   name="Time"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable("T_Toll", %1)
</send>
  </trigger>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="It is the (\w+) of (\w+)\.|It is (\w+) (\w+)"
   name="Season"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable("T_Prefix", "%1")
SetVariable("T_Season", "%2")</send>
  </trigger>
</triggers>

<!--  Timers  -->

<timers>
  <timer name="TTCheck" enabled="y" minute="1" second="0.00" offset_second="0.00"    send_to="12"
group="THTime" active_closed="y" >
  <send>TT()</send>
  </timer>
</timers>
<script>
<![CDATA[
function TT()
	--Variables
		real_time = os.date ("*t")
		if ingame_hour == nil then ingame_hour = tonumber(GetVariable("T_Toll")) end --Toll 
		if ingame_date == nil then ingame_date = tonumber(GetVariable("T_Date")) end -- Date 
		if ingame_month == nil then ingame_month = GetVariable("T_Month") end -- Month (String)
		if ingame_year == nil then ingame_year = tonumber(GetVariable("T_Year")) end -- Year
		if ingame_season == nil then ingame_season = GetVariable("T_Season") end -- Season
		if current_month == nil then current_month = GetVariable("current_month") end
		if Bank_Status == nil then Bank_Status = "Banks are closed" end
		months = {}
		months = {
			'Dawn',
			'Cuspis',
			'Thawing',
			'Renasci',
			'Tempest',
			'Serenus',
			'Solaria', 
			'Torrid',
			'Sojourn',
			'Hoerfest',
			'Twilight',
			'Deepchill'
			}
		real_time_sec = real_time.sec
		real_time_min = real_time.min
		real_time_hour = real_time.hour
		
	-- Suffix changes
	if(ingame_hour == 1 or ingame_hour == 21) then ingame_suffix = "st" 
	elseif ingame_hour == 2 or ingame_hour == 22 then ingame_suffix = "nd"
	elseif ingame_hour == 3 or ingame_hour == 23 then ingame_suffix = "rd"
	else ingame_suffix = "th" end
		
		increase = 1
		
	-- Every 5 minutes is 1 toll. Divide by %5
	if real_time_min % 5 == 0 then
	ingame_hour = ingame_hour + increase
	SetVariable("T_Toll", ingame_hour)
		if(ingame_hour >= 9 and ingame_hour < 11) then
			ColourNote("yellow", "black", "****** It is "..ingame_hour..ingame_suffix.." Toll. Sable Bank is open! *******")
			Bank_Status = "Sable Bank is open!"
		elseif(ingame_hour >= 11 and ingame_hour <= 16) then
			ColourNote("yellow", "green", "****** It is "..ingame_hour..ingame_suffix.." Toll. Both Banks are open! *******")
			Bank_Status = "Both Banks are open!"
		elseif(ingame_hour > 16 and ingame_hour <= 19) then 
			ColourNote("red", "green", "****** It is "..ingame_hour..ingame_suffix.." Toll. Thrace Bank is open! *******")
			Bank_Status = "Thrace Bank is open!"
		else
			Bank_Status = "Banks are Closed"
		end
	else 
		ingame_hour = tonumber(GetVariable("T_Toll")) --Toll
	end
	
	--Find current month and index
	for index, value in pairs(months) do
		if value == ingame_month then
			current_month = index;
		end
	end
	--Checks time for timer
	if(ingame_hour == 25)  -- 0 - 24 tolls
	then 
		ingame_hour = 0 
		SetVariable("T_Toll", ingame_hour)
		ingame_date = ingame_date + increase  
		SetVariable("T_Date", ingame_date)
	elseif(ingame_date > 30)  -- 30 days in a month
		then 
			ingame_date = 1
			current_month = (current_month+1) -- Sets next month
			ingame_month = months[current_month]
	elseif(current_month > 12) -- Next year
		then		
		ingame_year = ingame_year + 1
	end -- 1st if

Top

Posted by Zyn   (7 posts)  Bio
Date Reply #1 on Sat 18 Aug 2018 10:44 PM (UTC)

Amended on Sat 18 Aug 2018 11:05 PM (UTC) by Zyn

Message

Run-time error
Plugin: Thresholdrpg_time (called from world: ThresholdRPG - Zezyn)
Immediate execution
[string "Plugin: Thresholdrpg_time"]:254: attempt to compare number with nil
stack traceback:
        [string "Plugin: Thresholdrpg_time"]:254: in function 'TT'
        [string "Timer: TTCheck"]:1: in main chunk


I created this small plugin clock and it was working fine until changed colors of the Note. I then started getting errors. I attempted to revert my changes and still get errors. I've checked the variables and they print out the values. I am lost, can you please point me in the right direction?

Let me say I appreciate your time and effort ahead of time, I've been working on this for awhile.

Thank you
(I want to further note I passed this around and other people are using it without a problem. It was working fine and not sure what happened)

Here is the text supposed to be captured by the trigger;

   ---------------------------------------------------
   The current time and date in the realm of Threshold
   ---------------------------------------------------

        It is the 22nd of Solaria in the year 448.    
             It is the hour of the 9th toll.          

               It is the middle of summer.            

   ---------------------------------------------------
Top

Posted by Fiendish   USA  (2,555 posts)  Bio   Global Moderator
Date Reply #2 on Sun 19 Aug 2018 01:22 AM (UTC)

Amended on Sun 19 Aug 2018 01:24 AM (UTC) by Fiendish

Message
Quote:
[string "Plugin: Thresholdrpg_time"]:254: attempt to compare number with nil

On line 254 of the script section of your plugin (the part after <script>), you tried to see if a number is less than or greater than nil, which is bad.

You've only shown about 70 lines of your plugin's script section, so we can't help yet. Post a link to your full plugin. As you've discovered, the forum doesn't want you to post hundreds of lines of code here.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 19 Aug 2018 02:27 AM (UTC)
Message
As Fiendish said, the line number is relative to the start of the script section, so:


...
<script>
<![CDATA[       <---- this is line 1 of the script
function TT()
...


So, add whatever-that-line-is in your editor to 254, and that will give you the line where the error is (give or take a line).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zyn   (7 posts)  Bio
Date Reply #4 on Sun 19 Aug 2018 09:59 AM (UTC)
Message
1st half

<script>
<![CDATA[
function TT()
	
	-----------------------------------------------------------------------------
	
	--REFERENCE FOR THRESHOLDRPG TIMING
	--1 game hour   -  5 REAL minutes
    --1 game day    -  2 REAL hours
    --1 game month  -  60 REAL hours
    --1 game year   -  30 REAL days
     --Dawn  -  January
     --Cuspis  -  February
     --Thawing  -  March
     --Renasci  -  April
     --Tempest  -  May
     --Serenus  -  June
     --Solaria  -  July
     --Torrid  -  August
     --Sojourn  -  September
     --Hoerfest  -  October
     --Twilight  -  November
     --Deepchill  -  December
	
	 --Winter          Spring            Summer         Autumn
     --Deepchill       Thawing         Serenus         Sojourn
     --Dawn            Renasci          Solaria          Hoerfest
     --Cuspis          Tempest         Torrid            Twilight
			 
	-----------------------------------------------------------------------------
	
	--Variables
		real_time = os.date ("*t")
		if ingame_hour == nil then ingame_hour = tonumber(GetVariable("T_Toll")) end --Toll 
		if ingame_date == nil then ingame_date = tonumber(GetVariable("T_Date")) end -- Date 
		if ingame_month == nil then ingame_month = GetVariable("T_Month") end -- Month (String)
		if ingame_year == nil then ingame_year = tonumber(GetVariable("T_Year")) end -- Year
		if ingame_season == nil then ingame_season = GetVariable("T_Season") end -- Season
		if current_month == nil then current_month = GetVariable("current_month") end
		if Bank_Status == nil then Bank_Status = "Banks are closed" end
		months = {}
		months = {
			'Dawn',
			'Cuspis',
			'Thawing',
			'Renasci',
			'Tempest',
			'Serenus',
			'Solaria', 
			'Torrid',
			'Sojourn',
			'Hoerfest',
			'Twilight',
			'Deepchill'
			}
		real_time_sec = real_time.sec
		real_time_min = real_time.min
		real_time_hour = real_time.hour
		
	-- Suffix changes
	if(ingame_hour == 1 or ingame_hour == 21) then ingame_suffix = "st" 
	elseif ingame_hour == 2 or ingame_hour == 22 then ingame_suffix = "nd"
	elseif ingame_hour == 3 or ingame_hour == 23 then ingame_suffix = "rd"
	else ingame_suffix = "th" end
		
		increase = 1
		
	-- Every 5 minutes is 1 toll. Divide by %5
	if real_time_min % 5 == 0 then
	ingame_hour = ingame_hour + increase
	SetVariable("T_Toll", ingame_hour)
		if(ingame_hour >= 9 and ingame_hour < 11) then
			ColourNote("yellow", "black", "****** It is "..ingame_hour..ingame_suffix.." Toll. Sable Bank is open! *******")
			Bank_Status = "Sable Bank is open!"
		elseif(ingame_hour >= 11 and ingame_hour <= 16) then
			ColourNote("yellow", "green", "****** It is "..ingame_hour..ingame_suffix.." Toll. Both Banks are open! *******")
			Bank_Status = "Both Banks are open!"
		elseif(ingame_hour > 16 and ingame_hour <= 19) then 
			ColourNote("red", "green", "****** It is "..ingame_hour..ingame_suffix.." Toll. Thrace Bank is open! *******")
			Bank_Status = "Thrace Bank is open!"
		else
			Bank_Status = "Banks are Closed"
		end
	else 
		ingame_hour = tonumber(GetVariable("T_Toll")) --Toll
	end
	
	--Find current month and index
	for index, value in pairs(months) do
		if value == ingame_month then
			current_month = index;
		end
	end
	--Checks time for timer
	if(ingame_hour == 25)  -- 0 - 24 tolls
	then 
		ingame_hour = 0 
		SetVariable("T_Toll", ingame_hour)
		ingame_date = ingame_date + increase  
		SetVariable("T_Date", ingame_date)
	elseif(ingame_date > 30)  -- 30 days in a month
		then 
			ingame_date = 1
			current_month = (current_month+1) -- Sets next month
			ingame_month = months[current_month]
	elseif(current_month > 12) -- Next year
		then		
		ingame_year = ingame_year + 1
	end -- 1st if
	
	
	
	Display_Threshold_Time(ingame_season, ingame_year, ingame_month, ingame_suffix, ingame_date, ingame_hour, Bank_Status) -- Send to Window
	
end -- TT
function Display_Threshold_Time(Season, Year, Month, Suffix, Date, Hour, Bank)
	THTime = "THTime_" .. GetPluginID () .. ":ThresholdTime" -- get a unique name, ensure not empty if outside plugin
	
	local font = "f"
	local font2 = "f2"
	
	WindowCreate (THTime, 0, 0, 0, 0, 6, 0, 0) -- Create Window Placeholder
	--creating Fonts
	-- Trebuchet MS, 28 point, bold
	WindowFont (THTime, font, "Trebuchet MS", 12, true, false, false, false)
	WindowFont (THTime, font2, "Trebuchet MS", 10, true, false, false, false)
	local max_width = WindowTextWidth(THTime, font, "The Time in Threshold")
	local font_height = WindowFontInfo(THTime, font, 1)
	local window_width = max_width + 40
	local window_height = font_height * 4
	
	--make window with size
	WindowCreate(THTime, 0, 0, window_width, window_height, 6, 0, ColourNameToRGB("black"))
	WindowRectOp(THTime, 5, 0, 0, 0, 0, 5, 15 + 0x1000) -- Border 
	
	-- Heading
	WindowText(THTime, font, "The Time in Threshold", 25, 5, 0, 0, ColourNameToRGB("white"), false)
	
	--Each line
	local y = font_height + 2 --Font Y axis
	local x = 5 -- Font X axis
	
	--Time and Date
	WindowText(THTime, font, Hour..Suffix.." Toll  ", (x+2), (y+20), 0, 0, ColourNameToRGB("magenta"), false) -- Toll
	WindowText(THTime, font, Month.." "..Date..", "..Year..";  "..Season, x, y, 0, 0, ColourNameToRGB("magenta"), false) -- Adds Month/date/year
	
	if Bank_Status == "Thrace Bank is open!" or Bank_Status == "Sable Bank is open!" or Bank_Status == "Both Banks are open!" then 
	WindowText(THTime, font2, Bank, (x+75), (y+23), 0, 0, ColourNameToRGB("green"), false) -- Bank Hours open
	else WindowText(THTime, font2, Bank, (x+75), (y+23), 0, 0, ColourNameToRGB("red"), false) end -- Bank Hours closed 
	
	--Real Time & Date
	WindowText(THTime, font, (os.date("%I")..":"..os.date("%M").." "..os.date("%p").." "..os.date("%x")) , x+35, y+40, 0, 0, ColourNameToRGB("white"), false)
	
	WindowShow(THTime, true) -- Show window
	
end -- Display_Threshold_Time
]]>
</script>
Top

Posted by Fiendish   USA  (2,555 posts)  Bio   Global Moderator
Date Reply #5 on Sun 19 Aug 2018 03:59 PM (UTC)
Message
What do you mean "first half"?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Zyn   (7 posts)  Bio
Date Reply #6 on Sun 19 Aug 2018 06:34 PM (UTC)
Message
I apologize I should have explained better. The first post was the beginning of the plugin with the triggers, the second post was just the script as requested. I have tried reinstalling MUSHclient 5.05 hoping that would help. It did not. From what I understand the ingame_date variable is now nil which leaves me to believe the trigger isn't capturing the line and setting the variable. I have made a new test trigger to see if I can capture the line and it works. I compare the new test trigger with the old trigger and the regular expression is the same. I am not sure what I am doing differently in the plugin to where this is not working. If I comment out anything to do with the ingame_date variable the plugin runs and works.
Top

Posted by Zyn   (7 posts)  Bio
Date Reply #7 on Sun 19 Aug 2018 07:24 PM (UTC)
Message
Ok an update. I have been testing and trying for a good few hours. I remade the script into another plugin with a different name, where previously I was overwriting the original plugin I created. Now that I have created a new plugin with a different name it works. I'm still unclear where I broke the last one. I thank you for your time and help. I greatly enjoy using MUSHclient and think it's one of the better clients out. Please keep up the good work and I appreciate the responses. :)
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #8 on Sun 19 Aug 2018 08:25 PM (UTC)

Amended on Sun 19 Aug 2018 08:45 PM (UTC) by Nick Gammon

Message
Quote:


        It is the 22nd of Solaria in the year 448.    



Trigger:

Quote:


   match="It is the (\d+)th of (\w+) in the year (\d+)."



That won't match (it isn't the 22th of Solaria) thus your date won't be set. If the first time you test it, you happen to get a "th" date then the date will be set and stay set until another "th" date comes along.

Maybe make the trigger:


   match="It is the (\d+).. of (\w+) in the year (\d+)."



Or:



   match="It is the (\d+)(?:st|nd|rd|th) of (\w+) in the year (\d+)."

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zyn   (7 posts)  Bio
Date Reply #9 on Sun 19 Aug 2018 09:10 PM (UTC)
Message
I didn't think of that!! LOL. Always miss the easy things. I was able to duplicate the original problem I had though. After creating the plugin with the plugin wizard provided in MUSHclient, I attempted to alter the timer in the plugin file. I save the file, reload the plugin and that's when I started getting the same error as before. I hope this helps. Also Thanks Nick you're absolutely right and am fixing that issue now.

Thank you for all your time!
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.


28,236 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.