Jump to content




Chest/inventory Peripherals


  • You cannot reply to this topic
68 replies to this topic

#1 Noobular

  • Members
  • 86 posts

Posted 11 September 2014 - 03:41 AM

I was curious if i would be able to use a peripheral to look at everything in the chest,
like everything listed out so i can put them all on a monitor to show everything i have, I know it's possible i've seen it done but i'd like to see if i'd be able to do it with single chest or an ME system...

Purpose: Making an automated shop and that's pretty much the last bit i need.


Any help would be greatly appreciated!!!

#2 hilburn

  • Members
  • 153 posts
  • LocationLondon, England

Posted 11 September 2014 - 10:42 AM

If you have OpenPeripherals then yes, this is doable. However for "remote" chests (ones not adjacent so you are using modems) you will need to use the OpenP Peripheral Proxy block to connect to it. There are also methods to support AE systems, as well as automatically craft and pull items from it

#3 Noobular

  • Members
  • 86 posts

Posted 12 September 2014 - 12:33 AM

I was thinking maby trying to make it like a vending machine like setting them up around the areas of the map so i get more people purchasing and selling , then use Enderchest to set it to the specific machine..

#4 Noobular

  • Members
  • 86 posts

Posted 12 September 2014 - 04:33 AM

Oh, i didnt realize i didn't say it , i don't know exactly how to use the proxy block along with calling the getInventorySize and stuff like that , Peripheral Functions

#5 hilburn

  • Members
  • 153 posts
  • LocationLondon, England

Posted 12 September 2014 - 11:27 AM

Point the Proxy at the chest, attach a wired modem to the back, right click it to activate. You will get something like "chest_0 connected" appear in chat. That s the peripheral "side" you should wrap to allow you to call the chest methods

#6 Noobular

  • Members
  • 86 posts

Posted 13 September 2014 - 08:23 PM

I cant seem to get any of the commands for them to work... I don't exactly know specifically how to make them connected like a monitor nor if the commands are being used right.

#7 Noobular

  • Members
  • 86 posts

Posted 13 September 2014 - 08:33 PM

The code is simply this.
local p = "me_drive_0"
p.getTotalItemBytes()

It constantly says it attempts to call nil
Am I supposed to be putting arguments inside the getTotalItemBytes()?

#8 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 13 September 2014 - 10:41 PM

If it's saying attempt to call nil then that means that getTotalItemBytes does not exist, try using
for key, value in pairs(peripheral.getMethods("me_drive_0")) do
  print(key.." "..value)
end
to get the methods you can call

#9 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 13 September 2014 - 11:11 PM

Noobular - you aren't actually wrapping the ME drive as a peripheral.

Change this...
local p = "me_drive_0"

to this...
local p = peripheral.wrap("me_drive_0")


#10 Noobular

  • Members
  • 86 posts

Posted 14 September 2014 - 12:33 AM

i tried that before and it still didnt work for what ever reason.

Also dragon, I grabbed someones Show Peripherals program so thats how i got it.

#11 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 14 September 2014 - 12:50 AM

View PostNoobular, on 14 September 2014 - 12:33 AM, said:

i tried that before and it still didnt work for what ever reason.
...
'for what ever reason' doesn't really help us help you - an exact error message would be very helpful. FWIW, what I suggested is the correct way to wrap a peripheral - what you were trying will not work. Are you sure the peripheral you are trying to wrap is actually named "me_drive_0" ?

Dragon may know who's 'Show Peripherals' program you used, but I don't. If correctly wrapping the device (with the correct name) still doesn't work, would you please run his code and tell us what is returned?

Edited by Dog, 14 September 2014 - 12:56 AM.


#12 Noobular

  • Members
  • 86 posts

Posted 14 September 2014 - 01:10 AM

Well i guess it seems to be actually running the code without problems... How would i write out the Function: TABLENAME to a text? ...

#13 Noobular

  • Members
  • 86 posts

Posted 14 September 2014 - 03:53 AM

This might help, basicly when i press the button and run the CheckItems() function it just doesn't think it exist.
Posted Image
Posted Image

#14 Noobular

  • Members
  • 86 posts

Posted 14 September 2014 - 04:05 AM

Crap... I took the picture of the code after the mess up , its actually line 70, Sorry.

After further inspection of the monitor , it writes it out but it just dies after it does...Posted Image

#15 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 14 September 2014 - 05:45 AM

line 70 is
m.write(slot.name)

I'm guessing that slot.name is not a valid variable name. That would result in the error you are seeing.

#16 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 14 September 2014 - 09:34 AM

Or more specifically, that "slot" isn't a table that can be indexed into.

Perhaps if you changed line 69 to check the existence of "slot" instead of "CurrSlot"...

#17 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 14 September 2014 - 03:40 PM

View PostBomb Bloke, on 14 September 2014 - 09:34 AM, said:

Or more specifically, that "slot" isn't a table that can be indexed into.
...
Thank you for clarifying and correcting me, Bomb Bloke :)

#18 Noobular

  • Members
  • 86 posts

Posted 14 September 2014 - 08:32 PM

Actually... it turns out that when it is going over the catagory.getStackInSlot() it hits a nil then it stops it self, but i changed the code to
function CheckItems(s)
    local InvSize = Catagory.getInventorySize()
for CurrSlot = 1, InvSize-1 do
   local slot = C1.getStackInSlot(CurrSlot)
  if CurrSlot == nil then -- cycling
   m.write("Nothing")
   else
	 m.setCursorPos(1,CurrSlot+2)
   m.write("|"..slot.name)
   m.setCursorPos(25,CurrSlot+2)
   m.write(""..slot.id.."")
   m.setCursorPos(33,CurrSlot+2)
   m.write(""..slot.qty)
    end
end
end

but for some reason it still wont like stop error....

#19 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 14 September 2014 - 08:43 PM

View PostNoobular, on 14 September 2014 - 08:32 PM, said:

Actually... it turns out that when it is going over the catagory.getStackInSlot() it hits a nil then it stops it self, but i changed the code to
...
but for some reason it still wont like stop error....
You need to move your check for nil before your first invocation of the variable, like so...
if CurrSlot == nil then
  m.write("Nothing")
else
  local slot = C1.getStackInSlot(CurrSlot)
  m.setCursorPos(1,CurrSlot+2)
  m.write("|"..slot.name)
  --# rest of code

Edited by Dog, 14 September 2014 - 08:43 PM.


#20 Noobular

  • Members
  • 86 posts

Posted 14 September 2014 - 10:38 PM

Posted Image
Current Code :
Posted Image

It's still just ending it self basicly once it hits an empty slot.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users