[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Not understanding how to fix what a trigger error message says is wrong
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Not understanding how to fix what a trigger error message says is wrong

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


Posted by Skeric   (4 posts)  [Biography] bio
Date Sat 09 Dec 2006 01:47 PM (UTC)
Message
Greetings all. I have a MUSHclient trigger I made, and it's one of my first attempts:

<triggers>
<trigger
enabled="y"
expand_variables="y"
match="^You bleed (\d+) health\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>
bleeding = int("%1")
cmp = int(world.GetVariable("cmp"))
clotper = bleeding/60

if cmp > 1100:
if bleeding < 3000 > 160:
world.Send("clot\n"*clotper)
</trigger>
</triggers>


and after saving it as a .MCT and loading it under triggers, it pops with the message

Line 16: Element name must start with letter or underscore, but starts with " " (problem in this file)

and I cant figure exactly what it's telling me is wrong.



Thanks in advance!
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Reply #1 on Sat 09 Dec 2006 05:51 PM (UTC)
Message
At a guess. I would say this line:

'if bleeding < 3000 > 160:'

It "should" be storing it as:

'if bleeding &lt 3000 &gt 160:'

Basically, what the error is telling you, is, "I just looked through your XML and found an "open tag" marker, i.e. "<", but the stuff between there and the ">" doesn't make any sense to me, so I am going to assume you where trying to create an Element. It is not a valid element."
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sun 10 Dec 2006 04:48 AM (UTC)
Message
You wouldn't have this problem if you created the trigger in the GUI interface, and then just saved it (or, copied it). That automatically converts things like < and > characters.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Reply #3 on Mon 11 Dec 2006 01:39 AM (UTC)
Message
With respect Nick, there are times when one would like to work on and edit such things "outside" the GUI, since the GUI is **very** world centric and, due to that, its not hard to leave things out of the exports you want, include things you didn't intend (especially with triggers), etc. I don't blame him for hand designing the trigger. Now... Not understanding how they needed to be correctly coded by hand however is definitely something people should be more caregful about when doing it that way.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Mon 11 Dec 2006 01:46 AM (UTC)
Message
OK, well it may be worth pointing out that the built-in notepad has a function to automatically convert < to &lt; and so on, so you can select the script portion of your trigger and use that.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #5 on Mon 11 Dec 2006 02:17 AM (UTC)
Message
Besides, I'm not sure how else you can solve the problem. Is MUSHclient supposed to just guess if a < means a tag opener or a less-than? So I'm not sure what you're suggesting other than griping about a problem that seems to be just the way it is.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Mon 11 Dec 2006 02:31 AM (UTC)
Message
Since the interface is well-documented, anyone that wants to is welcome to write a small "standalone" editor for triggers etc.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Reply #7 on Mon 11 Dec 2006 06:18 PM (UTC)
Message
Hmm. Oddly enough, Ksilyan, I tend to suspect that its unlikely for other tags, including elements, to be "in" the <send> section of a trigger. In fact, I would say "especially" in there, since the basic function of Mushclient is such that an element declaration in that location isn't going to do anything, except mess up the sent information (I assume). There really isn't any practically reason, other than maintaining some sort of unneeded universality in the parser, to not include some checks for "where" the < appears and handle it differently when inside of a <send></send> or other similar cases. Even requiring that the specification handle those things as possible XML is imho anal, since which makes more sense, stating, "Elements must be declaired 'prior' to the data blocks that uses them, not inside them.", or, "You have to nit pick every < and > you don't intend to be a tag."?

Some things about XML are done for laziness sake, to keep the specification simple, not because they make any bloody sense at all from the perspective of someone doing coding. I mean, sure, *sloppy* coders declare there constants right when they need them. Good ones declair them in a header file or outside the function, in case they need them some place else. Now, imagine if any other language had some screwball way of defining constants that caused the interpreters and compilers to have a hernia everytime they encountered "normal" code, simply because the "default" was to expect that the coder escaped the symbol that defined "start of constant"... I really don't know what these people where thinking, other than that maybe "script" was an after thought in the process, not something they planned to support from the beginning, which is why they are using silly nonsense to do it, instead of something half way sane, like making a <code></code> block "standard" in the language and specifying that that "must" be treated differently internally. Oh wait... They did do that, only its fracking inconsistent in requiring its use and absurdly designed. lol

But yeah, if you want to do things the really hard way, you can code an extra app to let you edit them...
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #8 on Mon 11 Dec 2006 06:32 PM (UTC)
Message
XML isn't designed to be a scripting language nor was it designed to represent scripts. In fact it wasn't designed to represent anything specific. It's a language to represent hierarchical data, or a node graph if you prefer. So, representing code in XML isn't a design issue to begin with; it's not an after-thought because it isn't really a thought to begin with.

The fact that Nick uses XML to save triggers is incidental. It's a convenience that they are human readable and editable. Sure, it's inconvenient to have to escape certain symbols if you edit outside the GUI, but, well, Nick solved that problem by letting you edit inside the GUI or using the notepad's escaping features.

I do not understand your analogy to programming languages, because you would not compile or interpret code written in one language in a compiler for another language; that just doesn't make sense. So if one language had an odd feature, it wouldn't matter because the compilers/interpreters would know about it.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Tue 12 Dec 2006 12:24 AM (UTC)
Message
Any form of storage on disk is going to have the issue of how to handle the delimiters. In the XML case you have <send> ... </send> approach.

Now it is all very well saying "treat any < literally until you reach </send>" but what if you want to put "</send>" into the script? This isn't particularly far-fetched, a script might be generating XML tags.

In any case, MUSHclient uses an XML parser first, to break down the XML text into individual tags, at that point it doesn't know that it happens to be a script tag.

Maybe they could have been stored with some other delimiter, but you still have the issue of how to handle that delimiter inside the script, if necessary.

Quote:

... the GUI is **very** world centric ...


I don't see what is to stop you making a trigger in the GUI, copying it to the clipboard, which gives the proper format, escaped XML and all that, and then deleting the trigger from the GUI. Sounds simple enough to me.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


6,465 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]