Jump to content


valithor

Member Since 11 May 2013
Offline Last Active Mar 31 2020 04:23 AM
****-

Posts I've Made

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

25 March 2020 - 02:33 AM

Basically it sounds like you want to take a table and build a lookup table based upon the information.

Given a table of structure:
local tbl = {
  [3] = {
	count = 32,
	name = "minecraft:cobblestone",
	damage = 0,
  },[7] = {
	count = 32,
	name = "minecraft:stone",
	damage = 0,
  },[10] = {
	count = 13,
	name = "minecraft:cobblestone",
	damage = 0,
  },
}

You could do something like this:
local lookupTbl = {}
for k,v in pairs(tbl) do --# look through each index in the table.  k will be the key, v will be the value
  if not lookupTbl[v.name] then --# check to see if we have information about the item in our lookup table already
	lookupTbl[v.name] = {} --# we haven't seen the item before so initialize the table to hold the item
  end

  table.insert(lookupTbl[v.name],{slot=k,amount=v.count} --# insert the slot and amount information into the table for fast lookup
end

This would build a table that looks something like this:
{
  [minecraft:cobblestone] = {
	{
	  slot = 3,
	  amount = 32
	},
	{
	  slot = 10,
	  amount = 13
	}
  },
  ["minecraft:stone"] = {
	slot = 7,
	amount = 32
  }
}

Using this new table you can lookup all locations of each item instantly. It then becomes a problem of looping through all of the slots to figure out how much you have.

print(lookupTbl["minecraft:cobblestone"][1].slot) --# prints "3"
print(lookupTbl["minecraft:cobblestone"][1].amount) --# prints "32"

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

25 March 2020 - 02:23 AM

Here is another solution:

list = {
["immersiveengineering:storage_crate"] = true,
["minecraft:chest"] = true,
["thermalexpansion:storage_cache"] = true
}

local periphlist = peripheral.getNames()
local peripherals = {}
for i = 1, #periphlist do
  if list[periphlist[i]] then
    table.insert(peripherals,periphlist[i])
  end
end

In Topic: Which server do you use to host a server with CC mod ?

25 March 2020 - 02:19 AM

It really depends on what version of MC you are running.

If you do not want to change server software, you may be able to find a profiler mod that allows you to do roughly what timings would do in spigot. I have never used a forge profiling mod, but this is one I found after a quick search: https://www.cursefor...kprofiler/files

If you are wanting to change the software that you are running on to one that will allow plugins below are some choices.

If you are on older versions you can use kcauldron, cauldron, MCPC+, or MCPC. I listed those in the roughly the order that I would look into using them. I really doubt you would need to use anything older than kcauldron though.

If you are able to I would suggest moving away from spigot/forge combinations altogether and use sponge. It is actively being developed, and will most likely be the most stable software to run a server on with forge.

KCauldron: 1.7.10, 1.8.9
Sponge: 1.10+

sponge: https://www.spongepowered.org/
kcauldron: https://sourceforge..../server/1.7.10/