diff options
author | root <root@mirzakhani.gpcf.eu> | 2018-04-30 18:15:36 +0200 |
---|---|---|
committer | root <root@mirzakhani.gpcf.eu> | 2018-04-30 18:15:36 +0200 |
commit | 2462530981a61bbc83085cc3f1f5122310f94f3c (patch) | |
tree | af822328faf81b40c602966cb132892eb737901a /extranodes | |
parent | 1a93eef46fcb66d7d4d08b091bdb16c113188652 (diff) | |
parent | 4e2a550ec92801f3ceaedfbed0d4f8b7b5308ed1 (diff) |
Merge https://github.com/h-v-smacker/technic
Diffstat (limited to 'extranodes')
-rw-r--r-- | extranodes/lox.lua | 205 | ||||
-rw-r--r-- | extranodes/textures/technic_fbomb.png | bin | 0 -> 2099 bytes | |||
-rw-r--r-- | extranodes/textures/technic_fbombact.png | bin | 0 -> 2427 bytes | |||
-rw-r--r-- | extranodes/textures/technic_snowflake.png | bin | 0 -> 635 bytes |
4 files changed, 162 insertions, 43 deletions
diff --git a/extranodes/lox.lua b/extranodes/lox.lua index 08b2269..a4831a6 100644 --- a/extranodes/lox.lua +++ b/extranodes/lox.lua @@ -1,3 +1,6 @@ +-- An small arsenal of tools to battle the lava craters + + local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end local freezing_rules = { @@ -13,15 +16,84 @@ local freezing_rules = { ["ethereal:mushroom_dirt"] = "default:dirt_with_snow", } +local function freeze(user, pos, radius, itemstack) + + -- itemstack is true if the function is used in a tool callback + -- if so, user is a playerref + -- if itemstack is false, it's a node using the function, and the + -- user name is plain text string + + if (itemstack) then + + if minetest.is_protected(pos, user:get_player_name()) then + minetest.record_protection_violation(pos, user:get_player_name()) + return + end + + else + if minetest.is_protected(pos, user) then + minetest.record_protection_violation(pos, user) + return + end + end + + local loc = {} + local wrk = false + -- R = 2, d = 3 + -- R = 10, d = 5 + local depth = math.floor(0.25*radius+2.5) + + for y = 0,depth,1 do + for x = -radius,radius,1 do + for z = -radius,radius,1 do + loc = {x = pos.x - x, y = pos.y - y, z = pos.z - z} + if freezing_rules[minetest.get_node(loc).name] then + wrk = true + minetest.swap_node(loc, {name = freezing_rules[minetest.get_node(loc).name]}) + end + if math.random(1,5) == 5 then + if minetest.get_node({x = loc.x, y = loc.y+1, z = loc.z}).name == "air" + and minetest.get_node(loc).name ~= "air" + and minetest.get_node(loc).name ~= "stairs:slab_snowblock" then + minetest.set_node({x = loc.x, y = loc.y+1, z = loc.z}, {name = "stairs:slab_snowblock"}) + end + end + end + end + end + + if wrk then + minetest.sound_play("default_cool_lava", {gain = 1, pos = pos}) + end + + if (itemstack) then + + itemstack:take_item() + local uinv = user:get_inventory() + if uinv:room_for_item("main", "vessels:steel_bottle 1") then + uinv:add_item("main", "vessels:steel_bottle 1") + else + minetest.item_drop(ItemStack("vessels:steel_bottle 1"), user, user:getpos()) + end + + user:set_hp(user:get_hp() - 1) + + return itemstack + else + return true + end + +end + minetest.register_craftitem(":technic:lox", { description = S("Liquid Oxygen"), - drawtype = "plantlike", tiles = {"technic_lox.png"}, inventory_image = "technic_lox.png", wield_image = "technic_lox.png", paramtype = "light", is_ground_content = false, walkable = false, + liquids_pointable = true, selection_box = { type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25} @@ -32,49 +104,96 @@ minetest.register_craftitem(":technic:lox", { if pointed_thing.type ~= "node" then return itemstack end - - if minetest.is_protected(pointed_thing.under, user:get_player_name()) then - minetest.record_protection_violation(pointed_thing.under, user:get_player_name()) - return - end - - local pos = pointed_thing.under + freeze(user, pointed_thing.under, 2, itemstack) + end +}) - local loc = {} - local wrk = false - for y=0,3,1 do - for x=-2,2,1 do - for z = -2,2,1 do - loc = {x = pos.x - x, y = pos.y - y, z = pos.z - z} - if freezing_rules[minetest.get_node(loc).name] then - wrk = true - minetest.swap_node(loc, {name = freezing_rules[minetest.get_node(loc).name]}) - end - if math.random(1,5) == 5 then - if minetest.get_node({x = loc.x, y = loc.y+1, z = loc.z}).name == "air" - and minetest.get_node(loc).name ~= "air" - and minetest.get_node(loc).name ~= "stairs:slab_snowblock" then - minetest.set_node({x = loc.x, y = loc.y+1, z = loc.z}, {name = "stairs:slab_snowblock"}) - end - end - end - end - end - - if wrk then - minetest.sound_play("default_cool_lava", {gain = 1, pos = pos}) - end +minetest.register_node(":technic:fbomb", { + description = S("F-Bomb"), + tiles = {"technic_fbomb.png"}, + paramtype = "light", + is_ground_content = false, + walkable = false, + selection_box = { + type = "fixed", + fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25} + }, + groups = {dig_immediate = 2, falling_node = 1}, + sounds = default.node_sound_defaults(), + on_punch = function(pos, node, player, pointed_thing) + minetest.remove_node(pos) + minetest.place_node(pos, {name="technic:fbombact"}) + local nm = minetest.get_meta(pos) + nm:set_string("player", player:get_player_name()) + end +}) - itemstack:take_item() - local uinv = user:get_inventory() - if uinv:room_for_item("main", "vessels:steel_bottle 1") then - uinv:add_item("main", "vessels:steel_bottle 1") - else - minetest.item_drop(ItemStack("vessels:steel_bottle 1"), user, user:getpos()) +minetest.register_node(":technic:fbombact", { + description = S("F-Bomb Active"), + tiles = {"technic_fbombact.png"}, + paramtype = "light", + is_ground_content = false, + walkable = false, + light_source = 3, + selection_box = { + type = "fixed", + fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25} + }, + groups = {falling_node = 1, cracky = 1, not_in_creative_inventory = 1}, + sounds = default.node_sound_defaults(), + on_construct = function(pos) + local nm = minetest.get_meta(pos) + local id = minetest.add_particlespawner({ + amount = 30, + time = 0, + minpos = pos, + maxpos = pos, + minvel = {x=-2, y=0, z=-2}, + maxvel = {x=2, y=0, z=2}, + minacc = {x=0, y=0, z=0}, + maxacc = {x=0.5, y=0, z=0.5}, + minexptime = 1, + maxexptime = 5, + minsize = 1, + maxsize = 4, + collisiondetection = false, + vertical = false, + texture = "technic_snowflake.png", + glow = 2 + }) + nm:set_int("id", id) + local tm = minetest.get_node_timer(pos) + tm:start(5) + end, + on_timer = function(pos, elapsed) + local nm = minetest.get_meta(pos) + local pn = nm:get_string("player") + freeze(pn, pos, 10) + minetest.remove_node(pos) + return false + end, + on_destruct = function(pos) + local nm = minetest.get_meta(pos) + if (nm:get_int("id")) then + minetest.delete_particlespawner(nm:get_int("id")) end - - user:set_hp(user:get_hp() - 1) - - return itemstack - end + end, + drop = "technic:fbomb" + }) + +minetest.register_craft({ + output = "technic:fbomb 3", + recipe = { + { "technic:lox", "tnt:tnt", "technic:lox"}, + { "tnt:tnt", "technic:lox", "tnt:tnt"}, + { "technic:lox", "tnt:tnt", "technic:lox"} + }, + }) + +-- since there will be a significant surplus of snow slabs, a recipe for recycling is in order +minetest.register_craft({ + output = "default:snowblock", + type = "shapeless", + recipe = { "stairs:slab_snowblock", "stairs:slab_snowblock" }, + })
\ No newline at end of file diff --git a/extranodes/textures/technic_fbomb.png b/extranodes/textures/technic_fbomb.png Binary files differnew file mode 100644 index 0000000..edae1a1 --- /dev/null +++ b/extranodes/textures/technic_fbomb.png diff --git a/extranodes/textures/technic_fbombact.png b/extranodes/textures/technic_fbombact.png Binary files differnew file mode 100644 index 0000000..061f23f --- /dev/null +++ b/extranodes/textures/technic_fbombact.png diff --git a/extranodes/textures/technic_snowflake.png b/extranodes/textures/technic_snowflake.png Binary files differnew file mode 100644 index 0000000..1e039af --- /dev/null +++ b/extranodes/textures/technic_snowflake.png |