PDA

View Full Version : Newbie: Simple window


Fido
07-30-2011, 03:05 AM
Hi,
i'd like to start with programming plugins. I'd like to make first a simple window, but i make something wrong:
I have a file : window.lua - here a tried many variations.
At the moment it starts as follow

import "Turbine";
import "Turbine.UI";
import "Turbine.UI.Lotro";

Window = class( Turbine.UI.Lotro.GoldWindow );

function Window:Constructor()
Turbine.UI.Lotro.GoldWindow.Constructor( self );
...

Here I've copied the code from Turbine examples.
The I have a file : main.lua

import "Fido.simple.Window"
window = Window();
window:SetVisible(true);

and : simpleLotro.plugin

<?xml version="1.0"?>
<Plugin>
<Information>
<Name>simpleLotro</Name>
<Author>Fido</Author>
<Version>0.1</Version>
</Information>
<Package>Fido.simple.main</Package>
</Plugin>

But in game I get the error:

...d of the Rings Online\Plugins\Fido\simple\Window.lua:5: attempt to call global 'class' (a nil value)

I've tried with other Windows, but it is always the same error. What is the problem?
Thanks for help.
Fido

D.H1cks
07-30-2011, 06:11 AM
Have you downloaded and installed the Turbine utility files? I believe 'class' is part of them.

Fortunis
07-30-2011, 07:09 AM
try

Window = Turbine.UI.Lotro.GoldWindow();

Digital_Utopia
07-31-2011, 06:46 AM
Have you downloaded and installed the Turbine utility files? I believe 'class' is part of them.

^ This.

The utility files are part of the example plugins and can be found here (http://forums.lotro.com/showthread.php?370084-Documentation-and-examples-updated!). You will need 7zip (http://www.7-zip.org/download.html) to open the archive.

Fido
07-31-2011, 12:30 PM
Thanks for suggestions. I've already installed the Turbine plugins. But it still doesn't work. When I use the call as Fortunis suggested, I get the same error but in the main.lua. All other plugins work perfectly. I suppose the file structure or naming is wrong. My directory looks as follow

Plugins
+->Fido
+-> simple.plugin
+-> simple (directory)
+-> __init__.lua (is empty)
+-> main.lua
+-> Window.lua


Fido

Fortunis
07-31-2011, 01:46 PM
K, just thinkling on it more i remember coming across this when i decided to use multiple LUA files.

I recall there being a problem with calling functions from another lua, with colons ':' . Instead of using-

function Window:Constructor()

try

function Window()

and then go from there on tweeking it.

Garan
07-31-2011, 05:25 PM
Your "imports" do not include the path to the Class.lua file. You need to add:
import Turbine.Utils

and your original code will work. A word of advice, it is simpler to copy the Turbine sample files that you find yourself using into your own project and import them from there. That way if you ever build something worthy of publishing you won't have to worry about users having the Turbine samples. You also won't have to worry about changes to the Turbine samples breaking your plugin (back in November, Turbine moved the Class.lua file from one folder to another and broke a number of plugins).

Fido
08-01-2011, 11:58 AM
Fortunis, that import was it. Thanks a lot! I created a new project just to understand the structure and dependencies. Generally I agree with you.
Now I can really start :)
I suppose it wasn't the last post :)

Fido