what's wrong with this?

Posted by Aznvt33 on Thu 01 Jun 2006 01:36 AM — 4 posts, 20,674 views.

#0
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?
USA #1
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.
Russia #2
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.
Australia Forum Administrator #3
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.