]> git.lizzy.rs Git - Crafter.git/commitdiff
Make redstone have 16 states, overhaul performance
authoroilboi <47129783+oilboi@users.noreply.github.com>
Wed, 1 Jul 2020 14:58:56 +0000 (10:58 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Wed, 1 Jul 2020 14:58:56 +0000 (10:58 -0400)
13 files changed:
mods/redstone/button.lua
mods/redstone/init.lua
mods/redstone/inverter.lua
mods/redstone/lever.lua
mods/redstone/player_detector.lua
mods/redstone/repeater.lua
mods/redstone/space_maker.lua
mods/redstone/textures/redstone_cross.png
mods/redstone/textures/redstone_dust_main.png
mods/redstone/textures/redstone_redstone_dust_line1.png [deleted file]
mods/redstone/textures/redstone_t.png
mods/redstone/textures/redstone_turn.png
mods/redstone/torch.lua

index d1b96f893c4507ec2432274c43adf27486150bad..42d50e65b8e7f2a3da3f221de856e3976363f372 100644 (file)
@@ -53,9 +53,9 @@ minetest.register_node("redstone:button_off", {
 
                local dir = minetest.wallmounted_to_dir(node.param2)
 
-               redstone.inject(pos,{torch=9})
+               redstone.inject(pos,{torch=16})
                local pos2 = vector.add(dir,pos)
-               redstone.inject(pos2,{torch=9})
+               redstone.inject(pos2,{torch=16})
 
                redstone.update(pos)
                redstone.update(pos2)
@@ -123,9 +123,9 @@ minetest.register_lbm({
                local param2 = minetest.get_node(pos).param2
                local dir = minetest.wallmounted_to_dir(param2)
 
-               redstone.inject(pos,{torch=9})
+               redstone.inject(pos,{torch=16})
                local pos2 = vector.add(dir,pos)
-               redstone.inject(pos2,{torch=9})
+               redstone.inject(pos2,{torch=16})
 
                minetest.after(0,function()
                        redstone.update(pos)
index 6bf60f6801355a4db792fc50497b840ae35f37e1..1998fb4469b2c6db6c72c160e2966c401ba7f329 100644 (file)
@@ -22,6 +22,7 @@ end)
 -- math class
 local abs   = math.abs
 local floor = math.floor
+local ceil   = math.ceil
 
 -- vector library
 local new_vec         = vector.new
@@ -83,6 +84,8 @@ dofile(path.."/capacitors.lua")
 --this is written out manually so that
 --math.abs is not needed
 local order = {
+       {x=0,y=0,z=0},
+
        {x=1, y=0, z=0}, {x=-1, y=0, z= 0},
        {x=0, y=0, z=1}, {x= 0, y=0, z=-1},
 
@@ -125,19 +128,19 @@ local table_3d
 local temp_pool
 local function create_boundary_box(pos)
        table_3d = {}
-       for x = pos.x-9,pos.x+9 do
+       for x = pos.x-16,pos.x+16 do
                if pool[x] then
-                       for y = pos.y-9,pos.y+9 do
+                       for y = pos.y-16,pos.y+16 do
                                if pool[x][y] then
-                                       for z = pos.z-9,pos.z+9 do
+                                       for z = pos.z-16,pos.z+16 do
                                                temp_pool = pool[x][y][z]
                                                if temp_pool then
                                                        if not table_3d[x] then table_3d[x] = {} end
                                                        if not table_3d[x][y] then table_3d[x][y] = {} end
 
-                                                       if (x == pos.x-9 or x == pos.x+9 or 
-                                                       y == pos.y-9 or y == pos.y+9 or 
-                                                       z == pos.z-9 or z == pos.z+9) and 
+                                                       if (x == pos.x-16 or x == pos.x+16 or 
+                                                       y == pos.y-16 or y == pos.y+16 or 
+                                                       z == pos.z-16 or z == pos.z+16) and 
                                                        temp_pool.dust and temp_pool.dust > 1 then
                                                                table_3d[x][y][z] = {torch=temp_pool.dust}
                                                        else
@@ -267,7 +270,7 @@ local directional_activator = function(pos)
        temp_pool = nil
        temp_pool2 = nil
 
-       --if not (pool[pos.x] and pool[pos.x][pos.y] and pool[pos.x][pos.y][pos.z]) then return end
+       if not (pool[pos.x] and pool[pos.x][pos.y] and pool[pos.x][pos.y][pos.z]) then return end
        
        temp_pool = pool[pos.x][pos.y][pos.z]
        
@@ -309,34 +312,33 @@ end
 local i
 local index
 local passed_on_level
-local function redstone_pathfinder(source,source_level,mem_map,output)
-       if not source_level then return end
+local x,y,z
+local function redstone_distribute(pos,power,mem_map,output)
+
+       power = power - 1
+
        --directional torches
        if output then
-               i = output
-               if i and mem_map and mem_map[i.x] and mem_map[i.x][i.y] and mem_map[i.x][i.y][i.z] then
-                       index = mem_map[i.x][i.y][i.z]
-                       --dust
-                       if index.dust then
-                               passed_on_level = source_level - 1
-                               if passed_on_level > 0 then
-                                       mem_map[i.x][i.y][i.z].dust = passed_on_level
-                                       redstone_pathfinder(i,passed_on_level,mem_map,nil)
-                               end
+               x=output.x
+               y=output.y
+               z=output.z
+               if mem_map.dust[x] and mem_map.dust[x][y] and mem_map.dust[x][y][z] then
+                       if mem_map.dust[x][y][z].dust < power then
+                               mem_map.dust[x][y][z].dust = power
+                               redstone_distribute(new_vec(x,y,z),power,mem_map,nil)
                        end
                end
        else
                --redstone and torch
                for _,order in pairs(order) do
-                       i = add_vec(source,order)
-                       if i and mem_map and mem_map[i.x] and mem_map[i.x][i.y] and mem_map[i.x][i.y][i.z] then
-                               index = mem_map[i.x][i.y][i.z]
-                               if index.dust then
-                                       passed_on_level = source_level - 1
-                                       if passed_on_level > 0 and index.dust < source_level then
-                                               mem_map[i.x][i.y][i.z].dust = passed_on_level
-                                               redstone_pathfinder(i,passed_on_level,mem_map,nil)
-                                       end
+                       i = add_vec(pos,order)
+                       x=i.x
+                       y=i.y
+                       z=i.z
+                       if mem_map.dust[x] and mem_map.dust[x][y] and mem_map.dust[x][y][z] then
+                               if mem_map.dust[x][y][z].dust < power then
+                                       mem_map.dust[x][y][z].dust = power
+                                       redstone_distribute(new_vec(x,y,z),power,mem_map,nil)
                                end
                        end
                end
@@ -371,38 +373,131 @@ end
 ]]-- sic em boy!
 local i
 local index
-local function dust_sniff(pos,mem_map,boundary)
-       for _,order in pairs(order) do
-               i = add_vec(pos,order)
+local function dust_sniff(pos,mem_map,boundary,single,origin,ignore)
+       if not single then
+               --print("all position index--")
+               for _,order in pairs(order) do
+                       i = add_vec(pos,order)
+
+                       if not mem_map[i.x] then mem_map[i.x] = {} end
+                       if not mem_map[i.x][i.y] then mem_map[i.x][i.y] = {} end
+
+                       if not mem_map[i.x][i.y][i.z] then
+                               if i and boundary and boundary[i.x] and boundary[i.x][i.y] and boundary[i.x][i.y][i.z] then
+                                       index = boundary[i.x][i.y][i.z]
+
+                                       if index.dust then
+
+                                               mem_map[i.x][i.y][i.z] = true
+
+                                               if not mem_map.dust[i.x] then mem_map.dust[i.x] = {} end
+                                               if not mem_map.dust[i.x][i.y] then mem_map.dust[i.x][i.y] = {} end
+
+                                               mem_map.dust[i.x][i.y][i.z] = index
+
+                                               dust_sniff(i,mem_map,boundary)
+                                       
+                                       elseif index.torch and index.torch > 1 then
+                                               if index.torch_directional and vec_equals(pos,index.output) then
+                                                       
+                                                       mem_map[i.x][i.y][i.z] = true
+
+                                                       if not mem_map.torch[i.x] then mem_map.torch[i.x] = {} end
+                                                       if not mem_map.torch[i.x][i.y] then mem_map.torch[i.x][i.y] = {} end
+
+                                                       mem_map.torch[i.x][i.y][i.z] = index
+
+                                                       
+                                               elseif not index.torch_directional then
+
+                                                       mem_map[i.x][i.y][i.z] = true
+
+                                                       if not mem_map.torch[i.x] then mem_map.torch[i.x] = {} end
+                                                       if not mem_map.torch[i.x][i.y] then mem_map.torch[i.x][i.y] = {} end
+
+                                                       mem_map.torch[i.x][i.y][i.z] = index
+                                               end
+                                       end
+
+                                       if index.activator then
+                                               mem_map[i.x][i.y][i.z] = true
+
+                                               if not mem_map.activator[i.x] then mem_map.activator[i.x] = {} end
+                                               if not mem_map.activator[i.x][i.y] then mem_map.activator[i.x][i.y] = {} end
+
+                                               mem_map.activator[i.x][i.y][i.z] = index
+                                       elseif index.directional_activator and vec_equals(pos,index.input) then
+
+                                               mem_map[i.x][i.y][i.z] = true
+
+                                               if not mem_map.activator[i.x] then mem_map.activator[i.x] = {} end
+                                               if not mem_map.activator[i.x][i.y] then mem_map.activator[i.x][i.y] = {} end
+
+                                               mem_map.activator[i.x][i.y][i.z] = index
+                                       end
+                               end
+                       end
+               end
+       else
+               --print("single position index")
+               
+               i = pos
+
 
                if not mem_map[i.x] then mem_map[i.x] = {} end
                if not mem_map[i.x][i.y] then mem_map[i.x][i.y] = {} end
 
                if not mem_map[i.x][i.y][i.z] then
-                       
                        if i and boundary and boundary[i.x] and boundary[i.x][i.y] and boundary[i.x][i.y][i.z] then
                                index = boundary[i.x][i.y][i.z]
-
                                if index.dust then
-                                       mem_map[i.x][i.y][i.z] = index
-                                       mem_map[i.x][i.y][i.z].sniffed = true
 
-                                       dust_sniff(i,mem_map,boundary)
+                                       mem_map[i.x][i.y][i.z] = true
+
+                                       if not mem_map.dust[i.x] then mem_map.dust[i.x] = {} end
+                                       if not mem_map.dust[i.x][i.y] then mem_map.dust[i.x][i.y] = {} end
+
+                                       mem_map.dust[i.x][i.y][i.z] = index
 
-                               elseif index.directional_activator and vec_equals(pos,index.input) then
-                                       mem_map[i.x][i.y][i.z] = index
-                                       mem_map[i.x][i.y][i.z].sniffed = true
+                                       dust_sniff(i,mem_map,boundary)
+                               
                                elseif index.torch and index.torch > 1 then
-                                       if index.torch_directional and vec_equals(pos,index.output) then
-                                               mem_map[i.x][i.y][i.z] = index
-                                               mem_map[i.x][i.y][i.z].sniffed = true
+                                       if index.torch_directional and (vec_equals(origin,index.output) or ignore) then
+                                               
+                                               mem_map[i.x][i.y][i.z] = true
+
+                                               if not mem_map.torch[i.x] then mem_map.torch[i.x] = {} end
+                                               if not mem_map.torch[i.x][i.y] then mem_map.torch[i.x][i.y] = {} end
+
+                                               mem_map.torch[i.x][i.y][i.z] = index
+
+                                               
                                        elseif not index.torch_directional then
-                                               mem_map[i.x][i.y][i.z] = index
-                                               mem_map[i.x][i.y][i.z].sniffed = true
+
+                                               mem_map[i.x][i.y][i.z] = true
+
+                                               if not mem_map.torch[i.x] then mem_map.torch[i.x] = {} end
+                                               if not mem_map.torch[i.x][i.y] then mem_map.torch[i.x][i.y] = {} end
+
+                                               mem_map.torch[i.x][i.y][i.z] = index
                                        end
-                               elseif index.activator then
-                                       mem_map[i.x][i.y][i.z] = index
-                                       mem_map[i.x][i.y][i.z].sniffed = true
+                               end
+
+                               if index.activator then
+                                       mem_map[i.x][i.y][i.z] = true
+
+                                       if not mem_map.activator[i.x] then mem_map.activator[i.x] = {} end
+                                       if not mem_map.activator[i.x][i.y] then mem_map.activator[i.x][i.y] = {} end
+
+                                       mem_map.activator[i.x][i.y][i.z] = index
+                               elseif index.directional_activator and (vec_equals(origin,index.input) or ignore) then
+
+                                       mem_map[i.x][i.y][i.z] = true
+
+                                       if not mem_map.activator[i.x] then mem_map.activator[i.x] = {} end
+                                       if not mem_map.activator[i.x][i.y] then mem_map.activator[i.x][i.y] = {} end
+
+                                       mem_map.activator[i.x][i.y][i.z] = index
                                end
                        end
                end
@@ -417,49 +512,63 @@ local power
 local boundary
 local dust_detected
 local dust_map
-local count
 local pos3
 local temp_pool3
+local directional
 local function calculate(pos,is_capacitor)
        if not is_capacitor then
                boundary = create_boundary_box(pos)
                dust_map = {}
 
+               dust_map.dust = {}
+               dust_map.torch = {}
+               dust_map.activator = {}
+
                dust_detected = false
-               count = 0
-               
-               --update needs to sniff it's own position
+
+               directional = false
+
                if boundary[pos.x] and boundary[pos.x][pos.y] and boundary[pos.x][pos.y][pos.z] then
-                       if not dust_map[pos.x] then dust_map[pos.x] = {} end
-                       if not dust_map[pos.x][pos.y] then dust_map[pos.x][pos.y] = {} end
-                       dust_map[pos.x][pos.y][pos.z] = boundary[pos.x][pos.y][pos.z]
+                       if boundary[pos.x][pos.y][pos.z].torch_directional or boundary[pos.x][pos.y][pos.z].directional_activator then
+                               directional = true
+                       end
                end
 
-               dust_sniff(pos,dust_map,boundary)
-
                -- sniff all possible dust within boundaries
-               for _,pos2 in pairs(order) do
-                       pos3 = add_vec(pos,pos2)
-                       if boundary[pos3.x] and boundary[pos3.x][pos3.y] and boundary[pos3.x][pos3.y][pos3.z] and
-                               not (dust_map[pos3.x] and dust_map[pos3.x][pos3.y] and dust_map[pos3.x][pos3.y][pos3.z] and dust_map[pos3.x][pos3.y][pos3.z].sniffed) then
-                               temp_pool3 = boundary[pos3.x][pos3.y][pos3.z]
-                               if temp_pool3.dust then
-                                       dust_sniff(pos3,dust_map,boundary)
+               if not directional then
+                       dust_sniff(pos,dust_map,boundary)
+                       for _,pos2 in pairs(order) do
+                               pos3 = add_vec(pos,pos2)
+                               if boundary[pos3.x] and boundary[pos3.x][pos3.y] and boundary[pos3.x][pos3.y][pos3.z] and
+                                       not (dust_map[pos3.x] and dust_map[pos3.x][pos3.y] and dust_map[pos3.x][pos3.y][pos3.z]) then
+                                       temp_pool3 = boundary[pos3.x][pos3.y][pos3.z]
+                                       if temp_pool3.dust then
+                                               dust_sniff(pos3,dust_map,boundary)
+                                       end
                                end
                        end
-               end
+               else
+                       dust_sniff(pos,dust_map,boundary,true,pos,true)
 
+                       local input = boundary[pos.x][pos.y][pos.z].input
+                       local output = boundary[pos.x][pos.y][pos.z].output
+
+                       if input and boundary[input.x] and boundary[input.x][input.y] and boundary[input.x][input.y][input.z] then
+                               dust_sniff(input,dust_map,boundary,true,pos)
+                       end
+                       if output and boundary[output.x] and boundary[output.x][output.y] and boundary[output.x][output.y][output.z] then
+                               dust_sniff(output,dust_map,boundary,true,pos)
+                       end
+               end
                --do torches
-               for x,datax in pairs(dust_map) do
+               for x,datax in pairs(dust_map.torch) do
                        for y,datay in pairs(datax) do
                                for z,data in pairs(datay) do
-                                       count = count + 1
                                        if data.torch then
                                                if data.torch_directional then
-                                                       redstone_pathfinder(new_vec(x,y,z),data.torch,dust_map,data.output)
+                                                       redstone_distribute(new_vec(x,y,z),data.torch,dust_map,data.output)
                                                else
-                                                       redstone_pathfinder(new_vec(x,y,z),data.torch,dust_map)
-                                                       dust_map[x][y][z] = nil
+                                                       redstone_distribute(new_vec(x,y,z),data.torch,dust_map)
                                                end
                                        end
                                end
@@ -467,22 +576,20 @@ local function calculate(pos,is_capacitor)
                end
 
                --set dust, set pool memory
-               for x,datax in pairs(dust_map) do
+               for x,datax in pairs(dust_map.dust) do
                        for y,datay in pairs(datax) do
                                for z,data in pairs(datay) do
                                        if data.dust and data.dust ~= data.origin then
                                                swap_node(new_vec(x,y,z),{name="redstone:dust_"..data.dust})
                                                data_injection(new_vec(x,y,z),data)
-                                               --delete the data to speed up next loop
-                                               dust_map[x][y][z] = nil
                                        end
                                end
                        end
                end
-
+               
                --activators
                --this must be run at the end
-               for x,datax in pairs(dust_map) do
+               for x,datax in pairs(dust_map.activator) do
                        for y,datay in pairs(datax) do
                                for z,data in pairs(datay) do
                                        if data.directional_activator then
@@ -541,9 +648,9 @@ local function player_detector_calculation()
                max = 0
                for _,player in ipairs(minetest.get_connected_players()) do
                        pos2 = player:get_pos()
-                       power = floor(10-vector_distance(pos2,pos))
-                       if power > 9 then
-                               power = 9
+                       power = floor(17-vector_distance(pos2,pos))
+                       if power > 16 then
+                               power = 16
                        elseif power < 0 then
                                power = 0
                        end
@@ -629,16 +736,17 @@ minetest.register_craftitem("redstone:dust", {
        end,
 })
 
---8 power levels 8 being the highest
-local color = 0
-for i = 0,8 do
-       local coloring = floor(color)
+--15 power levels 15 being the highest
+for i = 0,15 do
+
+       local color = floor(255 * (i/15))
+       
        minetest.register_node("redstone:dust_"..i,{
                description = "Redstone Dust",
                wield_image = "redstone_dust_item.png",
                tiles = {
-                       "redstone_dust_main.png^[colorize:red:"..coloring, "redstone_turn.png^[colorize:red:"..coloring,
-                       "redstone_t.png^[colorize:red:"..coloring, "redstone_cross.png^[colorize:red:"..coloring
+                       "redstone_dust_main.png^[colorize:red:"..color, "redstone_turn.png^[colorize:red:"..color,
+                       "redstone_t.png^[colorize:red:"..color, "redstone_cross.png^[colorize:red:"..color
                },
                power=i,
                drawtype = "raillike",
@@ -664,7 +772,6 @@ for i = 0,8 do
                end,
                connects_to = {"group:redstone"},
        })
-       color= color +31.875
 
        minetest.register_lbm({
         name = "redstone:"..i,
index a4cc2a336a93d978aa93a06c156e28304082858e..4582d88571176d7588a725ad3241732709908a70 100644 (file)
@@ -38,6 +38,7 @@ minetest.register_node("redstone:inverter_on", {
                        name = "redstone:inverter_on",
                        directional_activator = true,
                        input  = vector.subtract(pos,dir),
+                       output = vector.add(pos,dir),
                        dir = dir
                })
                redstone.update(pos)
@@ -57,13 +58,14 @@ redstone.register_activator({
                local dir = minetest.facedir_to_dir(param2)
                redstone.inject(pos,{
                        name = "redstone:inverter_off",
-                       torch  = 9,
+                       torch  = 16,
                        torch_directional = true,
                        directional_activator = true,
                        input  = vector.subtract(pos,dir),
                        output = vector.add(pos,dir),
                        dir = dir
                })
+
                redstone.update(vector.add(pos,dir))
        end
 })
@@ -79,6 +81,7 @@ minetest.register_lbm({
                        name = "redstone:inverter_on",
                        directional_activator = true,
                        input  = vector.subtract(pos,dir),
+                       output = vector.add(pos,dir),
                        dir = dir
                })
        end,
@@ -98,7 +101,7 @@ minetest.register_lbm({
 minetest.register_node("redstone:inverter_off", {
     description = "Redstone Inverter",
     tiles = {"repeater_off.png"},
-    groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,redstone_activation_directional=1,torch_directional=1,redstone_power=9},
+    groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,redstone_activation_directional=1,torch_directional=1,redstone_power=16},
     sounds = main.stoneSound(),
     paramtype = "light",
        paramtype2 = "facedir",
@@ -118,7 +121,7 @@ minetest.register_node("redstone:inverter_off", {
                local dir = minetest.facedir_to_dir(minetest.get_node(pos).param2)
                redstone.inject(pos,{
                        name = "redstone:inverter_off",
-                       torch  = 9,
+                       torch  = 16,
                        torch_directional = true,
                        directional_activator = true,
                        input  = vector.subtract(pos,dir),
@@ -144,6 +147,7 @@ redstone.register_activator({
                        name = "redstone:inverter_on",
                        directional_activator = true,
                        input  = vector.subtract(pos,dir),
+                       output = vector.add(pos,dir),
                        dir = dir
                })
                redstone.update(vector.add(pos,dir))
@@ -159,16 +163,12 @@ minetest.register_lbm({
                local dir = minetest.facedir_to_dir(minetest.get_node(pos).param2)
                redstone.inject(pos,{
                        name = "redstone:inverter_off",
-                       torch  = 9,
+                       torch  = 16,
                        torch_directional = true,
                        directional_activator = true,
                        input  = vector.subtract(pos,dir),
                        output = vector.add(pos,dir),
                        dir    = dir
                })
-               --redstone needs to warm up
-               minetest.after(0,function()
-                       redstone.update(pos)
-               end)
        end,
-})
\ No newline at end of file
+})
index 8498c8037511c4015ae67f65a467a5216639d6cb..39d8ec333fbbad6e0d5b31c731afd1d3bdf650d8 100644 (file)
@@ -64,9 +64,9 @@ minetest.register_lbm({
        action = function(pos)
                local param2 = minetest.get_node(pos).param2
                local dir = minetest.wallmounted_to_dir(param2)
-               redstone.inject(pos,{torch=9})
+               redstone.inject(pos,{torch=16})
                local pos2 = vector.add(dir,pos)
-               redstone.inject(pos2,{torch=9})
+               redstone.inject(pos2,{torch=16})
                minetest.after(0,function()
                        redstone.update(pos)
                        redstone.update(pos2)
@@ -115,9 +115,9 @@ minetest.register_node("redstone:lever_off", {
 
                local dir = minetest.wallmounted_to_dir(node.param2)
 
-               redstone.inject(pos,{torch=9})
+               redstone.inject(pos,{torch=16})
                local pos2 = vector.add(dir,pos)
-               redstone.inject(pos2,{torch=9})
+               redstone.inject(pos2,{torch=16})
 
                redstone.update(pos)
                redstone.update(pos2)
index bef44abb48e6f70e06246fb428fc0661dec902ca..7ece35de0344e7f86e45f7a695fe2b0d3624c16d 100644 (file)
@@ -4,7 +4,7 @@ minetest,ipairs,math
 minetest,ipairs,math
 
 --detects players and outputs accordingly
-for i = 0,9  do
+for i = 0,16  do
 
 minetest.register_node("redstone:player_detector_"..i, {
        description = "Redstone Player Detector",
index 51201585ef0fabbfe164c7b3e17e3344e3622c52..5582898a981fa603ee6110574387b08d0876138c 100644 (file)
@@ -18,7 +18,7 @@ for level = 0,max_timer do
 minetest.register_node("redstone:repeater_on_"..level, {
        description = "Redstone Repeater",
        tiles = {"repeater_on.png"},
-       groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,redstone_activation_directional=1,repeater_on=1,repeater=1,torch_directional=1,redstone_power=9,repeater_level=level},
+       groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,redstone_activation_directional=1,repeater_on=1,repeater=1,torch_directional=1,redstone_power=16,repeater_level=level},
        sounds = main.stoneSound(),
        paramtype = "light",
        paramtype2 = "facedir",
@@ -48,7 +48,7 @@ minetest.register_node("redstone:repeater_on_"..level, {
                minetest.sound_play("lever", {pos=pos})
                redstone.inject(pos,{
                        name = "redstone:repeater_on_"..newlevel,
-                       torch  = 9,
+                       torch  = 16,
                        torch_directional = true,
                        directional_activator = true,
                        input  = vector.subtract(pos,dir),
@@ -65,10 +65,10 @@ minetest.register_node("redstone:repeater_on_"..level, {
                        name = "redstone:repeater_off_"..level,
                        directional_activator = true,
                        input  = vector.subtract(pos,dir),
+                       output = vector.add(pos,dir),
                        dir = dir
                })
                redstone.update(pos)
-               redstone.update(vector.add(pos,dir))
        end,
 
        after_destruct = function(pos, oldnode)
@@ -80,7 +80,7 @@ minetest.register_node("redstone:repeater_on_"..level, {
                local dir = minetest.facedir_to_dir(minetest.get_node(pos).param2)
                redstone.inject(pos,{
                        name = "redstone:repeater_on_"..level,
-                       torch  = 9,
+                       torch  = 16,
                        torch_directional = true,
                        directional_activator = true,
                        input  = vector.subtract(pos,dir),
@@ -110,17 +110,13 @@ minetest.register_lbm({
                local dir = minetest.facedir_to_dir(minetest.get_node(pos).param2)
                redstone.inject(pos,{
                        name = "redstone:repeater_on_"..level,
-                       torch  = 9,
+                       torch  = 16,
                        torch_directional = true,
                        directional_activator = true,
                        input  = vector.subtract(pos,dir),
                        output = vector.add(pos,dir),
                        dir = dir
                })
-               --redstone needs to warm up
-               minetest.after(0,function()
-                       redstone.update(pos)
-               end)
        end,
 })
 
@@ -172,7 +168,7 @@ minetest.register_node("redstone:repeater_off_"..level, {
                local dir = minetest.facedir_to_dir(param2)
                redstone.inject(pos,{
                        name = "redstone:repeater_on_"..level,
-                       torch  = 9,
+                       torch  = 16,
                        torch_directional = true,
                        directional_activator = true,
                        input  = vector.subtract(pos,dir),
@@ -180,7 +176,6 @@ minetest.register_node("redstone:repeater_off_"..level, {
                        dir = dir
                })
                redstone.update(pos)
-               redstone.update(vector.add(pos,dir))
        end,
 
        on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
@@ -195,6 +190,7 @@ minetest.register_node("redstone:repeater_off_"..level, {
                        name = "redstone:repeater_off_"..newlevel,
                        directional_activator = true,
                        input  = vector.subtract(pos,dir),
+                       output = vector.add(pos,dir),
                        dir = dir
                })
                minetest.sound_play("lever", {pos=pos})
@@ -211,6 +207,7 @@ minetest.register_node("redstone:repeater_off_"..level, {
                        name = "redstone:repeater_off_"..level,
                        directional_activator = true,
                        input  = vector.subtract(pos,dir),
+                       output = vector.add(pos,dir),
                        dir = dir
                })
                redstone.update(pos)
@@ -241,10 +238,6 @@ minetest.register_lbm({
                        input  = vector.subtract(pos,dir),
                        dir = dir
                })
-               --redstone needs a second to warm up
-               minetest.after(0,function()
-                       redstone.update(pos)
-               end)
        end,
 })
 
index b56dbef40acae1ab14b0af1111c1e238edb6410b..be38bdd32f20820a6238f072092209cae6540482 100644 (file)
@@ -55,9 +55,39 @@ minetest.register_node("redstone:space", {
                        --      obj:setvelocity({x=x, y=y, z=z})
                        --end
                end
-    end,
-    
-    
+    end,    
 })
 
 
+
+minetest.register_node("redstone:the_stone", {
+    description = "redstone ultimate",
+    tiles = {"redstone_dust_item.png"},
+    groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,pathable = 1},
+    sounds = main.stoneSound(),
+    after_place_node = function(pos, placer, itemstack, pointed_thing)
+               local min = vector.subtract(pos,50)
+               min.y = pos.y
+               local max = vector.add(pos,50)
+               max.y = pos.y
+               local vm = minetest.get_voxel_manip()   
+               local emin, emax = vm:read_from_map(min,max)
+               local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
+               local data = vm:get_data()
+               local content_id = minetest.get_name_from_content_id
+               
+               local y = pos.y
+               
+               for x = -50,50 do
+                       for z = -50,50 do
+                               local i = vector.add(pos,vector.new(x,0,z))
+                               i.y = pos.y
+                               local p_pos = area:index(i.x,i.y,i.z)   
+                               data[p_pos] = minetest.get_content_id("redstone:dust_0")
+                               redstone.inject(i,{dust=0})
+                       end
+               end
+               vm:set_data(data)
+               vm:write_to_map()
+    end,    
+})
index 0b23a20e72911f038798fc31bd5bc24ff2bee2eb..263a30db244fe6c4a9eb0b78ffa1eca8b459c9af 100644 (file)
Binary files a/mods/redstone/textures/redstone_cross.png and b/mods/redstone/textures/redstone_cross.png differ
index 3219df3c4bb2520b57880e8e33639e7f5f566045..8c53367e9d9c61d8a1e4d79994b55087892cbe5f 100644 (file)
Binary files a/mods/redstone/textures/redstone_dust_main.png and b/mods/redstone/textures/redstone_dust_main.png differ
diff --git a/mods/redstone/textures/redstone_redstone_dust_line1.png b/mods/redstone/textures/redstone_redstone_dust_line1.png
deleted file mode 100644 (file)
index 61ebb2c..0000000
Binary files a/mods/redstone/textures/redstone_redstone_dust_line1.png and /dev/null differ
index 486e6e8c3f5edd726933fbcff50faf98af37100e..475eb5f822c86d35680ca2be1907d02228a41217 100644 (file)
Binary files a/mods/redstone/textures/redstone_t.png and b/mods/redstone/textures/redstone_t.png differ
index 9a94f3ecf6320b13037e3cbd294b377cf874fe9f..8be9a7e3390e44d2799cacc1abba0b95d9118de7 100644 (file)
Binary files a/mods/redstone/textures/redstone_turn.png and b/mods/redstone/textures/redstone_turn.png differ
index 6cd222bfe05a20b251898ca91f8de7c32ec09edf..31fb4d2a0fc970db990846aab7db3edf31eac414 100644 (file)
@@ -7,7 +7,6 @@ minetest.register_craftitem("redstone:torch", {
        wield_image = "redstone_torch.png",
        wield_scale = {x = 1, y = 1, z = 1 + 1/16},
        liquids_pointable = false,
-       power = 9,
        on_place = function(itemstack, placer, pointed_thing)
                if pointed_thing.type ~= "node" then
                        return itemstack
@@ -47,12 +46,11 @@ minetest.register_node("redstone:torch_floor", {
        tiles = {"redstone_torch.png"},
        paramtype = "light",
        paramtype2 = "none",
-       power = 9,
        sunlight_propagates = true,
        drop = "redstone:torch",
        walkable = false,
        light_source = 13,
-       groups = {choppy=2, dig_immediate=3, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,redstone_power=9},
+       groups = {choppy=2, dig_immediate=3, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,},
        legacy_wallmounted = true,
        selection_box = {
                type = "fixed",
@@ -60,7 +58,7 @@ minetest.register_node("redstone:torch_floor", {
        },
        
        on_construct = function(pos)
-               redstone.inject(pos,{torch=9})
+               redstone.inject(pos,{torch=16})
                redstone.update(pos)
        end,
        after_destruct = function(pos, oldnode)
@@ -82,8 +80,7 @@ minetest.register_node("redstone:torch_wall", {
        sunlight_propagates = true,
        walkable = false,
        light_source = 13,
-       power = 9,
-       groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,redstone_power=9},
+       groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,},
        drop = "redstone:torch",
        selection_box = {
                type = "wallmounted",
@@ -92,7 +89,7 @@ minetest.register_node("redstone:torch_wall", {
                wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
        },
        on_construct = function(pos)
-               redstone.inject(pos,{torch=9})
+               redstone.inject(pos,{torch=16})
                redstone.update(pos)
        end,
        after_destruct = function(pos, oldnode)
@@ -108,6 +105,6 @@ minetest.register_lbm({
        nodenames = {"redstone:torch_wall","redstone:torch_floor"},
        run_at_every_load = true,
        action = function(pos)
-               redstone.inject(pos,{torch=9})
+               redstone.inject(pos,{torch=16})
        end,
 })
\ No newline at end of file