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 ➜ Lua ➜ Aardwolf Custom Level Plugin

Aardwolf Custom Level Plugin

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


Posted by Chicomecoatl   USA  (25 posts)  Bio
Date Sat 01 May 2010 02:36 AM (UTC)

Amended on Fri 07 May 2010 01:51 AM (UTC) by Chicomecoatl

Message
Hello, I got most of the grunt work for this plugin up and running. I only have one issue, when it fires, i can't get it to parse the information, before it tries to send. In other words, i can't get the level gains and such, before the trigger for level/pup fires, so it won't concatenate.

So, here it is:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- $Id: Aardwolf_Level_Tracker.xml 132 2010-05-04 17:10:42Z endavis $ -->
<muclient>
<plugin
   name="Aardwolf_Level_Tracker"
   author="Chicomecoatl"
   id="aab0ab9ed92f8fd614664bd1"
   language="Lua"
   purpose="broadcast info from leveling to gtell"
   save_state="y"      
   date_written="2010-05-04 14:20:07"
   requires="4.38"
   version="1.0"
   >
</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>
<triggers>
  <trigger
   enabled="n"
   match="^$"
   regexp="y"
   name="SendLevelInfo"
   group="linfo"
   send_to="12"
   sequence="50"
  >
  <send>
	if (pupped=="y" and levelled=="n") then
		if (pups_today==nil or "") then
			pups_today=1
		end
		msg="@RPup #@G".. pups_today.."! @R[@WGains: @G"..pup_gains.."@R]"
		if (bonus_trains ~=nil or "") then
			msg=msg.." @R[@WBonus Trains: @G"..bonus_trains.."@R]"
		end
		if (bonus_stats~=nil or "") then
			msg=msg.." @R[@WBonus Stats: @G"..bonus_stats.."@R]"
		end
		msg=msg.."@w"
		SendNoEcho("gt "..msg)
		pups_today=pups_today+1
		bonus_trains=nil
		bonus_stats=nil
	elseif (pupped=="n" and levelled=="y") then
		msg="@RLevel @G"..level.."! @R[@WGains: @G"..level_gains.."@R]"
		if (bonus_trains ~=nil or "") then
			msg=msg.." @R[@WBonus Trains: @G"..bonus_trains.."@R]"
		end
		if (bonus_stats ~=nil or "") then
			msg=msg.." @R[@WBonus Stats: @G"..bonus_stats.."@R]"
		end
		msg=msg.."@w"
		SendNoEcho("gt "..msg)
		bonus_trains=nil
		bonus_stats=nil
	end
	EnableTrigger("SendLevelInfo", false)
  </send>
  </trigger>
  <trigger
   enabled="y"
   match="You gain * hit points, * mana, * moves, * practices and * trains."
   name="levelgains"
   group="linfo"
   send_to="12"
   sequence="50"
  >
  <send>level_gains="%5"
  </send>
  </trigger>
  <trigger
   enabled="y"
   match="You gain * trains."
   name="pupgains"
   group="linfo"
   send_to="12"
   sequence="50"
  >
  <send>pup_gains="%1"</send>
  </trigger>
  <trigger
   enabled="y"
   match="Lucky! You gain an extra * training sessions*!"
   name="bonustrains"
   group="linfo"
   send_to="12"
   sequence="50"
  >
  <send>bonus_trains="%1"</send>
  </trigger>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="You gain a bonus * point!"
   name="bonusstat"
   send_to="12"
   group="linfo"
   sequence="50"
  >
  <send>
  if (bonus_stats ~= nil) then
	bonus_stats=bonus_stats..", %1"
  else
    bonus_stats="%1"
  end
  </send>
  </trigger>
<trigger
   enabled="y"
   match="Congratulations hero. You have increased your powers!"
   name="pup"
   send_to="12"
   sequence="100"
  ><send>levelled="n"
  pupped="y"
  EnableTrigger("SendLevelInfo", true)</send>
  </trigger>
  <trigger
   enabled="y"
   match="You raise a level! You are now level *."
   name="level"
   send_to="12"
   sequence="100"
  >
  <send>levelled="y"
  pupped="n"
  level="%1"
  EnableTrigger("SendLevelInfo", true)</send>
</trigger>
 </triggers>
 </muclient>
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 01 May 2010 03:39 AM (UTC)
Message
What order do the messages arrive in? Can you post an example?

- Nick Gammon

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

Posted by Chicomecoatl   USA  (25 posts)  Bio
Date Reply #2 on Sat 01 May 2010 03:44 AM (UTC)
Message

Run-time error
Plugin: LAardwolf_Level_Tracker (called from world: Aardwolf)
Immediate execution
[string "Trigger: level"]:6: attempt to concatenate global 'level_gains' (a nil value)
stack traceback:
        [string "Trigger: level"]:6: in main chunk

Top

Posted by Chicomecoatl   USA  (25 posts)  Bio
Date Reply #3 on Sat 01 May 2010 03:49 AM (UTC)
Message
That's the only message i receive from it.

It seems that it won't send at all, with a nill-value error.

I tried using the script="blah", but i don't have much experience with it -- so i went about it with the send to script ability, the mud sends the messages in this order, with random values, i'd given it for the test trigger.

You raise a level! You are now level 999.
You gain 1 hit points, 2 mana, 3 moves, 4 practices and 5 trains.
Lucky! You gain an extra 1337 training sessions!
You gain a bonus Studly point!
You gain a bonus Pimp point!
Top

Posted by Chicomecoatl   USA  (25 posts)  Bio
Date Reply #4 on Sat 01 May 2010 03:59 AM (UTC)
Message
Ok, found one mistake, i forgot "send_to="12"" under the levelgains, but i still get the same error.
Top

Posted by Chicomecoatl   USA  (25 posts)  Bio
Date Reply #5 on Wed 05 May 2010 02:58 AM (UTC)
Message
I ammended the script above, to how i now have it, with all errors that i can find, corrected.

I can't seem to get it to work though, no matter what i try. I continue to get attempt to concatenate <insert variable here>, a nil value.

Not really sure where i'm messing up, i would really appreciate some help.

Again, the script on the first post has been ammended, to fix the lacking things, such as forgetting

send_to="12"


in more than a few places, and a few other minor things i noticed awry, but still can't get the big error fixed.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #6 on Wed 05 May 2010 05:40 AM (UTC)
Message
OK, well the first trigger to fire is the one that matches:


You raise a level! You are now level 999.


Inside the script you do this:


msg="@RLevel @G"..wildcards[1].."! @R[@WGains: @G"..level_gains.."@R]"


In other words, you are concatenating level_gains with other stuff. But level_gains is not set up yet (it will be nil, which is exactly what the error message said).

The next line is this:


You gain 1 hit points, 2 mana, 3 moves, 4 practices and 5 trains.


That does this:


level_gains=%5


But it is too late. You needed level_gains the line before. You need to rework it so you are not using level_gains before you know what it is.


- Nick Gammon

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

Posted by Chicomecoatl   USA  (25 posts)  Bio
Date Reply #7 on Thu 06 May 2010 01:29 AM (UTC)
Message
How would i go about doing that?

I tried a DoAfterSpeciatl func, but i couldn't get it to work. If you can give me an idea, even a vague one, about how to get it done, i'll be happy to ponder it out from there.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #8 on Thu 06 May 2010 06:00 AM (UTC)
Message
It isn't totally clear what your objectives are here, but the simple thing is to modify the level gains message when the trigger for the number of trains arrives. In other words, use the number when it arrives, not some other time.

- Nick Gammon

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

Posted by Chicomecoatl   USA  (25 posts)  Bio
Date Reply #9 on Thu 06 May 2010 05:48 PM (UTC)
Message
Well, the issue is that the bonus's aren't always there, as in it's random if you get them or not, so i can't trigger off of those. The only two messages that are guaranteed to show up are the You raise a leve, and You gain, messages. So i'm not sure how to capture all the info in them, when they show up /after/ the only trigger messages i can use.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #10 on Thu 06 May 2010 07:30 PM (UTC)
Message
It would be easiest, in my opinion, to collect all the data first, and then react to it all when you hit the prompt. Since the prompt is (supposedly) guaranteed to come after all of the lines you want, you can use it as an "Okay, I got all the lines, now lets use them" moment.

<triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="YOUR PROMPT TRIGGER HERE"
   name="numeric_prompt"
   regexp="y"
   sequence="1"
  >
  <send>
  -- If your MUD doesn't use IAC EOR/GA at the end of your
  -- prompt, you don't need this check.
  if GetLineCount() == GetInfo(289) then
    -- Do stuff here.
  end
  </send>
  </trigger>
</triggers>

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Chicomecoatl   USA  (25 posts)  Bio
Date Reply #11 on Thu 06 May 2010 07:53 PM (UTC)
Message
Ok, I think I can get that to work, which brings me to another question:
Quote:

-- If your MUD doesn't use IAC EOR/GA at the end of your
-- prompt, you don't need this check.


What in the world is IAC EOR/GA?
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #12 on Thu 06 May 2010 08:07 PM (UTC)
Message
A Telnet byte sequence that some (most maybe?) MUDs put at the end of the prompt. IAC is a special Telnet "escape" byte. GA means "Go Ahead", EOR means "End of Record". Either one can be used by the MUD.

MUSHclient records the number of the last line with that byte sequence on it, and you can use that to check that the line you're matching really is the prompt.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Chicomecoatl   USA  (25 posts)  Bio
Date Reply #13 on Fri 07 May 2010 01:51 AM (UTC)
Message
Perfection! Got it up and running, will amend the top post to reflect the corrections. Thanks so much, all.

Chico
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.


29,631 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.