all help is appreciated! :D/>
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
new to cc and could use some help with functions
Started by CrimsonKnight007, 11 December 2016 - 01:00 AMPosted 11 December 2016 - 02:00 AM
So I tried to use CC today in my skyfactory 2.5 world and it looked pretty cool, so I read some more about it and i wanted to see if i could get basic information from my Immersive Engineering machines. So i was reading through the Engineer's manual and found that I can but I don't know how to use the GetInputFluidTanks() function.
all help is appreciated! :D/>
all help is appreciated! :D/>
Posted 11 December 2016 - 03:06 PM
<shameless self promotion> I wrote a great tutorial on working with peripherals from other mods.
It's not specific to your usage case, but should be enough to get you started and will run you through the steps to giving us the information we need to help.
It's not specific to your usage case, but should be enough to get you started and will run you through the steps to giving us the information we need to help.
Posted 11 December 2016 - 04:03 PM
yeah I have looked over that thread before I came to the forums and still had the same problem, it just says temp:1 attempted to call nil<shameless self promotion> I wrote a great tutorial on working with peripherals from other mods.
It's not specific to your usage case, but should be enough to get you started and will run you through the steps to giving us the information we need to help.
Posted 11 December 2016 - 06:49 PM
Attempt to call nil is covered in the sticky post:
http://www.computercraft.info/forums2/index.php?/topic/14531-read-this-post-before-asking-questions/page__pid__137905#entry137905
Specifically, you should remember that function names are case sensitive. Without seeing any of your code, it is difficult to comment on what function doesn't exist.
http://www.computercraft.info/forums2/index.php?/topic/14531-read-this-post-before-asking-questions/page__pid__137905#entry137905
Specifically, you should remember that function names are case sensitive. Without seeing any of your code, it is difficult to comment on what function doesn't exist.
Edited on 11 December 2016 - 05:59 PM
Posted 12 December 2016 - 01:51 AM
the code is very simple.
and in the engineer's manual it says the method name right there and I have looked over it enough times to know im getting the caps right
function stats = peripherals.getInputFluidTanks()
print("stats")
and in the engineer's manual it says the method name right there and I have looked over it enough times to know im getting the caps right
Posted 12 December 2016 - 02:58 AM
That code won't work at all. Care to correct it?
Edit:
Gah, thought you were someone else offering an "example".
You meant to do something like this:
Edit:
Gah, thought you were someone else offering an "example".
You meant to do something like this:
local myPeripheral = peripheral.wrap("<tankSide>") --# Wrap peripheral.
stats = myPeripheral.getInputFluidTanks() --# Call wrapped peripheral's function, assign result to variable.
print(stats) --# Print variable's contents.
Edited on 12 December 2016 - 06:54 PM
Posted 12 December 2016 - 10:58 AM
I think you could fix your problem by reading the PIL, for example https://www.lua.org/pil/4.1.html
You could also find lua examples on the forums here, and elsewhere. Basically, the problem is that the code you showed has invalid syntax in it.
You could also find lua examples on the forums here, and elsewhere. Basically, the problem is that the code you showed has invalid syntax in it.
Posted 12 December 2016 - 01:30 PM
Before using a peripheral, you have to tell the program where it is in relation to the computer.
Here's a basic example writing some text to a monitor:
Here's a basic example writing some text to a monitor:
local mon = peripheral.wrap( "right" ) --# the monitor is assumed to be to the right of the computer
mon.write( "Hello World!" )
Posted 12 December 2016 - 02:01 PM
ok ill try that when i get home, im at school rn
Posted 12 December 2016 - 08:17 PM
Ok, I think i'm on the right track, it doesn't throw an error but, it doesn't display anything at all…
here is my code:
here is my code:
local refinery = peripheral.wrap("back")
refinery.getInputFluidTanks()
Posted 12 December 2016 - 08:30 PM
When you call refinery.getInputFluidTanks(), it returns a value, but if you want something done with that value then you need to specify. Eg:
It may pay to read up on functions and assignments.
print(refinery.getInputFluidTanks())
It may pay to read up on functions and assignments.
Posted 12 December 2016 - 08:55 PM
when i run that code it just prints a (what looks to be)random string of characters
Posted 13 December 2016 - 08:17 AM
It'd be much more helpful if you told us what they are.
But let's assume you're told it's a table, and say to try it like this:
http://lua-users.org/wiki/TablesTutorial
http://www.computercraft.info/wiki/Textutils.serialize
But let's assume you're told it's a table, and say to try it like this:
print( textutils.serialise( refinery.getInputFluidTanks() ) )
http://lua-users.org/wiki/TablesTutorial
http://www.computercraft.info/wiki/Textutils.serialize