Jump to content




Chest inventory on moniotr


6 replies to this topic

#1 lightjello

  • Members
  • 3 posts

Posted 24 January 2014 - 07:47 PM

Ive been searching around for a pretty simple code that updates chest inventory on a monitor. Could someone put me in the right direction? Thanks guys

#2 6677

  • Members
  • 197 posts
  • LocationCambridgeshire, England

Posted 25 January 2014 - 08:20 AM

Computers dont know the inventories of chests, so with vanilla computercraft you can't

#3 CometWolf

  • Members
  • 1,283 posts

Posted 25 January 2014 - 08:27 AM

Let's try to be helpfull here shall we? What 6677 is saying is true, however if you have openPeripherals or openCCSensors installed, this is very much possible. Seeing as he has CC installed, chances are he probably has one of those aswell.

#4 lightjello

  • Members
  • 3 posts

Posted 25 January 2014 - 09:53 AM

I have ccsensors. I put a sensor by the chest and when i get on the computer and type /ccSensors/console it gives me the options. I target the chest and it tells me whats in the chest when i hit getreadings. My problem is i want this information to just auto update on a monitor whats in the chest without me having to push the getreading. Any help would be much appreciated. I also have skype if you are willing to work with me. Thanks.

Heres a picture i have of what i want on the monitor but i just want the readings and i dont want to have to hit getReading to update whats in the chest.

Edited by lightjello, 25 January 2014 - 05:52 PM.


#5 surferpup

  • Members
  • 286 posts
  • LocationUnited States

Posted 25 January 2014 - 11:52 PM

You can do a few things here.
  • You can read the chest periodically using the sleep function
  • You can read the chest on demand using a touch event on advanced monitors.
You will, of course, have to come up with a way to display the contents in some ordered fashion on your monitor (monitor.setScale() is your friend).

Here is a sketch:


local inventoryTable {}
function updateInventory()
  -- set inventoryTable = get readings
end

function updateDisplay()
   --do pretty printing of inventoryTable items
end

-- Main Loop

local interval = 15 -- update interval in seconds
local myTimer = os.timer(interval)
while true do
  event,timer = os.pullEvent()
  if (event == "timer" and timer == myTimer) or event == "monitor touch" then
    updateInventoryFunction()
    displayInventoryFunction()
    myTimer = os.timer(interval)
  end
end


Give that a try. I am not familiar enough with ccsensors to know the precise functions, but the logic will work for you.

#6 lightjello

  • Members
  • 3 posts

Posted 26 January 2014 - 10:05 AM

Thanks a lot for your help. I tried putting that code in but i get [string 'Inventory"]:2: unexpected symbol.

I copied the code exactly.

#7 surferpup

  • Members
  • 286 posts
  • LocationUnited States

Posted 26 January 2014 - 04:55 PM

This is a code snippet -- an outline of code. You still need to make the functions to populate the inventory and to display them. If you are having trouble, post your code.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users