Thread: Begginers Woe.
View Single Post
  #4  
Unread 08-23-2011, 11:44 AM
Equendil Equendil is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Apr 2011
Posts: 52
Alright, a few more things here:

- If a plugin is already loaded, trying to load it again will fail. A plugin is considered loaded by the system if it was able to run its 'package' file without error (even if there are subsequent errors from events). Always make sure your plugin is not actually loaded when you get the "unable to load" error ("/plugins list" or equivalent through a plugin manager).

- You do not declare types in lua, "HelloClass class = HelloClass();" should be "class = HelloClass();". On a side note, and for the sake of nitpicking it's generally a bad idea to use a keyword as a variable name. While "class" is not a keyword of lua as such, it should probably be considered as such to avoid confusion since it's the name of the class factory provided by Turbine. Also what you get when you call "HelloClass()" is an "instance" or "object" of the class HelloClass, so it's semantically incorrect.

- Building a function using the colon notation is a syntaxic shortcut.

Declaring : "function HelloClass:SayHello()"
is equivalent to : HelloClass.SayHello = function( self )

if you then want to call that function as a "method" on an instance, you need to call it using the colon notation:
if your instance is called myHelloClass then you would call SayHello that way : myHelloClass:SayHello();
which is equivalent to : myHelloClass.SayHello( myHelloClass );

In your code, you should have "self:SayHello()" (in HelloClass.lua) and "class:SayHello()" (in main.lua).

- The "cmd" argument given to the Execute() method of a command is the name through which it was called (you can declare multiple names in Turbine.Shell.AddCommand(), if you separate them with ";"). You declared "el" as a name, so "cmd" will always be "el". If as I expect you want "/el sayhi" to result in the "Hello World!" message being sent to the console, you need to test "args", not "cmd".

All but the first point however, should either cause an error other than "unable to load plugin" or not cause an error.

Edit: Also nitpicking, you should declare your command fully before you export it to the system through Turbine.Shell.AddCommand(). If AddCommand() tested (I don't think it does) for the existence of an "Execute()" method on your command, it wouldn't find one.

Can't see anything else that would be wrong, structure seems alright to me, not got the game running to check everything else is fine though.
__________________
Author of LIP, Bootstrap and Baruk

Last edited by Equendil : 08-23-2011 at 11:53 AM.
Reply With Quote