Jump to content


valithor's Content

There have been 4 items by valithor (Search limited from 30-March 23)


By content type

See this member's

Sort by                Order  

#279405 how do I look up an entry in a table?

Posted by valithor on 25 March 2020 - 02:33 AM in Ask a Pro

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"



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

Posted by valithor on 25 March 2020 - 02:23 AM in Ask a Pro

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



#279403 Which server do you use to host a server with CC mod ?

Posted by valithor on 25 March 2020 - 02:19 AM in Ask a Pro

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/



#278939 CC seems to be dead.

Posted by valithor on 17 April 2019 - 08:44 PM in General

View PostMrObsidy, on 17 April 2019 - 07:46 PM, said:

Not sure this is the correct way to say it, but this mod seems dead. I have not seen a major version updates in a while and the last tutorial article was so old that I saw it as read (I did not frequent this account in a large while.)

Farewell CC, I had some fun times with you.

The forums are fairly dead, but there is a fairly active community around the switchcraft server. The mod went open source a while ago, so there hasn't been official versions, but there has been many unofficial versions of the mod.