PDA

View Full Version : Extension not working



Hamish
February 20th, 2011, 20:19
What am I doing wrong this time? I'm guessing it's in extension.xml, but I'll be damned if I know what it is....

I created a new extension, copied characterlist.lua from the 3.5E ruleset to the scripts subfolder and added just 1 line, just to see if the extension is doing anything at all:


function onUserStateChange(username, statename, state)
print("Test");
if username ~= "" and User.getCurrentIdentity(username) then

I never have Test show up in the console ever.....

Here's extension.xml:

<?xml version="1.0" encoding="iso-8859-1"?>
<root version="2.0" release="1">
<properties>
<name>Extension Test</name>
<version>1</version>

<author>Nils van Schaik</author>
<description>3.5E ruleset test extension</description>

<ruleset>
<name>3.5E</name>
</ruleset>
</properties>

<base>
<script file="scripts/characterlist.lua" />
</base>
</root>


I have succesfully created another extension that modifies chatmanager.lua, so I've got the basics down. Only difference I can find is that chatmanager.lua has a name attribute in the script tag, and characterlist.lua hasn't.

Hope anyone can show me what I'm doing wrong.....

Hamish
February 24th, 2011, 10:54
Anyone? Please?

Ikael
February 24th, 2011, 11:15
first of all, onUserStateChange is handler function not even function. You need to define something the following the make it work:

User.onUserStateChange = handleIt
function handleIt(username, statename, state)
-- content of the function
end

Secondly I think you are using that characterlist.lua in the characterlist window implementation. If this is the case you can't override it like you're doing. You must include the window implementation to your extension as well. On the otherhand if that function is global script you must give name to it so it will be initialized/created at all. For example:

<script name="CharacterList" file="scripts/characterlist.lua" />

Hope this helps!

Hamish
February 24th, 2011, 12:26
Thanks for the tips,

As I described, I took the file I want to change from the 3.5E ruleset and just added a line. I assume (can't check right now) that the assignment of onUserStateChange to handle an event is elsewhere in the 3.5E ruleset, and I haven't done anything with that.

I'll try adding the xml that contains the reference to characterlist.lua to the extension, see if that works.

Moon Wizard
February 24th, 2011, 22:03
You will need to replace the characterlist window class, which is where that script file is used.

Copy the windowclass definition from desktop_classes.xml, into your extension.xml file. Then, put your new script file into a scripts subfolder under your extension's folder.

Cheers,
JPG

Hamish
February 25th, 2011, 07:53
Thanks guys, I now have a nice "Test" message showing up on my console. I can finally get started rebuilding my extension.