Jump to content


Luca_S

Member Since 09 Nov 2014
Offline Last Active Apr 26 2020 01:00 PM
*****

Posts I've Made

In Topic: Attempt to call a nil

26 April 2020 - 01:03 PM

Can you please post your complete code and the full error you are getting?
Without seeing all the code I'd guess that surface.create is not defined.

In Topic: get rf capacity from cells in table nil

28 March 2020 - 08:55 AM

getNames() returns a table of strings containing the names of the peripherals. So your cells table will look something like this:

{
  "thermalexpansion:storage_cell_1",
  "thermalexpansion:storage_cell_2",
  "thermalexpansion:storage_cell_3",
  "thermalexpansion:storage_cell_4",
  "thermalexpansion:storage_cell_5",
}

So to call the getRFCapacity method, you'll need to wrap the peripherals first. Instead of doing
table.insert(cells, name)
you can just do
table.insert(cells, peripheral.wrap(name))

In Topic: How to detect which dimension & world my turtle is inside?

25 March 2020 - 08:17 AM

AFAIK there is no builtin way to do that. You could however do something similar to the GPS program and have a server in each dimension responding to PINGs with the dimension it's in(Or patch that into the already existing GPS Program).

Because the modem_message event doesn't provide a distance if the message is coming from another dimension you can determine which response came from a server within your current dimension.

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

19 March 2020 - 04:32 PM

You should not use string.find() to check if a peripheral is of a certain type, you should change your code to do this(Also make all variables that can be local local):
Edit: Also once you've found that your peripheral is of a desired type and adding it to the peripherals table, there's no need to check for the rest of the peripherals, so you can break after inserting to the peripherals table.
local periphlist = peripheral.getNames()
local desired = {
"inset peripheral name here"
}
local peripherals = {}
for p=1,#periphlist do
   for t=1,#desired do
	  if peripheral.getType(periphlist[p]) == desired[t] then
	   peripherals[#peripherals+1] = periphlist[p]
	   break
	 end
   end
end

In Topic: how do I look up an entry in a table?

17 March 2020 - 11:01 AM

Maybe something like this:
local t = {
  [3] = {
	count = 32,
	name = "minecraft:cobblestone",
	damage = 0
  }
}

local res
for k, v in pairs(t) do
  if v.name == "minecraft:cobblestone" then
	res = k
	break
  end
end
print("cobblestone goes into slot " .. res)

EDIT: Be aware that this will only find one result of course, also iirc pairs is not deterministic, so if you have multiple minecraft:cobblestone it might find a random one each time