From 75947e833f44d7738535856aef395bc6e30e36a6 Mon Sep 17 00:00:00 2001 From: Izzy Date: Fri, 26 Apr 2019 00:52:55 -0600 Subject: [PATCH] rock crusher, tweaks --- concrete.lua | 2 +- crafts.lua | 11 ++++- init.lua | 1 + ore_gen.lua | 14 +++--- rock_crusher.lua | 108 +++++++++++++++++++++++++++++++---------------- 5 files changed, 91 insertions(+), 45 deletions(-) diff --git a/concrete.lua b/concrete.lua index 0b5e1dd..d9768b4 100644 --- a/concrete.lua +++ b/concrete.lua @@ -147,7 +147,7 @@ minetest.register_node("bitumen:cement_mixer", { } }, paramtype2 = "facedir", - groups = {choppy=1, petroleum_fixture=1}, + groups = {cracky=1, petroleum_fixture=1}, sounds = default.node_sound_wood_defaults(), on_construct = function(pos) diff --git a/crafts.lua b/crafts.lua index ccb2376..af2b6d5 100644 --- a/crafts.lua +++ b/crafts.lua @@ -306,7 +306,7 @@ minetest.register_craft({ }) --- +-- misc machines minetest.register_craft({ output = "bitumen:kerosene_light", @@ -316,3 +316,12 @@ minetest.register_craft({ {"", "bitumen:drum_extractor", ""}, } }) + +minetest.register_craft({ + output = "bitumen:rock_crusher", + recipe = { + {"", "bitumen:galv_steel_sheet", ""}, + {"bitumen:galv_steel_sheet", "bitumen:rock_crusher_blueprint", "bitumen:galv_steel_sheet"}, + {"", "bitumen:galv_steel_sheet", ""}, + } +}) diff --git a/init.lua b/init.lua index d708ab0..cd984a8 100644 --- a/init.lua +++ b/init.lua @@ -104,6 +104,7 @@ dofile(modpath.."/cylinder_tank.lua") dofile(modpath.."/sphere_tank.lua") dofile(modpath.."/refinery.lua") dofile(modpath.."/lights.lua") +dofile(modpath.."/rock_crusher.lua") diff --git a/ore_gen.lua b/ore_gen.lua index 835f743..a0bb1c5 100644 --- a/ore_gen.lua +++ b/ore_gen.lua @@ -85,23 +85,25 @@ minetest.register_ore({ minetest.register_ore({ ore_type = "blob", ore = "bitumen:chalk", - wherein = {"default:stone"}, - clust_scarcity = 32 * 32 * 32, - clust_size = 6, + wherein = {"default:stone", "default:sand"}, + clust_scarcity = 48 * 48 * 48, + clust_size = 14, y_min = 2, y_max = 30, noise_threshold = 0.0, noise_params = { offset = 0.5, scale = 0.2, - spread = {x = 5, y = 5, z = 5}, + spread = {x = 10, y = 5, z = 7}, seed = -343, octaves = 1, - persist = 0.0 + persist = 0.1 }, biomes = {"savanna", "savanna_shore", "savanna_ocean", "rainforest", "rainforest_swamp", "rainforest_ocean", "underground", - "floatland_coniferous_forest", "floatland_coniferous_forest_ocean"} + "floatland_coniferous_forest", "floatland_coniferous_forest_ocean" +-- ,"grassland", "desert", "sandstone_desert" + } }) diff --git a/rock_crusher.lua b/rock_crusher.lua index 7211da6..e24daa1 100644 --- a/rock_crusher.lua +++ b/rock_crusher.lua @@ -68,12 +68,12 @@ local rock_crusher_formspec = local function take_gas(itemstack, amount) - if st:get_name() ~= "bitumen:oil_drum_filled" end + if itemstack:get_name() ~= "bitumen:oil_drum_filled" then return false end - local smeta = st:get_meta() - if smeta:get_float("fluid") ~= "bitumen:gasoline" then + local smeta = itemstack:get_meta() + if smeta:get_string("fluid") ~= "bitumen:gasoline" then return false end @@ -88,6 +88,62 @@ local function take_gas(itemstack, amount) end + + +function crushtimer(pos, elapsed) + + local meta = minetest.get_meta(pos) + + local fuel = meta:get_float("fuel") or 0.0 + + if fuel <= 0 then + -- try to get some fuel + local inv = meta:get_inventory() + + local st = inv:get_stack("main", 1) + + if take_gas(st, 1) then + inv:set_stack("main", 1, st); + fuel = fuel + 1 + else + -- out of fuel, turn off + return false + end + + end + + fuel = fuel - .1 + meta:set_float("fuel", fuel) + + -- try to grind some rocks + pos.y = pos.y + 1 +-- local tnode = minetest.get_node(pos) + + local tmeta = minetest.get_meta(pos) + local tinv = tmeta:get_inventory() + local cob = tinv:remove_item("main", "default:cobble 1") + if cob:get_count() <= 0 then + cob = tinv:remove_item("main", "default:desert_cobble 1") + end + + + + if cob:get_count() > 0 then + pos.y = pos.y - 2 + local bmeta = minetest.get_meta(pos) + local binv = bmeta:get_inventory() + + binv:add_item("main", "default:gravel 1") + + end + + + + return true +end + + + minetest.register_node("bitumen:rock_crusher", { description = "Small Gas Rock Crusher", drawtype = "nodebox", @@ -120,40 +176,13 @@ minetest.register_node("bitumen:rock_crusher", { on_punch = function(pos) swap_node(pos, "bitumen:rock_crusher_on") - try_turn_on(pos) + minetest.get_node_timer(pos):start(2.0) + --try_turn_on(pos) + end, + + on_timer = function(pos) + return false end, - - on_timer = function(pos, elapsed) - - local meta = minetest.get_meta(pos) - - local fuel = meta:get_float("fuel") or 0.0 - - if fuel <= 0 then - -- try to get some fuel - local inv = meta:get_inventory() - - local st = inv:get_stack("main", 1) - - if take_gas(st, 1) then - inv:set_stack("main", 1, st); - fuel = fuel + 1 - else - -- out of fuel, turn off - return false - end - - end - - fuel = fuel - .1 - meta:set_float("fuel", fuel) - - -- try to grind some rocks - - - - - end }) @@ -190,11 +219,16 @@ minetest.register_node("bitumen:rock_crusher_on", { on_punch = function(pos) swap_node(pos, "bitumen:rock_crusher") - destruct_light(pos) +-- destruct_light(pos) end, + on_timer = crushtimer, }) +bitumen.register_blueprint({ + name="bitumen:rock_crusher", + no_constructor_craft = true, +})