EnableTrigger problem

Posted by Orogan on Fri 31 Oct 2008 07:23 PM — 3 posts, 14,431 views.

#0
Hi,
What I'm trying to do is this:
type 'lore <item>'
send this command to the mud
Then grab all the info the mud sends me unitl my prompt shows up.
Only problem I got is it keeps grabbing line even when the prompt has past.
I tested the reg exp for the prompt it works.
prob. have some thing dumb going oon, but can't figure it out.
So here's what I got:



<!--  Triggers  -->

<triggers>

  <trigger
   group="lore"
   enabled="n"
   match="*"
   name="GetLine"
   script="lore_to_world"
   send_to="12"
   sequence="10"
  >
  </trigger>

</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   name="StartLore"
   enabled="y"
   script="lore_to_world"
   match="Lore (?P<lore_item>.*)$"
   group="lore"
   regexp="y"
   send_to="12"
   ignore_case="y"
   omit_from_output="y"
   sequence="100"
  >
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[

function lore_to_world (name,line,wildcards,style)

	if name == "StartLore" then
		LoreItem = (GetAliasWildcard ("StartLore", "lore_item"))
		Note "1"
		Send ("lore " .. LoreItem)
		EnableTrigger ("GetLine", true)
		return
	end -- if

	if line == "^[" then
		EnableTrigger ("GetLine", false)
		ColourNote ("green", "", "Done")
		SaveState ()
		return
	end -- if

	if name == "GetLine" then
		Note ("line grab")
		return
	end --if
end -- lore_to_world

]]>
</script>



I replaced the actual action's by Notes just for testing.
Australia Forum Administrator #1
The problem line is here:


if line == "^[" then


You are doing a test for string equality on the line, but the prompt won't look that will it?

You mean to do either:


if string.sub (line, 1, 1) == "[" then  -- test first character


or


if string.match (line, "^%[")  then  -- regular expression


Amended on Fri 31 Oct 2008 08:34 PM by Nick Gammon
#2
Thanks, makes it all clear now :)