If anyone could help been having trouble (I think) with peripherals++ . I have a chest next to a computer set as a peripheral, I getStackInSlot(1) of said chest and then I print the name and the quanity, only problem is I can't print the quanitity and don't know and can't find out how. Would be really appreciated if someone could please help. :D/>
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Help -- Getting quantity of an item in a slot of a chest.
Started by _Astro_, 17 September 2016 - 06:24 PMPosted 17 September 2016 - 08:24 PM
Hello,
If anyone could help been having trouble (I think) with peripherals++ . I have a chest next to a computer set as a peripheral, I getStackInSlot(1) of said chest and then I print the name and the quanity, only problem is I can't print the quanitity and don't know and can't find out how. Would be really appreciated if someone could please help. :D/>
If anyone could help been having trouble (I think) with peripherals++ . I have a chest next to a computer set as a peripheral, I getStackInSlot(1) of said chest and then I print the name and the quanity, only problem is I can't print the quanitity and don't know and can't find out how. Would be really appreciated if someone could please help. :D/>
Posted 18 September 2016 - 01:02 AM
Moved to Ask a Pro.
That's probably OpenPeripheral rather than Peripherals++.
That's probably OpenPeripheral rather than Peripherals++.
Posted 18 September 2016 - 01:58 AM
print( textutils.serialize( c.getStackInSlot(1) ) )
Assuming c is the wrapped chest, what does this output?
Edited on 17 September 2016 - 11:59 PM
Posted 18 September 2016 - 08:30 AM
If KingofGamesYami solution errors (it shouldn't), then try:
Sure, this solution isn't fine, but I am online on my mobile.
local serializeSafe
serializeSafe = function (tab)
for key, value un pairs(tab) do
print(key, '=', tostring(value))
if type(value) == 'table' then
serializeSafe(value)
end
end
end
Sure, this solution isn't fine, but I am online on my mobile.
Posted 19 September 2016 - 01:50 PM
fixed it for youIf KingofGamesYami solution errors (it shouldn't), then try:local serializeSafe serializeSafe = function (tab) for key, value in pairs(tab) do print(key, '=', tostring(value)) if type(value) == 'table' then serializeSafe(value) end end end
Edited on 19 September 2016 - 12:38 PM
Posted 19 September 2016 - 02:34 PM
fixed it for youIf KingofGamesYami solution errors (it shouldn't), then try:local function serializeSafe (tab) for key, value in pairs(tab) do print(key, '=', tostring(value)) if type(value) == 'table' then serializeSafe(value) end end end
You edited just
local serializeSafe;
serializeSafe = function …
to
local serializeSafe = function …
what will errors, because the function can only call itself (just in case, the function is local) if the variable is predeclared.
I meant the output wouldn't be fine.
Posted 19 September 2016 - 02:39 PM
reverted to just fix in for loop
Posted 21 September 2016 - 10:39 PM
I didn't got what you mean.reverted to just fix in for loop
Posted 21 September 2016 - 10:57 PM
The correct spelling of 'in' is in, not un. You should test your code before posting.
Posted 22 September 2016 - 12:38 PM
Oh i see, but i was online on my mobile.The correct spelling of 'in' is in, not un. You should test your code before posting.