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 01-24-2011, 10:47 PM
MuNkEy MuNkEy is offline
The Wary
Interface Author - Click to view interfaces
 
Join Date: Jan 2011
Posts: 2
Shell cmd w/ multiple args

I'm trying to expand on to a simple LUA script I wrote (my first time working with LUA) to allow multiple arguments to be passed to it. The problem I'm running into is it seems that the way I'm doing it gives one argument regardless of what I type (I ran into a similar problem when first writing it where the argument wouldn't be nil when nothing was passed to it).

Here's my script:
Code:
import "Turbine"

AhCmd = Turbine.ShellCommand();

function AhCmd:Execute(cmd, arg1, arg2)
	if ( type(tonumber(arg1)) == "number"  and  arg2 == nil ) then
		AhCmd:AhCalc(arg1);
	elseif ( type(tonumber(arg1)) == "number" and type(tonumber(arg2)) == "number" ) then
		AhCmd:AhCalc(arg1, arg2);
	else
		AhCmd:GetHelp();
	end
end

function AhCmd:AhCalc(buyout, bid)
	if (bid == nil) then
		Turbine.Shell.WriteLine( "<rgb=#00FF00>Set Buyout to</rgb> <rgb=#FFFF00>" .. math.floor( ( buyout/0.95)*(10^2) )/(10^2) .. "s</rgb> <rgb=#00FF00>to get</rgb> <rgb=#80FF00>" .. buyout .. "s</rgb>" );
	else
		Turbine.Shell.WriteLine( "<rgb=#00FF00>Set Starting Bid to</rgb> <rgb=#FFBF00>" .. math.floor( ( bid/0.95)*(10^2) )/(10^2) .. "s</rgb><rgb=#00FF00>, Buyout to</rgb> <rgb=#FFFF00>" .. math.floor( ( buyout/0.95)*(10^2) )/(10^2) .. "s</rgb> <rgb=#00FF00>to get between</rgb> <rgb=#80FF00>" .. bid .. "s</rgb> <rgb=#00FF00>and</rgb> <rgb=#80FF00>" .. buyout .. "s</rgb>" );
	end
end

function AhCmd:GetHelp()
	Turbine.Shell.WriteLine( "Syntax: /ah <price>" );
end

Turbine.Shell.AddCommand( "ah", AhCmd );
The script accurately acknowledges 1 argument, but will just return the help text if 2 are is sent.
I know could just add a 2nd command specifically written to accept 2 args, but I really want just 1 command to work for everything

Last edited by MuNkEy : 01-24-2011 at 10:50 PM.
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
function Backpack:ItemMoved(sender, args); MrJackdaw Lua Programming Help (L) 0 11-21-2010 02:28 AM
Multiple Skindefinition.XML per UI Deewe LotRO Wish List (L) 2 09-29-2007 03:25 PM
Help with loading multiple UIs Crumby Interface Help (L) 0 07-06-2007 06:45 PM


All times are GMT -5. The time now is 08:13 PM.


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