This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
todworngenlp's profile picture

CC Request Logic Pipe Program

Started by todworngenlp, 28 January 2018 - 06:50 PM
todworngenlp #1
Posted 28 January 2018 - 07:50 PM
Hello CC Community ^^

I wanted to make an CC Programm for requesting Items over Logistic Pipes and i found something on the Internet what would Need me to always Change the itemID via an Editor and i wanted to make it to an Programm which lets me Input the ItemID (minecraft:stone) and Amount.

Now I am getting an

"Java Exception Thrown: Java.lang.NullPointerException" Error

I using CraftOS 1.7 on MC 1.7.10


textutils.slowPrint("Was wird gebraucht?")
print("Item:")
input = read(itemID)
print("Amount:")
imput = read(amount)
lp = peripheral.wrap("left")
local function packager ( itemID, amount )
local result = lp.getLP().getItemIdentifierBuilder()
result.setItemID( itemID )
lp.makeRequest( result.build(), amount )
end
packager( itemID , amount )

Am I doing something wrong with the variables? Or is it just an completely wrong coded Programm.
Dog #2
Posted 29 January 2018 - 02:36 AM
I can't speak to the logistics pipes code, but your use of read() is incorrect. read() spits out a string that you capture in a variable, like so…

itemID = read()

Since the second variable you're using for input should be a number, I would recommend using tonumber() to convert it to a number, like so…

amount = tonumber(read())

Here's more info on read, via the ComputerCraft Wiki.
Edited on 29 January 2018 - 01:37 AM
todworngenlp #3
Posted 29 January 2018 - 05:14 PM
@Dog

Thanks for the help ^^
Didnt now there is a tonumber() that converts it to an number :(/>

With best regards Todworngenlp ^^
———————————–
Thread can be closed ^^