Begginers Woe.
Hi there :) wanna get started writing a plugin and i cant get this to work, and i cant understand why.
Main.Lua Code:
-- Main.lua Code:
-- HelloClass Code:
LOTRO / Plugins / Elsees / Elsees / luafiles |
Quote:
Also possibly caused by adding/editing a ".plugin" file while the game is running without a "/plugins refresh". |
hey :) thanks for the reply. i do have a plugins file and it works, but only IF i dont use the HelloClass.lua
Elsees.plugin Code:
<?xml version="1.0"?> Code:
LOTRO/ Plugins / Elsees / Elsees.plugin |
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. |
While I'm at it, the most recent Turbine package (http://forums.lotro.com/showthread.p...amples-updated!) does not have a "Turbine.Utils" folder. Class.lua etc are found under "Turbine".
|
Equendil .. you are awesome :D cheers will look into it :)
Im new to Lua as a language, but not programming so a few of this mistakes made me ./faceplam. but hey, we learn :D Will get back to you soon. |
All times are GMT -5. The time now is 08:20 PM. |
vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI