Quantcast LoTROInterface - View Single Post - Beginners LUA Problem: Calling function located in another file
View Single Post
Unread 09-28-2010, 11:23 AM
rushl rushl is offline
The Indomitable
Interface Author - Click to view interfaces
Join Date: Jun 2009
Posts: 14
I did something similar for Horsey. I ran your test code, and found a few changes that should get you going. First, none of the imports in your common file are reaching the later scripts. So I removed it altogether.

For your Main.lua, I ended up with:

import "Lerusius.BagspaceLeft.BagspaceLeft";

--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"

--adds the commands /bs or /bagspaceleft to lotro

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

--Welcome Message when loading the plugin
Turbine.Shell.WriteLine("BagspaceLeft by Lerusius");
Changes in yellow. I moved the function include here, and the function call name didn't need the index.

For your BagspaceLeft.lua:

import "Turbine.Gameplay";

function BagspaceLeftFunction()
	local player = Turbine.Gameplay.LocalPlayer();
	local backpack = player:GetBackpack();
	Turbine.Shell.WriteLine (backpack:GetSize());
Here I moved the Turbine.Gameplay import to this script. Also, I changed the now shortened BagspaceLeftFunction() name. Finally, the self.backpack index won't work here, so it's now a local variable too.

Running that, I get a return of "75" when I enter /bs getsize!

Hope this helps!


Last edited by rushl : 09-28-2010 at 11:42 AM.
Reply With Quote