diff --git a/basic_machines/gravelrinser.lua b/basic_machines/gravelrinser.lua index d814c9b..cde3242 100644 --- a/basic_machines/gravelrinser.lua +++ b/basic_machines/gravelrinser.lua @@ -158,7 +158,6 @@ local function washing(pos, crd, mem, inv) end local function keep_running(pos, elapsed) - print("keep_running") local mem = tubelib2.get_mem(pos) local crd = CRD(pos) local inv = M(pos):get_inventory() diff --git a/basis/node_states.lua b/basis/node_states.lua index 0b984f0..a053d60 100644 --- a/basis/node_states.lua +++ b/basis/node_states.lua @@ -125,7 +125,6 @@ local function swap_node(pos, name) if node.name == name then return end - print("swap_node", name) node.name = name minetest.swap_node(pos, node) end diff --git a/coal_power_station/akkubox.lua b/coal_power_station/akkubox.lua index 53809c0..f73fea9 100644 --- a/coal_power_station/akkubox.lua +++ b/coal_power_station/akkubox.lua @@ -66,7 +66,6 @@ local State = techage.NodeStates:new({ -- Pass1: Power balance calculation local function on_power_pass1(pos, mem) - print("on_power_pass1", mem.charging) if State:is_active(mem) and mem.capa > POWER_HYSTERESIS then mem.correction = POWER_CONSUMPTION -- uncharging else @@ -77,7 +76,6 @@ end -- Pass2: Power balance adjustment local function on_power_pass2(pos, mem, sum) - print("on_power_pass2", mem.charging, sum) if State:is_active(mem) then if sum > mem.correction + POWER_CONSUMPTION and mem.capa < POWER_MAX_LOAD - POWER_HYSTERESIS then @@ -100,14 +98,12 @@ end -- Pass3: Power balance result local function on_power_pass3(pos, mem, sum) - print("on_power_pass3", mem.charging, sum) mem.power_result = sum end local function node_timer(pos, elapsed) local mem = tubelib2.get_mem(pos) - print("node_timer", mem.charging, mem.capa) if State:is_active(mem) then mem.capa = mem.capa or 0 if mem.charging == true then diff --git a/init.lua b/init.lua index dae9f9a..f12860c 100644 --- a/init.lua +++ b/init.lua @@ -110,6 +110,12 @@ else dofile(MP.."/lamps/lib.lua") dofile(MP.."/lamps/simplelamp.lua") dofile(MP.."/lamps/streetlamp.lua") + dofile(MP.."/lamps/ceilinglamp.lua") + dofile(MP.."/lamps/industriallamp1.lua") + dofile(MP.."/lamps/industriallamp2.lua") + + -- Oil + dofile(MP.."/oil/explore.lua") --dofile(MP.."/test/generator.lua") diff --git a/iron_age/coalburner.lua b/iron_age/coalburner.lua index c45f49b..dbc3e48 100644 --- a/iron_age/coalburner.lua +++ b/iron_age/coalburner.lua @@ -187,6 +187,7 @@ function techage.start_burner(pos, playername) end function techage.keep_running_burner(pos) + print("keep_running_burner") local meta = minetest.get_meta(pos) local height = meta:get_int("height") remove_flame(pos, height) diff --git a/iron_age/meltingpot.lua b/iron_age/meltingpot.lua index 4c76a06..dfa9ebd 100644 --- a/iron_age/meltingpot.lua +++ b/iron_age/meltingpot.lua @@ -209,11 +209,22 @@ local function get_heat(pos) pos.y = pos.y - 1 local node = minetest.get_node(pos) local meta = minetest.get_meta(pos) - pos.y = pos.y + 1 - if minetest.get_item_group(node.name, "techage_flame") > 0 then - heat = meta:get_int("heat") + print("get_heat1", minetest.get_item_group(node.name, "techage_flame")) + if minetest.get_item_group(node.name, "techage_flame") == 0 then + pos.y = pos.y + 1 + return 0 end - return heat + + pos.y = pos.y - 1 + node = minetest.get_node(pos) + pos.y = pos.y + 2 + print("get_heat2", node.name, minetest.get_item_group(node.name, "techage_flame")) + if minetest.get_item_group(node.name, "techage_flame") == 0 and + node.name ~= "techage:charcoal_burn" then + return 0 + end + + return meta:get_int("heat") end -- Start melting if heat is ok AND source items available diff --git a/lamps/ceilinglamp.lua b/lamps/ceilinglamp.lua new file mode 100644 index 0000000..8edf3b7 --- /dev/null +++ b/lamps/ceilinglamp.lua @@ -0,0 +1,68 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2019 Joachim Stolberg + + LGPLv2.1+ + See LICENSE.txt for more information + + TA3/TA4 Ceiling Lamp + +]]-- + +-- Load support for intllib. +local MP = minetest.get_modpath("techage") +local I,_ = dofile(MP.."/intllib.lua") + +techage.register_lamp("techage:ceilinglamp", { + description = "TA Ceiling Lamp", + tiles = { + -- up, down, right, left, back, front + 'techage_ceilinglamp_top.png', + 'techage_ceilinglamp_bottom.png', + 'techage_ceilinglamp.png', + 'techage_ceilinglamp.png', + 'techage_ceilinglamp.png', + 'techage_ceilinglamp.png', + 'techage_ceilinglamp.png', + 'techage_ceilinglamp.png', + }, + + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-5/16, -7/16, -5/16, 5/16, -5/16, 5/16}, + {-4/16, -8/16, -4/16, 4/16, -7/16, 4/16}, + }, + }, + +},{ + description = "TA Ceiling Lamp", + tiles = { + -- up, down, right, left, back, front + 'techage_ceilinglamp_top.png', + 'techage_ceilinglamp_bottom.png', + 'techage_ceilinglamp.png', + 'techage_ceilinglamp.png', + 'techage_ceilinglamp.png', + 'techage_ceilinglamp.png', + }, + + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-5/16, -7/16, -5/16, 5/16, -5/16, 5/16}, + {-4/16, -8/16, -4/16, 4/16, -7/16, 4/16}, + }, + }, +}) + +minetest.register_craft({ + type = "shapeless", + output = "techage:ceilinglamp_off 3", + recipe = {"techage:simplelamp_off", "default:wood", "default:glass"}, +}) diff --git a/lamps/industriallamp1.lua b/lamps/industriallamp1.lua new file mode 100644 index 0000000..75db430 --- /dev/null +++ b/lamps/industriallamp1.lua @@ -0,0 +1,68 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2019 Joachim Stolberg + + LGPLv2.1+ + See LICENSE.txt for more information + + TA3/TA4 Industrial Lamp 1 + +]]-- + +-- Load support for intllib. +local MP = minetest.get_modpath("techage") +local I,_ = dofile(MP.."/intllib.lua") + +techage.register_lamp("techage:industriallamp1", { + description = "TA Industrial Lamp 1", + inventory_image = 'techage_industriallamp_inv1.png', + tiles = { + -- up, down, right, left, back, front + 'techage_industriallamp1.png', + 'techage_industriallamp1.png', + 'techage_industriallamp1.png^[transformR180', + 'techage_industriallamp1.png^[transformR180', + 'techage_industriallamp1.png', + 'techage_industriallamp1.png', + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-8/16, -8/16, -3/32, -6/16, -9/32, 3/32}, + { 6/16, -8/16, -3/32, 8/16, -9/32, 3/32}, + {-6/16, -7/16, -1/16, 6/16, -5/16, 1/16}, + }, + }, +},{ + tiles = { + -- up, down, right, left, back, front + 'techage_industriallamp1_on.png', + 'techage_industriallamp1_on.png', + 'techage_industriallamp1_on.png^[transformR180', + 'techage_industriallamp1_on.png^[transformR180', + 'techage_industriallamp1_on.png', + 'techage_industriallamp1_on.png', + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-8/16, -8/16, -3/32, -6/16, -9/32, 3/32}, + { 6/16, -8/16, -3/32, 8/16, -9/32, 3/32}, + {-6/16, -7/16, -1/16, 6/16, -5/16, 1/16}, + }, + }, +}) + +minetest.register_craft({ + output = "techage:industriallamp1_off 2", + recipe = { + {"", "", ""}, + {"default:glass", "techage:simplelamp_off", "dye:grey"}, + {"basic_materials:plastic_strip", "default:copper_ingot", "basic_materials:plastic_strip"}, + }, +}) diff --git a/lamps/industriallamp2.lua b/lamps/industriallamp2.lua new file mode 100644 index 0000000..4a3ecc9 --- /dev/null +++ b/lamps/industriallamp2.lua @@ -0,0 +1,70 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2019 Joachim Stolberg + + LGPLv2.1+ + See LICENSE.txt for more information + + TA3/TA4 Industrial Lamp 2 + +]]-- + +-- Load support for intllib. +local MP = minetest.get_modpath("techage") +local I,_ = dofile(MP.."/intllib.lua") + +local size = {x = 8/32, y = 8/32, z = 5/32} + +techage.register_lamp("techage:industriallamp2", { + description = "TA Industrial Lamp 2", + inventory_image = 'techage_industriallamp_inv2.png', + tiles = { + -- up, down, right, left, back, front + 'techage_industriallamp2.png', + 'techage_industriallamp2.png', + 'techage_industriallamp2.png^[transformR180', + 'techage_industriallamp2.png^[transformR180', + 'techage_industriallamp2.png', + 'techage_industriallamp2.png', + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-8/32, -16/32, -4/32, 8/32, -9/32, 4/32}, + {-7/32, -16/32, -5/32, 7/32, -9/32, 5/32}, + {-7/32, -9/32, -4/32, 7/32, -8/32, 4/32}, + }, + }, +},{ + tiles = { + -- up, down, right, left, back, front + 'techage_industriallamp2_on.png', + 'techage_industriallamp2_on.png', + 'techage_industriallamp2_on.png^[transformR180', + 'techage_industriallamp2_on.png^[transformR180', + 'techage_industriallamp2_on.png', + 'techage_industriallamp2_on.png', + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-8/32, -16/32, -4/32, 8/32, -9/32, 4/32}, + {-7/32, -16/32, -5/32, 7/32, -9/32, 5/32}, + {-7/32, -9/32, -4/32, 7/32, -8/32, 4/32}, + }, + }, +}) + +minetest.register_craft({ + output = "techage:industriallamp2_off 2", + recipe = { + {"default:glass", "default:glass", ""}, + {"techage:simplelamp_off", "dye:black", ""}, + {"basic_materials:steel_bar", "basic_materials:steel_bar", ""}, + }, +}) diff --git a/lamps/lib.lua b/lamps/lib.lua index ab27d6b..79a1b4b 100644 --- a/lamps/lib.lua +++ b/lamps/lib.lua @@ -7,6 +7,27 @@ local POWER_CONSUMPTION = 1 local Power = techage.ElectricCable +-- Input data to generate the Param2ToDir table +local Input = { + 8,9,10,11, -- 1 + 16,17,18,19, -- 2 + 4,5,6,7, -- 3 + 12,13,14,15, -- 4 + 0,1,2,3, -- 5 + 20,21,22,23, -- 6 +} + +local Param2Dir = {} +for idx,val in ipairs(Input) do + Param2Dir[val] = math.floor((idx - 1) / 4) + 1 +end + +local function rotate(param2) + local offs = math.floor(param2 / 4) * 4 + local rot = ((param2 % 4) + 1) % 4 + return offs + rot +end + local function swap_node(pos, postfix) local node = Power:get_node_lvm(pos) local parts = string.split(node.name, "_") @@ -27,7 +48,6 @@ local function on_power_pass1(pos, mem) end local function on_power_pass2(pos, mem, sum) - local node = minetest if sum > 0 and mem.running then swap_node(pos, "on") return 0 @@ -50,12 +70,50 @@ local function lamp_on_rightclick(pos, node, clicker) techage.power.power_distribution(pos) end +local function on_rotate(pos, node, user, mode, new_param2) + if minetest.is_protected(pos, user:get_player_name()) then + return false + end + node.param2 = rotate(node.param2) + minetest.swap_node(pos, node) + return true +end + +local function on_place(itemstack, placer, pointed_thing) + if pointed_thing.type ~= "node" then + return itemstack + end + return minetest.rotate_and_place(itemstack, placer, pointed_thing) +end + +local function determine_power_side(pos, node) + return {tubelib2.Turn180Deg[Param2Dir[node.param2] or 1]} +end + function techage.register_lamp(basename, ndef_off, ndef_on) ndef_off.on_construct = tubelib2.init_mem ndef_off.on_rightclick = lamp_on_rightclick + ndef_off.on_rotate = on_rotate + ndef_off.on_place = on_place + ndef_off.paramtype = "light" + ndef_off.light_source = 0 + ndef_off.sunlight_propagates = true + ndef_off.paramtype2 = "facedir" + ndef_off.groups = {choppy=2, cracky=2, crumbly=2} + ndef_off.is_ground_content = false + ndef_off.sounds = default.node_sound_glass_defaults() ndef_on.on_construct = tubelib2.init_mem ndef_on.on_rightclick = lamp_on_rightclick + ndef_on.on_rotate = on_rotate + ndef_on.paramtype = "light" + ndef_on.light_source = minetest.LIGHT_MAX + ndef_on.sunlight_propagates = true + ndef_on.paramtype2 = "facedir" + ndef_on.diggable = false + ndef_on.groups = {not_in_creative_inventory=1} + ndef_on.is_ground_content = false + ndef_on.sounds = default.node_sound_glass_defaults() minetest.register_node(basename.."_off", ndef_off) minetest.register_node(basename.."_on", ndef_on) @@ -64,5 +122,6 @@ function techage.register_lamp(basename, ndef_off, ndef_on) on_power_pass1 = on_power_pass1, on_power_pass2 = on_power_pass2, power_network = Power, + conn_sides = determine_power_side, -- will be handled by clbk function }) end diff --git a/lamps/streetlamp.lua b/lamps/streetlamp.lua index f533a0e..a986a2e 100644 --- a/lamps/streetlamp.lua +++ b/lamps/streetlamp.lua @@ -39,13 +39,6 @@ techage.register_lamp("techage:streetlamp", { type = "fixed", fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16}, }, - paramtype = "light", - light_source = 0, - sunlight_propagates = true, - paramtype2 = "facedir", - groups = {choppy=2, cracky=2, crumbly=2}, - is_ground_content = false, - sounds = default.node_sound_glass_defaults(), },{ description = "TA Street Lamp", tiles = { @@ -67,13 +60,6 @@ techage.register_lamp("techage:streetlamp", { type = "fixed", fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16}, }, - paramtype = "light", - light_source = minetest.LIGHT_MAX, - sunlight_propagates = true, - paramtype2 = "facedir", - groups = {crumbly=0, not_in_creative_inventory=1}, - is_ground_content = false, - sounds = default.node_sound_wood_defaults(), }) minetest.register_craft({ diff --git a/oil/explore.lua b/oil/explore.lua new file mode 100644 index 0000000..1d400bd --- /dev/null +++ b/oil/explore.lua @@ -0,0 +1,304 @@ +-- for lazy programmers +local S = function(pos) if pos then return minetest.pos_to_string(pos) end end +local P = minetest.string_to_pos +local M = minetest.get_meta + +-- Load support for intllib. +local MP = minetest.get_modpath("techage") +local I,IS = dofile(MP.."/intllib.lua") + + +local PROBABILITY = 2 +local OIL_MIN = 1000 +local OIL_MAX = 20000 +local DEPTH_MIN = (16 * 7) - 8 +local DEPTH_MAX = (16 * 60) - 8 + +local seed = 1234 + +local function get_node_name(pos) + local node = minetest.get_node_or_nil(pos) + if node then + return node.name + end + local vm = minetest.get_voxel_manip() + local MinEdge, MaxEdge = vm:read_from_map(pos, pos) + local data = vm:get_data() + local area = VoxelArea:new({MinEdge = MinEdge, MaxEdge = MaxEdge}) + local idx = area:index(pos.x, pos.y, pos.z) + return minetest.get_name_from_content_id(data[idx]) +end + + +local function oil_amount(pos) + local block_key = seed + + math.floor((pos.z + 32768) / 16) * 4096 * 4096 + + math.floor((pos.y + 32768) / 16) * 4096 + + math.floor((pos.x + 32768) / 16) + math.randomseed(block_key) + math.random(); math.random(); math.random() + local has_oil = math.random(1,PROBABILITY) == 1 + if has_oil then + local amount = math.random(OIL_MIN, OIL_MAX) + return amount + end + return 0 +end + +local function center(coord) + return (math.floor(coord/16) * 16) + 8 +end + +local Invalid = { + "air", +} + +local function gen_oil_slice(pos1, posc, y, radius, data, id) + local y_offs = (y - pos1.y) * 16 + for x = posc.x - radius, posc.x + radius do + for z = posc.z - radius, posc.z + radius do + local idx = x - pos1.x + y_offs + (z - pos1.z) * 16 * 16 + data[idx] = id + end + end + return (radius * 2 + 1) * (radius * 2 + 1) +end + +local function gen_oil_bubble(pos1, posC, amount, data) + local id = minetest.get_content_id("techage:oil_source") + local radius = math.floor(math.pow(amount, 1.0/3) / 2) + local sum = 0 + for y = posC.y - radius, posC.y + radius do + sum = sum + gen_oil_slice(pos1, posC, y, radius + 1, data, id) + print(y, sum, amount) + if sum >= amount then break end + end +end + +local function useable_stone_block(data) + local valid = {} + for _,id in ipairs(data) do + if not valid[id] then + local itemname = minetest.get_name_from_content_id(id) + local ndef = minetest.registered_nodes[itemname] + if not ndef or not ndef.is_ground_content or Invalid[itemname] then + return false + end + valid[id] = true + end + end + return true +end + +local function explore_area(posS, depth, amount, player_name, pos1, pos2, posC) + if amount > 0 and M(posS):get_int("oil_amount") == 0 then + local vm = minetest.get_voxel_manip(pos1, pos2) + local data = vm:get_data() + + if useable_stone_block(data) then + gen_oil_bubble(pos1, posC, amount/10, data) + vm:set_data(data) + vm:write_to_map() + vm:update_map() + print("explore_area", S(pos1), S(pos2)) + else + amount = 0 + end + end + M(posS):set_int("oil_amount", amount) + minetest.chat_send_player(player_name, "[TA Oil] depth: "..tostring(depth).. + ", Oil: "..tostring(amount).." ") +end + +local function get_next_depth(pos) + local meta = M(pos) + local name = get_node_name(pos) + local depth = DEPTH_MIN + if name == "techage:oilstorage" then + if meta:get_int("oil_amount") == 0 then + depth = M(pos):get_int("exploration_depth") + 32 + else + depth = M(pos):get_int("exploration_depth") + end + else + minetest.set_node(pos, {name = "techage:oilstorage"}) + end + M(pos):set_int("exploration_depth", depth) + return depth +end + +local function emerge_area(pos, node, player_name) + node.name = "techage:oilexplorer_on" + minetest.swap_node(pos, node) + minetest.get_node_timer(pos):start(2.2) + + -- used to store the depth/amount info + local store_pos = {x = center(pos.x), y = -100, z = center(pos.z)} + local depth = get_next_depth(store_pos) + minetest.sound_play("techage_explore", { + pos = pos, + max_hear_distance = 8}) + local posC = {x = center(pos.x), y = center(pos.y-depth), z = center(pos.z)} + local amount = oil_amount(posC) + if amount > 0 then + local radius = 7 + local pos1 = {x = posC.x - radius, y = posC.y - radius, z = posC.z - radius} + local pos2 = {x = posC.x + radius, y = posC.y + radius, z = posC.z + radius} + print("emerge_area", S(pos1), S(pos2), S(posC)) + minetest.emerge_area(pos1, pos2) + minetest.after(2, explore_area, store_pos, depth, amount, player_name, pos1, pos2, posC) + else + minetest.after(2, explore_area, store_pos, depth, 0, player_name) + end +end + +--local function test(pos) +-- local posC = {x = center(pos.x), y = center(pos.y+20), z = center(pos.z)} +-- local pos1 = {x = posC.x - 8, y = posC.y - 8, z = posC.z - 8} +-- local pos2 = {x = posC.x + 7, y = posC.y + 7, z = posC.z + 7} +-- bubble(pos1, pos2, posC, math.random(10, 200)) +--end + +-- Used as storage for already explored blocks +-- Will be places -100 in the middle if a block (8,8) +minetest.register_node("techage:oilstorage", { + description = "TA Oil Storage", + tiles = {"default_stone.png"}, + groups = {not_in_creative_inventory=1}, + diggable = false, + is_ground_content = false, +}) + +minetest.register_node("techage:oilexplorer", { + description = "Oil Explorer", + tiles = { + "techage_filling_ta3.png^techage_appl_oilexplorer_top.png^techage_frame_ta3_top.png", + "techage_filling_ta3.png^techage_frame_ta3.png", + "techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_oilexplorer.png", + }, + + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + emerge_area(pos, node, clicker:get_player_name()) + end, + + is_ground_content = false, + groups = {snappy=2,cracky=2,oddly_breakable_by_hand=2}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("techage:oilexplorer_on", { + description = "Oil Explorer", + tiles = { + { + image = "techage_filling4_ta3.png^techage_appl_oilexplorer_top4.png^techage_frame4_ta3_top.png", + backface_culling = false, + animation = { + type = "vertical_frames", + aspect_w = 32, + aspect_h = 32, + length = 1.0, + }, + }, + "techage_filling_ta3.png^techage_frame_ta3.png", + "techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_oilexplorer.png", + }, + + on_timer = function(pos,elapsed) + local node = minetest.get_node(pos) + node.name = "techage:oilexplorer" + minetest.swap_node(pos, node) + end, + + is_ground_content = false, + groups = {snappy=2,cracky=2,oddly_breakable_by_hand=2}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("techage:oil_source", { + description = "Oil Source", + drawtype = "liquid", + paramtype = "light", + + inventory_image = "techage_oil_inv.png", + tiles = { + { + name = "techage_oil_animated.png", + backface_culling = false, + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 10 + } + }, + { + name = "techage_oil_animated.png", + backface_culling = false, + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 2.0 + } + } + }, + + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + drowning = 1, + liquidtype = "source", + liquid_alternative_flowing = "techage:oil_flowing", + liquid_alternative_source = "techage:oil_source", + liquid_viscosity = 20, + liquid_range = 10, + post_effect_color = {a = 200, r = 1, g = 1, b = 1}, + groups = {liquid = 5}, +}) + + + +minetest.register_node("techage:oil_flowing", { + description = "Flowing Oil", + drawtype = "flowingliquid", + tiles = {"techage_oil.png"}, + special_tiles = { + { + name = "techage_oil_animated.png", + backface_culling = false, + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 10, + }, + }, + { + name = "techage_oil_animated.png", + backface_culling = true, + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 10, + }, + }, + }, + paramtype = "light", + paramtype2 = "flowingliquid", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + is_ground_content = false, + drop = "", + drowning = 1, + liquidtype = "flowing", + liquid_alternative_flowing = "techage:oil_flowing", + liquid_alternative_source = "techage:oil_source", + liquid_viscosity = 20, + liquid_range = 10, + post_effect_color = {a = 200, r = 1, g = 1, b = 1}, + groups = {liquid = 5, not_in_creative_inventory = 1}, +}) \ No newline at end of file diff --git a/oil/storage.lua b/oil/storage.lua new file mode 100644 index 0000000..34f81f5 --- /dev/null +++ b/oil/storage.lua @@ -0,0 +1,68 @@ +local S = function(pos) if pos then return minetest.pos_to_string(pos) end end +local DAYS_VALID = (30 * 72) -- 30 real days + +local storage = minetest.get_mod_storage() + +local function data_maintenance() + minetest.log("info", "[MOD] minecart maintenance") + local day_count = minetest.get_day_count() + local tbl = storage:to_table() + for key,s in pairs(tbl.fields) do + local route = minetest.deserialize(s) + if not route.waypoints or not route.best_before or route.best_before < day_count then + storage:set_string(key, "") + else + minetest.log("info", "[minecart] Route: start="..key.." length="..#(route.waypoints)) + end + end +end +minetest.after(1, data_maintenance) + + +-- Store data of running carts +minecart.CartsOnRail = {} + +for key,val in pairs(minetest.deserialize(storage:get_string("CartsOnRail")) or {}) do + -- use invalid keys to force the cart spawning + minecart.CartsOnRail[-key] = val +end + +minetest.register_on_shutdown(function() + data_maintenance() + storage:set_string("CartsOnRail", minetest.serialize(minecart.CartsOnRail)) +end) + +-- All positions as "pos_to_string" string +--Routes = { +-- start_pos = { +-- waypoints = {{spos, svel}, {spos, svel}, ...}, +-- dest_pos = spos, +-- junctions = { +-- {spos = num}, +-- {spos = num}, +-- }, +-- best_before = num +-- }, +-- start_pos = {...}, +--} +local Routes = {} +local NEW_ROUTE = {waypoints = {}, junctions = {}} + +function minecart.store_route(key, route) + Routes[key] = table.copy(route) + Routes[key].best_before = minetest.get_day_count() + DAYS_VALID + storage:set_string(key, minetest.serialize(Routes[key])) +end + +function minecart.get_route(key) + Routes[key] = Routes[key] or minetest.deserialize(storage:get_string(key)) or NEW_ROUTE + Routes[key].best_before = minetest.get_day_count() + DAYS_VALID + return Routes[key] +end + +function minecart.del_route(key) + Routes[key] = nil -- remove from memory + storage:set_string(key, "") -- and from storage +end + + diff --git a/power/power.lua b/power/power.lua index 3717e76..a6f534f 100644 --- a/power/power.lua +++ b/power/power.lua @@ -55,8 +55,12 @@ end local function set_conn_dirs(pos, sides) local tbl = {} local node = minetest.get_node(pos) - for _,side in ipairs(sides) do - tbl[#tbl+1] = tubelib2.Turn180Deg[side_to_dir(node.param2, side)] + if type(sides) == "function" then + tbl = sides(pos, node) + else + for _,side in ipairs(sides) do + tbl[#tbl+1] = tubelib2.Turn180Deg[side_to_dir(node.param2, side)] + end end M(pos):set_string("power_dirs", minetest.serialize(tbl)) end @@ -125,7 +129,7 @@ local function power_distribution(pos) Route = {} pos_already_reached(pos) sum = connection_walk(pos, "on_power_pass3", sum) - print("power sum = "..sum) + --print("power sum = "..sum) end local function register_lbm(name) diff --git a/power/powerswitch.lua b/power/powerswitch.lua index 60f4ab1..6cd127e 100644 --- a/power/powerswitch.lua +++ b/power/powerswitch.lua @@ -110,6 +110,7 @@ minetest.register_node("techage:powerswitch_on", { switch_off(pos, node, clicker) end, + drop = "techage:powerswitch", on_rotate = screwdriver.disallow, paramtype = "light", sunlight_propagates = true, diff --git a/sounds/techage_explore.ogg b/sounds/techage_explore.ogg new file mode 100644 index 0000000..fa714e0 Binary files /dev/null and b/sounds/techage_explore.ogg differ diff --git a/steam_engine/boiler.lua b/steam_engine/boiler.lua index c8b77bf..a4aee22 100644 --- a/steam_engine/boiler.lua +++ b/steam_engine/boiler.lua @@ -272,7 +272,6 @@ minetest.register_node("techage:boiler2", { end, power_signal_heat = function(pos) - print("power_signal_heat") local mem = tubelib2.get_mem(pos) mem.fire_trigger = true if not minetest.get_node_timer(pos):is_started() then diff --git a/test/test.lua b/test/test.lua index 794cc43..abbba07 100644 --- a/test/test.lua +++ b/test/test.lua @@ -1,95 +1,10 @@ --- for lazy programmers -local S = function(pos) if pos then return minetest.pos_to_string(pos) end end -local P = minetest.string_to_pos -local M = minetest.get_meta - -local function determine_water_dir(pos) - local pos1 = {x=pos.x+1, y=pos.y+1, z=pos.z} - local pos2 = {x=pos.x-1, y=pos.y+1, z=pos.z} - local pos3 = {x=pos.x, y=pos.y+1, z=pos.z+1} - local pos4 = {x=pos.x, y=pos.y+1, z=pos.z-1} - local node1 = minetest.get_node(pos1) - local node2 = minetest.get_node(pos2) - local node3 = minetest.get_node(pos3) - local node4 = minetest.get_node(pos4) - if node1.name == "default:water_flowing" and node2.name == "default:water_flowing" then - if node1.param2 > node2.param2 then - return 4 - elseif node1.param2 < node2.param2 then - return 2 - end - elseif node3.name == "default:water_flowing" and node4.name == "default:water_flowing" then - if node3.param2 > node4.param2 then - return 3 - elseif node3.param2 < node4.param2 then - return 1 - end - end - return 0 -end - -local function remove(obj) - obj:remove() -end - -local function velocity(obj, dir) - obj:set_velocity(vector.multiply(tubelib2.Dir6dToVector[dir], 0.3)) - minetest.after(10, remove, obj) -end - -local function node_timer(pos, elapsed) - local node = minetest.get_node(techage.get_pos(pos, 'U')) - local obj = minetest.add_item({x=pos.x, y=pos.y+1, z=pos.z}, ItemStack("default:gold_lump")) - minetest.after(0.8, velocity, obj, M(pos):get_int("water_dir")) - return true -end - -minetest.register_node("techage:rinser", { - description = "TechAge Rinser", - tiles = { - -- up, down, right, left, back, front - { - image = "techage_appl_sieve4_top.png^techage_frame4_ta2_top.png", - backface_culling = false, - animation = { - type = "vertical_frames", - aspect_w = 32, - aspect_h = 32, - length = 2.0, - }, - }, - 'techage_electric_button.png', - }, - paramtype2 = "facedir", - groups = {cracky=2, crumbly=2, choppy=2}, - on_rotate = screwdriver.disallow, - is_ground_content = false, - - after_place_node = function(pos, placer) - minetest.get_node_timer(pos):start(5) - local dir = determine_water_dir(pos) - M(pos):set_int("water_dir", dir) - end, - - on_timer = node_timer, -}) - -local function remove_objects(pos) - for _, object in pairs(minetest.get_objects_inside_radius(pos, 1)) do - local lua_entity = object:get_luaentity() - if not object:is_player() and lua_entity and lua_entity.name == "__builtin:item" then - object:remove() - end - end -end - -minetest.register_lbm({ - label = "[techage] Rinser update", - name = "techage:update", - nodenames = {"techage:rinser"}, - run_at_every_load = true, - action = function(pos, node) - remove_objects({x=pos.x, y=pos.y+1, z=pos.z}) - end -}) - +local function bubble(pos1, pos2, posc, amount) + local radius = math.floor(math.pow(amount, 0.333)) + local xc = pos2.x - pos1.x + for x = posc.x - radius, posc.x + radius do + for y = posc.y - radius, posc.y + radius do + for z = posc.z - radius, posc.z + radius do + local idx = x - pos1.x + + (y - pos1.y) * 16 + + (z - pos1.z) * 16 * 16 +print() diff --git a/textures/techage_appl_oilexplorer.png b/textures/techage_appl_oilexplorer.png new file mode 100644 index 0000000..26551a4 Binary files /dev/null and b/textures/techage_appl_oilexplorer.png differ diff --git a/textures/techage_appl_oilexplorer_top.png b/textures/techage_appl_oilexplorer_top.png new file mode 100644 index 0000000..12136be Binary files /dev/null and b/textures/techage_appl_oilexplorer_top.png differ diff --git a/textures/techage_appl_oilexplorer_top4.png b/textures/techage_appl_oilexplorer_top4.png new file mode 100644 index 0000000..73c8467 Binary files /dev/null and b/textures/techage_appl_oilexplorer_top4.png differ diff --git a/textures/techage_ceilinglamp.png b/textures/techage_ceilinglamp.png new file mode 100644 index 0000000..b9c9aec Binary files /dev/null and b/textures/techage_ceilinglamp.png differ diff --git a/textures/techage_ceilinglamp_bottom.png b/textures/techage_ceilinglamp_bottom.png new file mode 100644 index 0000000..f7635ef Binary files /dev/null and b/textures/techage_ceilinglamp_bottom.png differ diff --git a/textures/techage_ceilinglamp_top.png b/textures/techage_ceilinglamp_top.png new file mode 100644 index 0000000..835c1c3 Binary files /dev/null and b/textures/techage_ceilinglamp_top.png differ diff --git a/textures/techage_industriallamp1.png b/textures/techage_industriallamp1.png new file mode 100644 index 0000000..8fc4900 Binary files /dev/null and b/textures/techage_industriallamp1.png differ diff --git a/textures/techage_industriallamp1_on.png b/textures/techage_industriallamp1_on.png new file mode 100644 index 0000000..9c2a702 Binary files /dev/null and b/textures/techage_industriallamp1_on.png differ diff --git a/textures/techage_industriallamp2.png b/textures/techage_industriallamp2.png new file mode 100644 index 0000000..58eb44e Binary files /dev/null and b/textures/techage_industriallamp2.png differ diff --git a/textures/techage_industriallamp2_on.png b/textures/techage_industriallamp2_on.png new file mode 100644 index 0000000..8d46b21 Binary files /dev/null and b/textures/techage_industriallamp2_on.png differ diff --git a/textures/techage_industriallamp_inv1.png b/textures/techage_industriallamp_inv1.png new file mode 100644 index 0000000..58f04d6 Binary files /dev/null and b/textures/techage_industriallamp_inv1.png differ diff --git a/textures/techage_industriallamp_inv2.png b/textures/techage_industriallamp_inv2.png new file mode 100644 index 0000000..18a975f Binary files /dev/null and b/textures/techage_industriallamp_inv2.png differ diff --git a/textures/techage_oil.png b/textures/techage_oil.png new file mode 100644 index 0000000..a5de498 Binary files /dev/null and b/textures/techage_oil.png differ diff --git a/textures/techage_oil_animated.png b/textures/techage_oil_animated.png new file mode 100644 index 0000000..643ee13 Binary files /dev/null and b/textures/techage_oil_animated.png differ diff --git a/textures/techage_oil_inv.png b/textures/techage_oil_inv.png new file mode 100644 index 0000000..e3dbf85 Binary files /dev/null and b/textures/techage_oil_inv.png differ