Jump to content


qwerty

Member Since 28 Feb 2017
Offline Last Active Jun 10 2020 10:20 PM
-----

Topics I've Started

[SOLVED] how do I filter peripherals in list = peripheral.getNames()

19 March 2020 - 11:30 AM

it amuses me that I'm the only one asking for help here.

On to the point, how do I filter a table of contents efficiently?
I have a list of peripherals attached in a table and I have potentially hundreds of peripherals on the network, however, all are not equal.
some are disk drives others are monitors, but I have a table with the peripherals that I need access to, and it looks a lot like this;
list = {
"immersiveengineering:storage_crate",
"minecraft:chest",
"thermalexpansion:storage_cache"
}
and here's a table that has the peripherals attached;
periph = {
"right",
"top",
"immersiveengineering:storage_crate_1",
"minecraft:chest_3"
}

so my question is; how do I determine that periph[item] equals list[any]?
thanks in advance.

with regards,
-qwerty

how do I look up an entry in a table?

16 March 2020 - 04:04 PM

How do I search a table for specific keys? I have read the 5.1 reference manual, but there's just too much to keep in track of.

specifically, I need to copy sub-tables from peripheral.getNames() to a different table.
since I'm making an inventory management program I need to keep track of where items are and since iterating trough a table is easier than polluting the global environment or hard coding things.

thanks in advance!

with regards,
-qwerty

[SOLVED]attempt to call global 'index' a table value.

25 February 2020 - 10:46 AM

that is the error I'm getting from this;
function index()
  if index ~= nil then
	index = nil
	index = inventory.list()
  else inventory.list()
  end
end
why is that?
as the name implies this is just a function used to update the index table of all items inside a chest.

[SOLVED]how do I reference a table inside another?

25 February 2020 - 08:01 AM

It amuses me that I'm the only one starting threads here since the 20th, anyway- here's where I'm stuck yet again.
how do I reference a table within a different one?

this is what I got so far
sh = {} --[[sh stands for shorthand because I'm making a turtle crafting interface]]


sh["cbl"]="minecraft:cobblestone"


furnace = {
  sh:cbl, sh:cbl, sh:cbl, nil,
  sh:cbl, nil, sh:cbl, nil,
  sh:cbl, sh:cbl, sh:cbl, nil,
}
however you might notice that this doesn't work.
I've tried throwing everything but the kitchen sink of simple solutions but it looks like I'll have to use advanced techniques.

with regards
-qwerty

how do I autowrap peripherals on wired network?

24 February 2020 - 11:53 PM

Once more I am asking for your divine guidance with a problem of peripherals.
namely: how do I automatically wrap them when -the computer turns on or when a new peripheral is attached via wired modem.

so far I've come up with using string.find() to compare things, but peripheral.getNames() gives a table so that's more manipulation than I know. besides, trying to detect witch reference instance was found is rather difficult for me.

case and point: this is what I'm trying to accomplish.
reference = {chest, crate, cache}
List =  peripheral.getNames()

--code I have no idea on how to construct--

pointer = peripheral.wrap(*inventory from list*)
reference_id** = pointer

-- ** > the reference and id are to be used as pointers to selected inventory --

P.S. I'm using cc:tweaked if it wasn't allready obvious

with regards
-qwerty