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'
Right-clicking on the Computer brings up the CraftOS command line (CraftOS is the default operating system for computers); it's from here where most users run programs on their computers.
ComputerCraft is a mod for minecraft that adds computer consoles with which you can create complex Redstone switching systems. It uses the scripting language Lua for all of its programming and it is compatible with RedPower, which is recommended for the best experience.
But note that Minecraft ComputerCraft may provide a different function than the standard os. exit one. Show activity on this post. You can also terminate it manually by holding down Ctrl + T a few seconds in the turtle/computer's interface.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With