Post by me3you2 on Dec 15, 2005 22:51:52 GMT -5
My first attempt at a script was a simple one. But I started to get sidetracked so i'll just post some random parts of it that others may find helpful.
This is a function that I wrote to get any arguments passed to the script
Check arguments passed
Just easier to write then Windower.console_Write()
Get any commands passed with
'.Lunar command script.lua COMMAND'
Check if command found
This function needs some work.
Usage:
This is a function that I wrote to get any arguments passed to the script
'.Lunar load script.lua ARGUMENTS'
function GetArguments()
ArgArray = {}
ArgCount=Windower.script_GetArgCount( )
for arg=1,ArgCount,1 do
ArgArray[arg] = Windower.script_GetArg(arg)
Windower.script_Sleep(50)
end
table.remove(ArgArray , 1) --The 1st argument is the scripts name 'script.lua'
end
Check arguments passed
function CheckArgument(ThisArray)
chkArg = {}
for CA=1,table.getn(ThisArray),1 do
chkArg[CA] = ThisArray [CA]
if chkArg[CA] == "argument" then
--Insert what to do when this argument is found.
end
end
Just easier to write then Windower.console_Write()
function wprint (text)
Windower.console_Write(text)
end
Get any commands passed with
'.Lunar command script.lua COMMAND'
function GetCommands ()
CommandCount = Windower.script_GetCommandCount( )
CommandArray = {}
if CommandCount ~= 0 then
for cmd=1,CommandCount,1 do
Command=Windower.script_GetCommand()
CommandArray[cmd] = Command
Windower.script_Sleep(500)
end
end
end
Check if command found
function CheckCommand(ThisArray)
chkCmd = {}
for CC=1,table.getn(ThisArray),1 do
chkCmd[CC] = ThisArray [CC]
if chkCmd[CC] == "command" then
--Insert what to do when command found
end
end
end
This function needs some work.
function GraphicText(Name,XPos,YPos,Color,Font,Bold,Visible)
Name=Graphics.text_CreateObject()
Graphics.text_SetPosition(XPos,YPos,Name)
if Color == Red then Graphics.text_SetColor(255,255,0,0,Name) end
if Color == Black then Graphics.text_SetColor(255,0,0,0,Name) end
if Color == White then Graphics.text_SetColor(255,255,255,255,Name) end
if Color == Yellow then Graphics.text_SetColor(255,255,255,0,Name) end
if Color == Blue then Graphics.text_SetColor(255,255,255,0,Name) end
if Color == nil then Graphics.text_SetColor(255,255,255,255,Name) end
if Font == nil then Graphics.text_SetFont("Agency FB",15,Name) end
if Bold == nil then Graphics.text_SetBold(Bold,Name) end
if Visible == nil then Graphics.text_SetVisibility(Visible,Name) end
return Name
end
Usage:
TPObject=GraphicText("TPObject",420,747,White,nil,true,1)