lotrointerface.com
Search Downloads


Go Back   LoTROInterface > LotRO > Developer Discussions > Lua Programming Help (L)

Reply
Thread Tools Display Modes
  #1  
Unread 12-29-2010, 05:05 PM
Gramps Gramps is offline
The Indomitable
 
Join Date: Aug 2007
Posts: 12
Real basic help

Hey there, I've been spending some time digging around the Turbine examples and basically want to learn how to do really simple lua.

If I wanted to learn how to say, make a simple Window, maybe add in a button or two, maybe add a function to a button. Where would I start?

I just have some time on my hands and thought I could spend some of it on very basic Lotro LUA stuff. If this is something that time, effort and a learning capacity cant overcome, and school is the only route then be honest

Thx.
Reply With Quote
  #2  
Unread 12-29-2010, 05:46 PM
SanDBoX's Avatar
SanDBoX SanDBoX is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Location: Idaho
Posts: 40
Lua is an extreamly flexable language which is easy to learn (hurts the head if you are a c-type programmer already) but you can create a window with only a handful of lines, the hard part (for me atleast) was figuring out how to get lotro to "see" the plugin, for that you can create your own directory with the other plugins and "steal" the .plugin file then rename and modify it (with a text editor or IDE if you have one) then just a matter of making another directory (with your plugin's name). after that you create two files (or three if you plan to have an single place to put your imports) your "main.lua" and your "window.lua" files, in your window file you put in basic code like this -
Code:
import "Turbine"
import "Turbine.UI"
import "Turbine.UI.Lotro"

Window = class( Turbine.UI.Window )

function Window:Constructor()
    Turbine.UI.Lotro.Window.Constructor( self )
    self:SetVisible( true )
    
    --I Setup Window Data
    self:SetSize( 200, 150 )
    self:SetBackColor( Turbine.UI.Color() )
    self:SetPosition( 25, 150 )
    self:SetText( "Hello World!" )
end
that will give you a very basic small window, then in your main.lua file put -
Code:
import <your directory name>.Window

window = Window()
at that point it would just be a matter of digging through the API documentation to get whatever elements/widgets you want to use. there are a lot of examples you can use since you can just open up any of the existing plugins and read them! (I have done that to figure a lot of things out like saving/loading data.)

hope that is a good enough primmer to get you going!
Reply With Quote
  #3  
Unread 12-29-2010, 07:55 PM
MrJackdaw's Avatar
MrJackdaw MrJackdaw is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Feb 2009
Location: Lancaster, England
Posts: 249
I found looking at other peoples plugins and working through http://www.lua.org/pil/1.html helped. I still don't understand everything, but learning on-the-job is the best way to learn anything! Well... except brain surgery...
__________________
************************************************** ************************************************** **
"Our ideals may never be realised, But they indicate what we are trying to do." Dick Tahta
Reply With Quote
  #4  
Unread 12-30-2010, 03:19 AM
Gramps Gramps is offline
The Indomitable
 
Join Date: Aug 2007
Posts: 12
Quote:
Originally Posted by SanDBoX
Lua is an extreamly flexable language which is easy to learn (hurts the head if you are a c-type programmer already) but you can create a window with only a handful of lines, the hard part (for me atleast) was figuring out how to get lotro to "see" the plugin, for that you can create your own directory with the other plugins and "steal" the .plugin file then rename and modify it (with a text editor or IDE if you have one) then just a matter of making another directory (with your plugin's name). after that you create two files (or three if you plan to have an single place to put your imports) your "main.lua" and your "window.lua" files, in your window file you put in basic code like this -
Code:
import "Turbine"
import "Turbine.UI"
import "Turbine.UI.Lotro"

Window = class( Turbine.UI.Window )

function Window:Constructor()
    Turbine.UI.Lotro.Window.Constructor( self )
    self:SetVisible( true )
    
    --I Setup Window Data
    self:SetSize( 200, 150 )
    self:SetBackColor( Turbine.UI.Color() )
    self:SetPosition( 25, 150 )
    self:SetText( "Hello World!" )
end
that will give you a very basic small window, then in your main.lua file put -
Code:
import <your directory name>.Window

window = Window()
at that point it would just be a matter of digging through the API documentation to get whatever elements/widgets you want to use. there are a lot of examples you can use since you can just open up any of the existing plugins and read them! (I have done that to figure a lot of things out like saving/loading data.)

hope that is a good enough primmer to get you going!

Thx for the start man. I got the game to 'see' my plugin. "Testwindow" but it wont load

TestWindow.lua
Code:
import "Turbine"
import "Turbine.UI"
import "Turbine.UI.Lotro"

Window = class( Turbine.UI.Window )

function Window:Constructor()
    Turbine.UI.Lotro.Window.Constructor( self )
    self:SetVisible( true )
    
    --I Setup Window Data
    self:SetSize( 200, 150 )
    self:SetBackColor( Turbine.UI.Color() )
    self:SetPosition( 25, 150 )
    self:SetText( "Hello World!" )
end
_init_.lua
Code:
import "Gramps.Window.TestWindow";
main.lua
Code:
import "Gramps.TestWindow"

window = Window()
Reply With Quote
  #5  
Unread 12-30-2010, 07:26 AM
D.H1cks's Avatar
D.H1cks D.H1cks is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Apr 2007
Posts: 162
Quote:
_init_.lua
Code:
import "Gramps.Window.TestWindow";
I think the problem is you are pointing to an incorrect path. Do you have a subfolder called Window in your Gramps folder? Let me explain...

I am gonna guess that your .plugin file points to Gramps.TestWindow.main.

Which then looks in the Gramps\TestWindow\main.lua file and sees that it needs to load the Gramps.TestWindow folder, which means the _init_.lua file. So that file looks for the following file: Gramps\Window\TestWindow.lua.

So this would mean you have the following folder layout:

Gramps
  • TestWindow.plugin
    TestWindow
    • _init.lua
      main.lua
    Window
    • TestWindow.lua.

At least, that is what I can gather. If you have the TestWindow file in the same folder as the rest, then simply change the line in the _init_.lua file to:

import "Gramps.TestWindow.TestWindow";

Hope that makes sense.
Reply With Quote
  #6  
Unread 12-30-2010, 01:10 PM
Gramps Gramps is offline
The Indomitable
 
Join Date: Aug 2007
Posts: 12
Makes perfect sense thanks man.

Making progress.

.d of the Rings Online\Plugins\Gramps\Window\Main.lua:2: Unable to resolve package "Gramps.TestWindow".

I'll dig around a bit and see what I can find out. I honesty spent several hrs yesterday looking though author's plugins, turbine examples, editing turbine examples ect. Thx for the help!


Problem was in my Window.Plugin (pluginsfile) Changed package to Testwindow from Window.

the Rings Online\Plugins\Gramps\TestWindow\main.lua:4: attempt to call global 'Window' (a nil value)
Rings Online\Plugins\Gramps\TestWindow\Main.lua:2: Failed to import package "Gramps.TestWindow.main".

Two new ones now. I'll continue to dig

Got it

Thx man. You really got me motivated to dig into this stuff.

Last edited by Gramps : 12-30-2010 at 01:31 PM.
Reply With Quote
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is this real, or was my account here hacked? cyberpotato Site help, bugs, suggestions/questions 4 10-07-2010 01:37 PM
A few basic questions Dain93 General Authoring Discussion (L) 2 01-21-2009 01:19 AM
A few basic modding questions Xodarap777 Interface Help (D) 1 01-01-2009 01:52 PM
Learning the basic? Amrod General Authoring Discussion (L) 3 08-12-2007 06:13 AM
Basic UI fawnanubis Interface Requests (L) 7 06-21-2007 08:58 AM


All times are GMT -5. The time now is 11:16 AM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui