From f4ac2b8c1ef97a8adf29501f5599fb8adb4df00c Mon Sep 17 00:00:00 2001 From: Novatux <nathanael.courant@laposte.net> Date: Fri, 04 Oct 2013 16:48:39 +0200 Subject: [PATCH] Make power distribution more efficient. --- technic/init.lua | 101 +++++++++++++++++++------------------------------- 1 files changed, 39 insertions(+), 62 deletions(-) diff --git a/technic/init.lua b/technic/init.lua index 184c8b9..8c4fa09 100644 --- a/technic/init.lua +++ b/technic/init.lua @@ -1,63 +1,37 @@ --- Minetest 0.4.4 : technic +-- Minetest 0.4.7 mod: technic +-- namespace: technic +-- (c) 2012-2013 by RealBadAngel <mk@realbadangel.pl> -modpath=minetest.get_modpath("technic") +technic = {} ---Read technic config file +local load_start = os.clock() +local modpath = minetest.get_modpath("technic") +technic.modpath = modpath + + +-- Read configuration file dofile(modpath.."/config.lua") --- world gen -dofile(modpath.."/ores.lua") -if enable_rubber_tree_generation==true then dofile(modpath.."/rubber.lua") end +-- Helper functions +dofile(modpath.."/helpers.lua") --- chests -dofile(modpath.."/chest_commons.lua") -dofile(modpath.."/iron_chest.lua") -dofile(modpath.."/copper_chest.lua") -dofile(modpath.."/silver_chest.lua") -dofile(modpath.."/gold_chest.lua") -dofile(modpath.."/mithril_chest.lua") - ---items -dofile(modpath.."/concrete.lua") +-- Items dofile(modpath.."/items.lua") ---LV machines -dofile(modpath.."/alloy_furnace.lua") -dofile(modpath.."/solar_panel.lua") -dofile(modpath.."/geothermal.lua") -dofile(modpath.."/water_mill.lua") -dofile(modpath.."/electric_furnace.lua") -dofile(modpath.."/battery_box.lua") -dofile(modpath.."/wires.lua") -dofile(modpath.."/tool_workshop.lua") -dofile(modpath.."/music_player.lua") -dofile(modpath.."/generator.lua") -dofile(modpath.."/grinder.lua") +-- Craft recipes for items +dofile(modpath.."/crafts.lua") ---MV machines -dofile(modpath.."/wires_mv.lua") -dofile(modpath.."/solar_panel_mv.lua") -dofile(modpath.."/battery_box_mv.lua") -dofile(modpath.."/electric_furnace_mv.lua") +-- Register functions +dofile(modpath.."/register.lua") ---Tools -if enable_mining_drill==true then dofile(modpath.."/mining_drill.lua") end -if enable_mining_laser==true then dofile(modpath.."/mining_laser_mk1.lua") end -if enable_flashlight==true then dofile(modpath.."/flashlight.lua") end -dofile(modpath.."/cans.lua") -dofile(modpath.."/chainsaw.lua") -dofile(modpath.."/tree_tap.lua") -dofile(modpath.."/screwdriver.lua") -dofile(modpath.."/sonic_screwdriver.lua") +-- Machines +dofile(modpath.."/machines/init.lua") --- mesecons and tubes related ---dofile(modpath.."/injector.lua") -dofile(modpath.."/node_breaker.lua") -dofile(modpath.."/deployer.lua") -dofile(modpath.."/constructor.lua") +-- Tools +dofile(modpath.."/tools/init.lua") -if enable_item_drop then dofile(modpath.."/item_drop.lua") end -if enable_item_pickup then dofile(modpath.."/item_pickup.lua") end +-- Aliases for legacy node/item names +dofile(modpath.."/legacy.lua") function has_locked_chest_privilege(meta, player) if player:get_player_name() ~= meta:get_string("owner") then @@ -66,18 +40,21 @@ return true end - -function hacky_swap_node(pos,name) - local node = minetest.env:get_node(pos) - local meta = minetest.env:get_meta(pos) - local meta0 = meta:to_table() - if node.name == name then - return nil +-- Swap nodes out. Return the node name. +function hacky_swap_node(pos, name) + local node = minetest.get_node(pos) + if node.name ~= name then + local meta = minetest.get_meta(pos) + local meta_table = meta:to_table() + node.name = name + minetest.set_node(pos, node) + meta = minetest.get_meta(pos) + meta:from_table(meta_table) end - node.name = name - local meta0 = meta:to_table() - minetest.env:set_node(pos,node) - meta = minetest.env:get_meta(pos) - meta:from_table(meta0) - return 1 + return node.name end + +if minetest.setting_get("log_mod") then + print("[Technic] Loaded in "..tostring(os.clock() - load_start).."s") +end + -- Gitblit v1.8.0