-
- for x = -1,1 do
- for y = -1,1 do
- for z = -1,1 do
- --index only direct neighbors
- if not (math.abs(x)+math.abs(z) > 1) or (math.abs(x)+math.abs(z) == 0) then
- local r_type = ""
- local i = vector.add(pos,vector.new(x,y,z))
- local execute_collection = true
- if r_index[i.x] and r_index[i.x][i.y] then
- if r_index[i.x][i.y][i.z] then
- execute_collection = false
- end
- end
- --[[ EXPLANATION
- we run through the groups
- 1 redstone_torch overrides dust if defined
- 2 torch_directional overrides torch if defined
- 3 redstone activation is bolted on with directional overriding general
-
- this is to prevent weird behavior
-
-
- This new method also uses a table bolted onto the x,y,z positional data value
- what does this mean?
- It's much easier to work with and modify
- ]]--
-
- if execute_collection == true then
- --index dust
- if get_group(i,"redstone_dust") > 0 then
- --add data to both maps
- if not r_index[i.x] then r_index[i.x] = {} end
- if not r_index[i.x][i.y] then r_index[i.x][i.y] = {} end
- r_index[i.x][i.y][i.z] = {dust = true,level = 0} --get_group(i,"redstone_power")}
- --the data to the 3d array must be written to memory before this is executed
- --or a stack overflow occurs!!!
- --pass down info for activators
- redstone.collect_info(i,get_group(i,"redstone_power"))
- end
- --index power sources
- if get_group(i,"redstone_torch") > 0 then
- if not r_index[i.x] then r_index[i.x] = {} end
- if not r_index[i.x][i.y] then r_index[i.x][i.y] = {} end
- r_index[i.x][i.y][i.z] = {torch = true,power=get_group(i,"redstone_power")}
- end
- --index directional power sources (Like repeaters/comparators)
- --only outputs forwards
- if get_group(i,"torch_directional") > 0 then
- if not r_index[i.x] then r_index[i.x] = {} end
- if not r_index[i.x][i.y] then r_index[i.x][i.y] = {} end
- r_index[i.x][i.y][i.z] = {torch_directional = true, dir = get_node(i).param2 , power = get_group(i,"redstone_power")}
- end
-
- --index directional activators (Like repeaters/comparators)
- --only accepts input from the back
- if get_group(i,"redstone_activation_directional") > 0 then
- --print("indexing directional")
- if not r_index[i.x] then r_index[i.x] = {} end
- if not r_index[i.x][i.y] then r_index[i.x][i.y] = {} end
- if not r_index[i.x][i.y][i.z] then r_index[i.x][i.y][i.z] = {} end
- --r_index[i.x][i.y][i.z].activate = false
- r_index[i.x][i.y][i.z].redstone_activation = true
- r_index[i.x][i.y][i.z].directional = true
- r_index[i.x][i.y][i.z].dir = get_node(i).param2
- end
-
- --index objects that activate
- if get_group(i,"redstone_activation") > 0 then
- if not r_index[i.x] then r_index[i.x] = {} end
- if not r_index[i.x][i.y] then r_index[i.x][i.y] = {} end
- if not r_index[i.x][i.y][i.z] then r_index[i.x][i.y][i.z] = {} end
- --r_index[i.x][i.y][i.z].activate = false
- r_index[i.x][i.y][i.z].redstone_activation = true
- r_index[i.x][i.y][i.z].name = get_node(i).name
-
-
- --set_powered_state(i)
-
- --local powered = get_powered_state(i)
-
-
- --print("powered:"..powered,"oldpowered:"..old_powered)
-
- --r_index[i.x][i.y][i.z].powered = powered
- --r_index[i.x][i.y][i.z].old_powered = old_powered
-
- --split this into update up and down
- --if powered > old_powered then
- -- r_index[i.x][i.y][i.z].deactivate = true
- ---elseif powered > 0 and old_powered == 0 then
- -- r_index[i.x][i.y][i.z].deactivate = true
- --end
- end
- end
- end