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 ➜ what's wrong with this?

what's wrong with this?

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


Posted by Aznvt33   (18 posts)  Bio
Date Thu 01 Jun 2006 01:36 AM (UTC)
Message
I am trying to write a plugin for Achaea and I think everything is alright but now i'm stuck. I keep getting this error:

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

===========================================

Here is the actual plugin:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, May 31, 2006, 3:53:56 PM -->
<!-- MuClient version 3.70 -->

<muclient>
<plugin
name="Health Change"
author="Jinze"
id="99e5a40f9e8c83f43dba7ff4"
language="Lua"
purpose="Shows Health Changes"
save_state="y"
date_written="2006-05-31 15:53:56"
requires="3.7"
version="1.2"
>

<description trim="y">
<![CDATA[
This plugin will show health changes on your prompt when you heal or are attacked.

prompt (on|off) to turn it on or off

]]>
</description>

<triggers>
<trigger
enabled="y"
expand_variables="y"
group="Prompt"
keep_evaluating="y"
match="(?P&lt;chp&gt;\d+)h, (?P&lt;cmp&gt;\d+)m, (?P&lt;end&gt;\d+)e ([cexkdb]+)\-$"
regexp="y"
script="HPprompt"
send_to="12"
sequence="100"
>
<send>world.SetVariable("chp", %&lt;chp&gt;)
world.SetVariable("cmp", %&lt;cmp&gt;)

</send>
</trigger>
</triggers>

<aliases>
<alias
match="^prompt (on|off)$"
expand_variables="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>if "%1" == "on":
world.EnableTriggerGroup("Prompt", 1)
else:
world.EnableTriggerGroup("Prompt",0)
</send>
</alias>
</aliases>

<script>

def = HPprompt(name,output,wildcards):
world.SetVariable('chp', wildcards[0])
world.SetVariable('cmp', wildcards[1])
CSHP = int(world.GetVariable('CSHP'))
chp = int(wildcards[0])
defs = wildcards[3]

diff = CSHP-chp
if diff < 0:
diff = str(diff)
Ndiff = diff.replace('-','+')
diff = Ndiff
world.ColourTell('Silver','black','[' + str(diff) + ']')

elif diff:
world.ColourTell('Silver','black','[-' + str(diff) + ']')
world.SetVariable('CSHP',chp)

</script>

=========================================

Any ideas?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Thu 01 Jun 2006 01:57 AM (UTC)
Message
Well, that's not Lua code, so it's not surprising that it's not working correctly since you're telling it to work as Lua. :) Try setting the language to Python.

Also, in the future, you should use the code tag to make it easier to read the plugin, and also indicate which line is the trouble-line, so that we know where to look.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #2 on Thu 01 Jun 2006 04:12 AM (UTC)
Message
You might want to take a look at http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=6606&page=999999

The plugin there is much bigger, but it's Lua and it does what you want.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 01 Jun 2006 05:45 AM (UTC)

Amended on Thu 01 Jun 2006 05:46 AM (UTC) by Nick Gammon

Message
Well for one thing the plugin is missing the final line:


</muclient>


However let's assume you have that there and didn't paste it into the message.

Line 74 is this line:


if diff < 0:


The problem here is that, the XML parser that is reading in the plugin is expecting an entity name (like <script> ) after the "<" symbol.

Your solution is to do either:


  • Change every < into &lt; and > into &gt; and & into &amp;

    or

  • Bracket the entire script in a CDATA block, like this:

    
    <script>
    <![CDATA[
    
    ... your script here ...
    
    ]]>
    </script> 
    


    Now, you can leave everything as it is (assuming you don't have "]]>" inside the script itself).


Also, as Ksilyan said, you may have chosen the wrong language when you created the plugin, you might want to change that.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


15,650 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.