Posted 09 March 2013 - 12:32 PM
Title: Running a program with arguments
I have what would most likely be an incredibly easy question, but i'm new to lua, and I can't find anyone who has explained it. I basically have 2 programs, the main program("startup"), and the second program("crush") which I use for more redstone work, and together they make up a mob trap system.
What I want to do is pass a variable from the startup program, to the crush program. I know I can do:
local integer = 1
shell.run("crush", integer)
but I do not know how to receive it. I believe I have to create a function in the crush program:
function mobCrush(…)
{
print(integer)
}
In this case, I want the program to send the variable(integer) and then print it in the crush program (function/method if I have to use one). I am not sure if I have to use a function/method, but if someone would please be able to explain it to me it would be much appreciated.
P.S. I apologize if this was unclear, I am sort of new to programming in java, and I have not yet grasped the lua terms, so I hope someone can understand what I am trying to do.
I have what would most likely be an incredibly easy question, but i'm new to lua, and I can't find anyone who has explained it. I basically have 2 programs, the main program("startup"), and the second program("crush") which I use for more redstone work, and together they make up a mob trap system.
What I want to do is pass a variable from the startup program, to the crush program. I know I can do:
local integer = 1
shell.run("crush", integer)
but I do not know how to receive it. I believe I have to create a function in the crush program:
function mobCrush(…)
{
print(integer)
}
In this case, I want the program to send the variable(integer) and then print it in the crush program (function/method if I have to use one). I am not sure if I have to use a function/method, but if someone would please be able to explain it to me it would be much appreciated.
P.S. I apologize if this was unclear, I am sort of new to programming in java, and I have not yet grasped the lua terms, so I hope someone can understand what I am trying to do.