lotrointerface.com
Search Downloads


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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Unread 09-28-2010, 06:48 AM
lerusius lerusius is offline
The Wary
 
Join Date: Sep 2010
Posts: 3
Beginners LUA Problem: Calling function located in another file

Hello! I'm a real beginner in Lua and programming. But I'd like to learn so here goes my first question!

I want to when I use /bs getsize to return the size of all bags you currently have unlocked. but I get the error
"...\Main.lua:16 : Attempting to index global 'BagspaceLeftFunction' (a nil value)"

I have marked line 16 with blue.

What I'm trying to do is to use the function BagspaceLeftFunction:BagSize() that is located in another file. Any ideas how to fix this?

_init_.lua
Code:
-- Common imports.
import "Turbine";
import "Turbine.Gameplay";
import "Turbine.UI";
import "Turbine.UI.Extensions";
import "Turbine.UI.Lotro";
import "Turbine.Utils";

--BagspaceLeft specific
import "Lerusius.BagspaceLeft.BagspaceLeft";
Main.lua
Code:
--Just for clarification on what I'm doing, changing name on
--the Turbine.Shell Command() to BSCommand
BSCommand = Turbine.ShellCommand();

--Could put this inside the Execute function but decided on having
--it here instead take a look at line 18 on how I'm using it
function BSCommand:GetHelp()
	return "This is the Help Command"
end

--adds the commands /bs or /bagspaceleft to lotro
Turbine.Shell.AddCommand("bs:bagspaceleft",BSCommand);

--Here comes the real adding of commands to the plugin. for example
--"/bs bagsize" will call the command BagspaceLeft:BagSize() that lies in
--BagspaceLeft.lua
function BSCommand:Execute( command, arguments)
	if (arguments=="getsize") then
		BagspaceLeftFunction:BagSize();
	elseif (arguments == "help") then
		Turbine.Shell.WriteLine(self:GetHelp());
	end
end

--Welcome Message when loading the plugin
Turbine.Shell.WriteLine("BagspaceLeft by Lerusius");
BagspaceLeft.lua
Code:
function BagspaceLeftFunction:BagSize()
	local player = Turbine.Gameplay.LocalPlayer();
	self.backpack = player:GetBackpack();
	Turbine.Shell.WriteLine (self.backpack:GetSize());
end
Reply With Quote
 



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
Lua General Forum Bredic Lua Programming Help (L) 3 09-12-2010 02:34 AM
Lua Plug-in and UI? Elentir Interface Help (L) 4 09-09-2010 02:42 PM
I wrote a Lua plugin, now what? scrappy General Authoring Discussion (L) 3 09-08-2010 10:06 AM
Lua support coming to LOTRO Sparr General Authoring Discussion (L) 33 08-05-2010 07:52 PM
Lua support coming to LOTRO's UI! Dolby News 1 07-15-2010 09:36 AM


All times are GMT -5. The time now is 01:29 PM.


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