can someone tell me the command so I can make programs like:
'program 19' or
'build house 5 3 10'
instead of having to rely on input = read()
?
I've been hunting this down forever and haven't figured it out or found it yet, so it would be nice if someone could tell me, if nobody can then thats okay, thanks for your time.
since the site wont let me post this question unless i got something to help fix the problem, ill put a code that would use it that currently uses the read method.
input = read()
if input == "right" then
for k, v in ipairs(peripheral.getMethods(input)) do
print(k,", ",v)
end
I think that code would be cooler if I could do 'scan right' instead of 'scan' 'right'
It sounds like you're asking how to access arguments and parameters passed into your computercraft program. From what I can find on the interweb, arguments passed in from the computercraft prompt are collected into a variadic parameter list denoted with ...
on the outermost scope.
That likely means computercraft scripts accesses that parameter list the same way any vanilla lua script would. For example,
local arg1, arg2, arg3 = ...
print(arg1, arg2, arg3)
That will grab the first three arguments passed in with arg1
taking the first argument, arg2
taking the second and so on. If there's less than three given the extra corresponding argn
will be nil
.
To work with an arbitrary number of arguments passed in just wrap the variadic list with a table. eg.
local inputs = {...}
print(select('#', ...) .. " arguments received:")
for i, v in ipairs(inputs) do
print(i, ",", v)
end