diff --git a/init.lua b/init.lua index 1bd123e..3760831 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,14 @@ local modpath = minetest.get_modpath("adv_vehicles") dofile(modpath.."/api.lua") +local function random_dropped_items_amount(player, itemstack, max_items_amount) + local random_items_amount_to_give = math.random(max_items_amount) + + local stack = ItemStack(itemstack.. tostring(random_items_amount_to_give)) + local inv = minetest.get_inventory({type="player", name=player:get_player_name()}) + inv:add_item("main", stack) +end + minetest.register_craftitem("adv_vehicles:car_frame", { description = "Car Frame (raw)", inventory_image = "car_frame.png" @@ -11,6 +19,94 @@ minetest.register_craftitem("adv_vehicles:wheel", { inventory_image = "wheel.png" }) +minetest.register_craftitem("adv_vehicles:silicon_dust", { + description = "Silicon Dust", + inventory_image = "silicon_dust.png" +}) + +minetest.register_craftitem("adv_vehicles:aluminium_dust", { + description = "Aluminium Dust", + inventory_image = "aluminium_dust.png" +}) + +minetest.register_craftitem("adv_vehicles:aluminium_lump", { + description = "Aluminium Lump", + inventory_image = "aluminium_lump.png" +}) + +minetest.register_craftitem("adv_vehicles:silicon_lump", { + description = "Silicon Lump", + inventory_image = "silicon_lump.png" +}) + +minetest.register_craftitem("adv_vehicles:headlight_red", { + description = "Red Headlight", + inventory_image = "headlight_red.png" +}) + +minetest.register_craftitem("adv_vehicles:headlight_white", { + description = "White Headlight", + inventory_image = "headlight_white.png" +}) + +minetest.register_node("adv_vehicles:aluminium_ore", { + description = "Aluminium Ore", + tiles = {"default_stone.png^aluminium_ore.png"}, + is_ground_content = true, + paramtype = "light", + light_source = 1, + drop="", + groups = {cracky=3, oddly_breakable_by_hand=1}, + sounds = default.node_sound_defaults(), + after_dig_node = function(pos, oldnode, oldmetadata, digger) + random_dropped_items_amount(digger, "adv_vehicles:aluminium_lump ", 6) + end +}) + +minetest.register_node("adv_vehicles:silicon_ore", { + description = "Silicon Ore", + tiles = {"default_stone.png^silicon_ore.png"}, + is_ground_content = true, + paramtype = "light", + light_source = 6, + drop="", + groups = {cracky=3, oddly_breakable_by_hand=1}, + sounds = default.node_sound_defaults(), + after_dig_node = function(pos, oldnode, oldmetadata, digger) + random_dropped_items_amount(digger, "adv_vehicles:silicon_lump ", 4) + end +}) + +minetest.register_ore({ + ore_type = "sheet", + ore = "adv_vehicles:aluminium_ore", + wherein = "default:stone", + clust_scarcity = 180, + clust_num_ores = 7, + clust_size = 4, + height_min = -31000, + height_max = -40 +}) + +minetest.register_ore({ + ore_type = "scatter", + ore = "adv_vehicles:silicon_ore", + wherein = "default:stone", + clust_scarcity = 140, + clust_num_ores = 5, + clust_size = 3, + height_min = -31000, + height_max = -60 +}) + +for i, v in pairs({"red", "white", "blue", "green"}) do + minetest.register_craftitem("adv_vehicles:".. v .. "_led", { + description = string.upper(string.sub(v, 1, 1)) .. string.sub(v, 2) .. " LED", + inventory_image = v .. "_led.png" + }) +end + + local plastic_itemstring if minetest.get_modpath("basic_materials") then plastic_itemstring = "basic_materials:plastic_sheet" @@ -36,9 +132,61 @@ minetest.register_craft({ {"default:steel_ingot", plastic_itemstring, ""}, {"", "", ""} } - }) +}) +minetest.register_craft({ + type="shapeless", + output = "adv_vehicles:aluminium_dust", + recipe = {"adv_vehicles:aluminium_lump"} +}) +minetest.register_craft({ + type="shapeless", + output = "adv_vehicles:silicon_dust", + recipe = {"adv_vehicles:silicon_lump"} +}) + +minetest.register_craft({ + output = "adv_vehicles:red_led", + recipe = { + {"adv_vehicles:aluminium_dust", plastic_itemstring, "default:copper_ingot"}, + {"", "", ""}, + {"", "", ""} + } +}) + +minetest.register_craft({ + output = "adv_vehicles:blue_led", + recipe = { + {"adv_vehicles:silicon_dust", plastic_itemstring, "default:copper_ingot"}, + {"", "", ""}, + {"", "", ""} + } +}) + +minetest.register_craft({ + type = "shapeless", + output = "adv_vehicles:white_led", + recipe = {"adv_vehicles:red_led", "adv_vehicles:blue_led", "adv_vehicles:green_led"} +}) + +minetest.register_craft({ + output = "adv_vehicles:headlight_red", + recipe = { + {"adv_vehicles:red_led", "adv_vehicles:red_led", "adv_vehicles:red_led"}, + {"adv_vehicles:red_led", plastic_itemstring, "adv_vehicles:red_led"}, + {"adv_vehicles:red_led", "default:steel_ingot", "adv_vehicles:red_led"} + } +}) + +minetest.register_craft({ + output = "adv_vehicles:headlight_white", + recipe = { + {"adv_vehicles:white_led", "adv_vehicles:white_led", "adv_vehicles:white_led"}, + {"adv_vehicles:white_led", plastic_itemstring, "adv_vehicles:white_led"}, + {"adv_vehicles:white_led", "default:steel_ingot", "adv_vehicles:white_led"} + } +}) adv_vehicles.register_vehicle("bmw_118_two_seats", { hp_max = 60, mass = 1.3, diff --git a/textures/aluminium_dust.png b/textures/aluminium_dust.png new file mode 100644 index 0000000..c33957d Binary files /dev/null and b/textures/aluminium_dust.png differ diff --git a/textures/aluminium_lump.png b/textures/aluminium_lump.png new file mode 100644 index 0000000..cde40d3 Binary files /dev/null and b/textures/aluminium_lump.png differ diff --git a/textures/aluminium_ore.png b/textures/aluminium_ore.png new file mode 100644 index 0000000..e4bf2c4 Binary files /dev/null and b/textures/aluminium_ore.png differ diff --git a/textures/blue_led.png b/textures/blue_led.png new file mode 100644 index 0000000..edbd4e5 Binary files /dev/null and b/textures/blue_led.png differ diff --git a/textures/green_led.png b/textures/green_led.png new file mode 100644 index 0000000..a63be35 Binary files /dev/null and b/textures/green_led.png differ diff --git a/textures/headlight_red.png b/textures/headlight_red.png new file mode 100644 index 0000000..06e66f3 Binary files /dev/null and b/textures/headlight_red.png differ diff --git a/textures/headlight_white.png b/textures/headlight_white.png new file mode 100644 index 0000000..1e020eb Binary files /dev/null and b/textures/headlight_white.png differ diff --git a/textures/red_led.png b/textures/red_led.png new file mode 100644 index 0000000..0c2201c Binary files /dev/null and b/textures/red_led.png differ diff --git a/textures/silicon_dust.png b/textures/silicon_dust.png new file mode 100644 index 0000000..fe26853 Binary files /dev/null and b/textures/silicon_dust.png differ diff --git a/textures/silicon_lump.png b/textures/silicon_lump.png new file mode 100644 index 0000000..e512fb0 Binary files /dev/null and b/textures/silicon_lump.png differ diff --git a/textures/silicon_ore.png b/textures/silicon_ore.png new file mode 100644 index 0000000..c43e980 Binary files /dev/null and b/textures/silicon_ore.png differ diff --git a/textures/wheel.png b/textures/wheel.png index ff5bc82..9526e03 100644 Binary files a/textures/wheel.png and b/textures/wheel.png differ diff --git a/textures/white_led.png b/textures/white_led.png new file mode 100644 index 0000000..3cc4d25 Binary files /dev/null and b/textures/white_led.png differ