From 5e19514c60bd46a939beeeddde1125f137c486fb Mon Sep 17 00:00:00 2001 From: Carter Kolwey <cheapiephp@gmail.com> Date: Tue, 28 Feb 2017 00:58:43 +0100 Subject: [PATCH] Add dirt recipe to centrifuge 4 dirt -> 2 clay lumps, 1 sand, 1 gravel --- technic/machines/MV/wind_mill.lua | 99 ++++++++++++++++++++++++++----------------------- 1 files changed, 53 insertions(+), 46 deletions(-) diff --git a/technic/machines/MV/wind_mill.lua b/technic/machines/MV/wind_mill.lua index 1090c4c..28a075d 100644 --- a/technic/machines/MV/wind_mill.lua +++ b/technic/machines/MV/wind_mill.lua @@ -1,37 +1,76 @@ +local S = technic.getter + minetest.register_craft({ output = 'technic:wind_mill_frame 5', recipe = { - {'default:steel_ingot', '', 'default:steel_ingot'}, - {'', 'default:steel_ingot', ''}, - {'default:steel_ingot', '', 'default:steel_ingot'}, + {'technic:carbon_steel_ingot', '', 'technic:carbon_steel_ingot'}, + {'', 'technic:carbon_steel_ingot', ''}, + {'technic:carbon_steel_ingot', '', 'technic:carbon_steel_ingot'}, } }) minetest.register_craft({ output = 'technic:wind_mill', recipe = { - {'', 'default:steel_ingot', ''}, - {'default:steel_ingot', 'technic:motor', 'default:steel_ingot'}, - {'', 'default:steelblock', ''}, + {'', 'technic:motor', ''}, + {'technic:carbon_steel_ingot', 'technic:carbon_steel_block', 'technic:carbon_steel_ingot'}, + {'', 'technic:mv_cable', ''}, } }) minetest.register_node("technic:wind_mill_frame", { - description = "Wind Mill Frame", + description = S("Wind Mill Frame"), drawtype = "glasslike_framed", - tiles = {"default_steel_block.png", "default_glass.png"}, + tiles = {"technic_carbon_steel_block.png", "default_glass.png"}, sunlight_propagates = true, groups = {cracky=3}, sounds = default.node_sound_stone_defaults(), paramtype = "light", }) +local function check_wind_mill(pos) + if pos.y < 30 then + return false + end + pos = {x=pos.x, y=pos.y, z=pos.z} + for i = 1, 20 do + pos.y = pos.y - 1 + local node = minetest.get_node_or_nil(pos) + if not node then + -- we reached CONTENT_IGNORE, we can assume, that nothing changed + -- as the user will have to load the block to change it + return + end + if node.name ~= "technic:wind_mill_frame" then + return false + end + end + return true +end + +local run = function(pos, node) + local meta = minetest.get_meta(pos) + local machine_name = S("Wind %s Generator"):format("MV") + + local check = check_wind_mill(pos) + if check == false then + meta:set_int("MV_EU_supply", 0) + meta:set_string("infotext", S("%s Improperly Placed"):format(machine_name)) + elseif check == true then + local power = math.min(pos.y * 100, 5000) + meta:set_int("MV_EU_supply", power) + meta:set_string("infotext", S("@1 (@2 EU)", machine_name, technic.pretty_num(power))) + end + -- check == nil: assume nothing has changed +end + minetest.register_node("technic:wind_mill", { - description = "Wind Mill", - tiles = {"default_steel_block.png"}, + description = S("Wind %s Generator"):format("MV"), + tiles = {"technic_carbon_steel_block.png"}, paramtype2 = "facedir", - groups = {cracky=1}, + groups = {cracky=1, technic_machine=1, technic_mv=1}, + connect_sides = {"top", "bottom", "back", "left", "right"}, sounds = default.node_sound_stone_defaults(), drawtype = "nodebox", paramtype = "light", @@ -46,42 +85,10 @@ }, on_construct = function(pos) local meta = minetest.get_meta(pos) - meta:set_string("infotext", "Wind Mill") + meta:set_string("infotext", S("Wind %s Generator"):format("MV")) meta:set_int("MV_EU_supply", 0) - end, -}) - -local function check_wind_mill(pos) - if pos.y < 30 then - return false - end - for i = 1, 20 do - local node = minetest.get_node({x=pos.x, y=pos.y-i, z=pos.z}) - if node.name ~= "technic:wind_mill_frame" then - return false - end - end - return true -end - -minetest.register_abm({ - nodenames = {"technic:wind_mill"}, - interval = 1, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - local meta = minetest.get_meta(pos) - local power = math.min(pos.y * 100, 5000) - - if not check_wind_mill(pos) then - meta:set_int("MV_EU_supply", 0) - meta:set_string("infotext", "Wind Mill Inproperly Placed") - return - else - meta:set_int("MV_EU_supply", power) - end - - meta:set_string("infotext", "Wind Mill ("..power.."EU)") - end + end, + technic_run = run, }) technic.register_machine("MV", "technic:wind_mill", technic.producer) -- Gitblit v1.8.0