Index: compat.lua ================================================================== --- compat.lua +++ compat.lua @@ -34,11 +34,16 @@ description = 'Ash'; inventory_image = 'sorcery_iron_powder.png^[colorize:#FFFFFF:100'; }) minetest.register_alias('new_campfire:ash', 'sorcery:ash') end + +-- xdecor offers a conflicting and somewhat poorly designed enchantment +-- mechanism; make it inaccessible but don't fuck up already existing +-- enchanters in the world +minetest.clear_craft { output='xdecor:enchanter'; } return { defp = function(name) return minetest.registered_items[name] or minetest.registered_aliases[name] end; } Index: displacer.lua ================================================================== --- displacer.lua +++ displacer.lua @@ -311,21 +311,29 @@ on_punch = n.button and function(pos,node,puncher) if puncher and puncher:get_wielded_item():is_empty() then n.button(pos) end end or nil; - after_place_node = function(...) autoselect(...) end; + after_place_node = function(...) + autoselect(...) + -- these are not ley devices but they still affect the + -- energy consumption of the ley device they are attached + -- to, so we need to manually run the notification routine + -- when they are placed or dug + sorcery.ley.notify(...) + end; allow_metadata_inventory_put = m.allowput; _sorcery = { attune = (mode == 'attune') and n.attune or nil; }; after_dig_node = function(...) autoselect(...) sorcery.lib.node.purge_container(...) + sorcery.lib.node.notifyneighbors(...) end; groups = { cracky = 2; sorcery_magitech = 1; }; }) end end Index: enchanter.lua ================================================================== --- enchanter.lua +++ enchanter.lua @@ -303,10 +303,14 @@ drawtype = 'airlike'; pointable = false; walkable = false; buildable_to = true; sunlight_propagates = true; light_source = i + 4; + groups = { + air = 1, sorcery_air = 1; + not_in_creative_inventory = 1; + }; on_construct = function(pos) minetest.get_node_timer(pos):start(0.05) end; on_timer = function(pos) if i <= 2 then minetest.remove_node(pos) else @@ -418,16 +422,11 @@ end puncher:set_wielded_item(tool) -- perform leyline checks and call notify if necessary if minetest.get_item_group(node.name, 'sorcery_ley_device') ~= 0 then - for _,p in pairs(sorcery.ley.txofs) do - local sum = vector.add(pos,p) - if minetest.get_item_group(minetest.get_node(sum).name, 'sorcery_ley_device') ~= 0 then - sorcery.ley.notify(sum) - end - end + sorcery.lib.node.notifyneighbors(pos) end end) minetest.register_chatcommand('enchants', { description = 'Log information about the currently held object\'s enchantment'; Index: lib/node.lua ================================================================== --- lib/node.lua +++ lib/node.lua @@ -90,6 +90,36 @@ checked[#checked+1] = pos i = i + 1 until i > #stack return nodes, positions end; + + forneighbor = function(pos, n, fn) + for _,p in pairs(n) do + local sum = vector.add(pos, p) + fn(sum, minetest.get_node(sum)) + end + end; + + -- when items have already been removed; notify cannot be relied on + -- to reach the entire network; this function accounts for the gap + notifyneighbors = function(pos) + sorcery.lib.node.forneighbor(pos, sorcery.ley.txofs, function(pos,node) + if minetest.get_item_group(node.name,'sorcery_ley_device') ~= 0 then + sorcery.ley.notify(sum) + end + end) + end; + + blockpos = function(pos) + return { + x = math.floor(pos.x / 16); + y = math.floor(pos.y / 16); + z = math.floor(pos.z / 16); + } + end; + + preload = function(pos, user) + minetest.load_area(pos) + user:send_mapblock(sorcery.lib.node.blockpos(pos)) + end; } Index: portal.lua ================================================================== --- portal.lua +++ portal.lua @@ -214,15 +214,14 @@ -- evaluation of the local network occurs before this function -- is ever even called, so we only need to worry about the -- farcaster-related transmission costs for i,c in pairs(circuit) do if vector.equals(c.pos,pos) then - print('found destination in circuit table',i,dump(c)) -- the destination is listed in the circuit table for j,r in pairs(c.route) do local nc = sorcery.ley.netcaps(pos,1) - print('checking route for sufficient energy to power farcasters', j, nc.freepower) + -- print('checking route for sufficient energy to power farcasters', j, nc.freepower) if nc.freepower < constants.portal_jump_cost_per_farcaster then return false -- only one route to any given portal node -- will be listed in the circuit table, so bail early -- maybe in the future farcasters should charge up, -- and power should be deducted when they are used? @@ -236,24 +235,19 @@ return false end local portal_pick_destination = function(dev,circuit,partner) if partner then - print('paired: evaluating partner') if portal_destination_evaluate(circuit,partner) then return partner end - print('partner failed eval') end local scrambled = sorcery.lib.tbl.scramble(circuit) for i=1,#scrambled do - print('evaluating destination',i,dump(scrambled[i])) if portal_destination_evaluate(circuit,scrambled[i].pos) then return scrambled[i].pos end - print('eval failed') end - print('no viable destinations in net') end -- minetest.register_lbm { -- name = 'sorcery:activate_portals'; -- label = 'activate portals'; @@ -294,11 +288,11 @@ end end end if cap.self.minpower ~= cap.self.powerdraw then - print("not enough power") + -- print("not enough power") return true end -- clean out user table for name,user in pairs(portal_context.users) do @@ -329,14 +323,13 @@ end local cap = sorcery.ley.netcaps(pos,delta) local jc = (constants.portal_jump_cost_local*delta) if not user.dest and cap.freepower >= jc then user.dest = portal_pick_destination(dev,crc,partner) + sorcery.lib.node.preload(user.dest, u.object) end - if not user.dest then goto skippad else - minetest.load_area(user.dest) - end + if not user.dest then goto skippad end local fac = (user.time / constants.portal_jump_time); minetest.add_particlespawner { time = 1, amount = 100 + (fac * 200); minsize = 0.2 + fac*0.7, maxsize = 0.4 + fac*0.9; minvel = {y = 0.2, x=0,z=0}, maxvel = {y = 0.5, x=0,z=0}; Index: potions.lua ================================================================== --- potions.lua +++ potions.lua @@ -40,10 +40,11 @@ if extra then for k,v in pairs(extra) do node[k] = v end end if not node.groups then node.groups = {} end node.groups.dig_immediate = 3; node.groups.attached_node = 1; node.groups.vessel = 1; + node.groups.not_in_creative_inventory = 1; minetest.register_node("sorcery:"..name, node) end sorcery.register_oil = function(name,label,desc,color,imgvariant,extra) local image = 'xdecor_bowl.png^(sorcery_oil_' .. (imgvariant or 'dull') .. '.png^[colorize:'..tostring(color)..':140)' Index: tnodes.lua ================================================================== --- tnodes.lua +++ tnodes.lua @@ -5,11 +5,11 @@ sunlight_propagates = true; buildable_to = true; pointable = false; walkable = false; floodable = true; - groups = { air = 1; sorcery_air = 1; }; + groups = { air = 1; sorcery_air = 1; not_in_creative_inventory = 1; }; on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_float('duration',10) meta:set_float('timeleft',10) meta:set_int('power',minetest.LIGHT_MAX) Index: wands.lua ================================================================== --- wands.lua +++ wands.lua @@ -410,10 +410,11 @@ }; inventory_image = basis.img.whole:render(); groups = { tool = 1; sorcery_wand = 1; + not_in_creative_inventory = 1; }; node_dig_prediction = ""; on_use = wand_cast; on_secondary_use = function(stack,user,target) return wand_cast(stack,user,nil)