Aardwolf Custom Level Plugin

Posted by Chicomecoatl on Sat 01 May 2010 02:36 AM — 14 posts, 41,310 views.

USA #0
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>
Amended on Fri 07 May 2010 01:51 AM by Chicomecoatl
Australia Forum Administrator #1
What order do the messages arrive in? Can you post an example?
USA #2

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

USA #3
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!
USA #4
Ok, found one mistake, i forgot "send_to="12"" under the levelgains, but i still get the same error.
USA #5
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.
Australia Forum Administrator #6
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.

USA #7
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.
Australia Forum Administrator #8
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.
USA #9
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.
USA #10
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>
USA #11
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?
USA #12
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.
USA #13
Perfection! Got it up and running, will amend the top post to reflect the corrections. Thanks so much, all.

Chico