a trigger, and an alias

Posted by Ignis on Sun 24 Apr 2005 08:12 AM — 26 posts, 87,825 views.

#0
i seem to be having troubles following the guide, one trigger i'm trying to get to work is "|||||||| >" (the fatigue bar in a game i play) to display as "8 >" but for some reason "* |{8} >* won't work, also an alias i'm trying to get to work "@ *", the body appearing as:
get %1
drop %1
remove quartz
take blade from bag
light %1
it works with what i type in, but is there a way to save key strokes as there are only 2 types of kindling in game, shredded bark, and dried grass, i was wondering if there was a way to make it so that typing "@ bark" would automatically know to put in shredded bark, and "@ grass" know to put in dried grass into the wildcard, if calling from a variable to use this trigger would work, i've already figured out how to make a trigger that does that, it's title is kindling, and it basically switches between the two depending on what type of area i'm in, i'm not trying to cheat, just save keystrokes
USA #1
If you're going to use quantifiers ({8}) then you'll need to use a regexp, which means you'll need to escape the | (\|) and the * (actually, since * is probably a wildcard, you'll replace it with (.*).

And the second example should work, could you post the exact trigger you're using?

And, to be perfeclty honest, I don't understand what you're asking for in the last bit. Do you want the same alias to do it (with the get, drop, etc)? or... expand where?
It's definately doable, once I figure out what you're looking to do.
#2
basically i want one trigger that can get shredded bark, or get dried grass for use as kindling by entering the appropriate into the %1 in the above alias example, then of course get the other items, and light the kindling, i should be able to make the output trigger work though for the number instead of |||| >, so thanks for that, and thanks for helping with this as well, if i need to elaborate further, i'll be glad to do so as i tend to not be the best at explaining things
USA #3
Depending on the scripting language you're using, it'll be different, but basically:

Instead of using %1 for most, you'll use a temporary variable, which you can check for grass or bark and change the variable accordingly. Something like this (of course, this isn't in any particular language):

temp = "%1"
if temp == "grass"
temp = "dried grass"
if temp == "bark"
temp = "shredded bark"
send "get " & temp
send "drop " & temp
send "remove quartz"
send "take blade from bag"
send "light " & temp
#4
ok, i think i know how to proceed from here, though admittedly, i've never called for a script from within an alias before
USA #5
You don't need to. To save the effort of making a script file, and calling a routine (and then moving that script whenever you move the alias, etc), just put the script into the trigger, and change the "send" to "send to script".

This way you can use %1, otherwise you'll have to deal with an array.
#6
and i must be an idiot cause i've got it partially working except now it says "Send-to-script cannot execute because scripting is not enabled." even though i've checked the enable box
USA #7
Did you enable scripting? (Game > Config > Scripting)? And of course, choose a language.
If that doesn't work, try saving the world after enabling scripting (not that it should make a difference).
#8
it's enabled, according to the little check box, but it's still not working, is there perhaps something in the trigger i need to look for?
USA #9
Why don't you go ahead and post the trigger.

What script language are you set for? And do you have a script file selected? (Not that either would cause failure, just trying to track down the problem).
What version of MC are you using?

Try disabling, and reenabling the script (close the dialog after each). Maybe that will solve it.

Do you get any errors when reloading the script? It's the button next to the autosay and reset timers.
Amended on Sun 24 Apr 2005 10:31 AM by Flannel
#10
<trigger>^(.*?) forest (.*?)$


<send>temp = "%1"
if temp = "grass", then temp = "dried grass"
if temp = "bark", then temp = "shredded bark"
World.send "get " & temp
World.send "drop " & temp
World.send "remove quartz"
World.send "take blade from bag"
World.send "light " & temp
<send> to script
<script> temp


it might be those commas, it's been a while since i coded
#11
one other thing, this is the desc i'm trying to get whether i need bark or grass from

Heavily wooded forest

Obvious exits: nothing
It is nearly pitch black here.
------------------------------------------------------------------
Dense foliage crowds this area, nearly black at this time of night. Above,
dappled wedges of the night sky are visible through the thick branches;
column-like tree trunks stand starkly against this shadowy backdrop. Fallen
branches and leaves, some tangled in the ever-present undergrowth, are visible
in the few shafts of pale light.
This area is vast.
------------------------------------------------------------------
A wood cabin is to the southwest.
==================================================================



the name of the room, in this case heavily wooded forest is always bold, and that's what i've been trying to get the alias for lighting kindling to respond to
USA #12
You can 'copy' the trigger and paste it here (please do) copy from the main trigger dialog (copy button).

But, a bad script won't cause problems (until it's run).

Do remove the script function though, since you don't need it.

Did you get any errors when reloading the script? I can't remember if an error will make the script engine stop working completely, but it does seem like it might.

And what language are you writing in?
Amended on Sun 24 Apr 2005 10:38 AM by Flannel
#13
<triggers>
<trigger
custom_colour="15"
enabled="y"
lines_to_match="16"
match="^(.*?) forest (.*?)$"
multi_line="y"
omit_from_output="y"
regexp="y"
script="temp"
send_to="12"
sequence="100"
variable="kindling"
>
<send>shredded bark</send>
</trigger>
</triggers>
USA #14
Wait, what? Where did that come from? You could set a variable for the 'current item', but we're still working on the other problem (or did that fix itself?) since, scripting won't do you any good if you can't get scripting to work.

And that last trigger would call the 'temp' routine, and then send "shredded bark" to the script engine, which would generate a syntax error (most likely). You do one or the other (send to script or a script function) well, under normal circumstances.

Why are you matching 16 lines?
#15
i'm not matching 16 lines, it's just that it's 16 lines back to find the word forest, to get the trigger to send "shredded bark" to anywhere, and i thought i was sending it to the function, not just the script
USA #16
No, send to script sends to the script.

And you don't check 16 lines back. It will match when that line gets there. It checks each line, one at a time.

Stick to one problem at a time, the alias was a good once, once you figure that out (including script syntax errors, if youre using VBScript or JavaScript download their help file and reference that to figure out the syntax, as well as the forums) then you can worry about setting and using a variable regarding your preferred item. Mushclient will only do what you tell it to, and if you don't tell it to do the right thing, nothing will work. So take the time and figure it out one step at a time. Simple triggers/aliases to simple scripts inside of triggers/aliases (and how they interface with triggers/aliases) to more complicated triggers/aliases (ones that interact with and depend on other things).

So go back and reread the guide again, you'll probably pick up on things you missed the first time around, and don't try to do things that are too complicated, since then all you get is confused.
USA #17
And also, that script that I posted was for your alias (to be able to do @ [item] or @ [grass] or @ [bark] and have it send accordingly. It had nothing to do with the trigger to figure out which to use.
#18
ok, i was hoping for a two in one alias, but perhaps just doing this for now is best then

<aliases>
<alias
script="temp"
match="@bark"
enabled="y"
sequence="100"
>
<send>get shredded bark
drop bark
remove quartz
take blade from bag
light bark
</send>
</alias>
</aliases>


<aliases>
<alias
script="temp"
match="@grass"
enabled="y"
sequence="100"
>
<send>get dried grass
drop grass
remove quartz
take blade from bag
light grass
</send>
</alias>
</aliases>
#19
also i figured out a solution for the ends i wanted with the other alias, but diff means

<triggers>
<trigger
custom_colour="15"
enabled="y"
match="*|||||||||| &gt; *"
omit_from_output="y"
send_to="2"
sequence="91"
>
<send>10 &gt; %1!</send>
</trigger>
</triggers>
#20
i know i should keep it simple, but i don't suppose there's a way to make the ansi maps in my game get translated into a bmp so that as i walk around, i'm making one large bmp map of the game world?
USA #21
You CAN do it in one alias that's what the script that I gave you was for. I went ahead and put it into an alias (notice no script routine? since you seem to have it in everything regardless)

<aliases>
  <alias
   match="@*"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>temp = "%1"
if (temp = "grass") then
  temp = "dried grass"
end if
if (temp = "bark") then
  temp = "shredded bark"
end if
send "get " &amp; temp
send "drop " &amp; temp
send "remove quartz"
send "take blade from bag"
send "light " &amp; temp</send>
  </alias>
</aliases>


will send shredded bark if its bark, dried grass if its grass, and anything else if its whatever else (if you wanted to make it JUST work for grass/bark, we can do that too).

As for your other alias, like I was saying, regular expression. Try matching on this:
^(.*)\|{8} > (.*)$
Which is a regexp. You CANT use a regexp quantifier ({8})with just normal *s for wildcards. It just doesn't work that way, you can't have half be a regexp, and the other half not.

The map thing is going to be way too complicated for you right now. Especially with the overlapping. Although If you have coordinates, that will simplify it some.
Amended on Sun 24 Apr 2005 09:59 PM by Flannel
#22
is there a way to have an alias call for another smaller alias from within itself?
USA #23
Instead of world.send, use world.execute.
#24
sweet, i have the alias completely solved (thanks to you ofcourse) and the trigger has sort of resolved itself which is also a big perk
#25
btw, end result on alias to get and light kindling
<aliases>
<alias
match="1*"
enabled="y"
send_to="10"
sequence="100"
>
<send>%1
drop %1
remove quartz
take blade from bag
light %1</send>
</alias>
</aliases>

plus one to light an object from the kindling
<aliases>
<alias
match="2* *"
enabled="y"
sequence="100"
>
<send>wear quartz
put blade in bag
take %1
light %1 from %2</send>
</alias>
</aliases>