diff --git a/games/minitest/README.txt b/games/minitest/README.txt new file mode 100644 index 0000000..0e36388 --- /dev/null +++ b/games/minitest/README.txt @@ -0,0 +1,16 @@ +===Minicraft - a game for MINETEST-C55=== +by PilzAdam + +Introduction: +This game tries to copy some elements of the Minecraft gameplay. + +How to install: +Unzip the folder and copy it to the game/ folder in your Minetest directory. Then create a new world and choose Minitest as game. + +License: +The most textures are from Jordach. +All mods have a README.txt; read these for license and authors. +Mods without a README.txt are from me (PilzAdam) and under the WTFPL (all parts). + +See also: +http://minetest.net/ \ No newline at end of file diff --git a/games/minitest/game.conf b/games/minitest/game.conf new file mode 100644 index 0000000..a80c0a5 --- /dev/null +++ b/games/minitest/game.conf @@ -0,0 +1 @@ +name = MiniTest diff --git a/games/minitest/mods/animatedfluids/README.md b/games/minitest/mods/animatedfluids/README.md new file mode 100644 index 0000000..439a84d --- /dev/null +++ b/games/minitest/mods/animatedfluids/README.md @@ -0,0 +1,8 @@ +Animated-Fluids +=============== + +A mod for minetest + +extract the zip to ~/.minetest/mods/minetest/ + +rename khonkhortisan-animatedfluids-a73caea to animatedfluids diff --git a/games/minitest/mods/animatedfluids/depends.txt b/games/minitest/mods/animatedfluids/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/games/minitest/mods/animatedfluids/depends.txt @@ -0,0 +1 @@ +default diff --git a/games/minitest/mods/animatedfluids/init.lua b/games/minitest/mods/animatedfluids/init.lua new file mode 100644 index 0000000..936d2a2 --- /dev/null +++ b/games/minitest/mods/animatedfluids/init.lua @@ -0,0 +1,13 @@ +fluids = {'water', 'lava'} +for fluid=1,#fluids do + name = fluids[fluid] + fluid = minetest.registered_nodes['default:'..name..'_flowing'] + tile = {name='default_'..name..'_animated.png', animation={type='vertical_frames', aspect_w=16, aspect_h=16, length=fluid.viscosity}} + fluid.tiles = {tile} + tile1 = tile + tile2 = tile + tile1.backface_culling=false + tile2.backface_culling=true + fluid.special_tiles = {tile1,tile2} + minetest.register_node(':default:'..name..'_flowing', fluid) +end diff --git a/games/minitest/mods/animatedfluids/textures/default_lava_animated.png b/games/minitest/mods/animatedfluids/textures/default_lava_animated.png new file mode 100644 index 0000000..0fb8206 Binary files /dev/null and b/games/minitest/mods/animatedfluids/textures/default_lava_animated.png differ diff --git a/games/minitest/mods/animatedfluids/textures/default_water_animated.png b/games/minitest/mods/animatedfluids/textures/default_water_animated.png new file mode 100644 index 0000000..ac4cdaf Binary files /dev/null and b/games/minitest/mods/animatedfluids/textures/default_water_animated.png differ diff --git a/games/minitest/mods/animatedfluids/textures/lava.gif b/games/minitest/mods/animatedfluids/textures/lava.gif new file mode 100644 index 0000000..6eaa75a Binary files /dev/null and b/games/minitest/mods/animatedfluids/textures/lava.gif differ diff --git a/games/minitest/mods/animatedfluids/textures/water.gif b/games/minitest/mods/animatedfluids/textures/water.gif new file mode 100644 index 0000000..129b77e Binary files /dev/null and b/games/minitest/mods/animatedfluids/textures/water.gif differ diff --git a/games/minitest/mods/animatedtorches/README b/games/minitest/mods/animatedtorches/README new file mode 100644 index 0000000..31ea128 --- /dev/null +++ b/games/minitest/mods/animatedtorches/README @@ -0,0 +1,14 @@ +This simple mod uses a bit of code cobbled together from the default +torches and from the recently-introduced animated lava to create proper, +animated torches. All existing torches (wall, ceiling, floor) will be +displayed with the new animated texture, but no nodes are being +replaced. Inventory/wield image uses the stock torch image already +supplied with Minetest. + +Textures by me (derived from a rendered torch and an actual burning +flame). + +This mod requires a build or git pull of Minetest dated June 17, 2012 or +later. + +License: GPL for the code, WTFPL for the textures. diff --git a/games/minitest/mods/animatedtorches/copyright.txt b/games/minitest/mods/animatedtorches/copyright.txt new file mode 100644 index 0000000..3247334 --- /dev/null +++ b/games/minitest/mods/animatedtorches/copyright.txt @@ -0,0 +1,4 @@ +Code copied from minetest's stock code by celeron55 et.al, modifications +and all textures by Vanessa Ezekowitz. + +Licenses: For the lua code, GPL. For all images and everything else, WTFPL. diff --git a/games/minitest/mods/animatedtorches/depends.txt b/games/minitest/mods/animatedtorches/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/games/minitest/mods/animatedtorches/depends.txt @@ -0,0 +1 @@ +default diff --git a/games/minitest/mods/animatedtorches/init.lua b/games/minitest/mods/animatedtorches/init.lua new file mode 100644 index 0000000..bc39e4e --- /dev/null +++ b/games/minitest/mods/animatedtorches/init.lua @@ -0,0 +1,33 @@ +-- Animated torches, based on the static torches and animated lava code +-- from Minetest; modifications by Vanessa Ezekowitz 2012-06-17 +-- +-- License: LGPL + +minetest.register_node(":default:torch", { + description = "Torch", + drawtype = "torchlike", + tiles = { + + -- "default_torch_on_floor.png", "default_torch_on_ceiling.png", "default_torch.png" + + {name="default_torch_on_floor_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}}, + {name="default_torch_on_ceiling_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}}, + {name="default_torch_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}} + + }, + inventory_image = "default_torch_on_floor.png", + wield_image = "default_torch_on_floor.png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + walkable = false, + light_source = LIGHT_MAX-1, + selection_box = { + type = "wallmounted", + wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1}, + wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, + wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1}, + }, + groups = {choppy=2,dig_immediate=3,flammable=1}, + sounds = default.node_sound_defaults(), +}) diff --git a/games/minitest/mods/animatedtorches/textures/default_torch_animated.png b/games/minitest/mods/animatedtorches/textures/default_torch_animated.png new file mode 100644 index 0000000..ca1668c Binary files /dev/null and b/games/minitest/mods/animatedtorches/textures/default_torch_animated.png differ diff --git a/games/minitest/mods/animatedtorches/textures/default_torch_on_ceiling_animated.png b/games/minitest/mods/animatedtorches/textures/default_torch_on_ceiling_animated.png new file mode 100644 index 0000000..b101561 Binary files /dev/null and b/games/minitest/mods/animatedtorches/textures/default_torch_on_ceiling_animated.png differ diff --git a/games/minitest/mods/animatedtorches/textures/default_torch_on_floor.png b/games/minitest/mods/animatedtorches/textures/default_torch_on_floor.png new file mode 100644 index 0000000..925a59a Binary files /dev/null and b/games/minitest/mods/animatedtorches/textures/default_torch_on_floor.png differ diff --git a/games/minitest/mods/animatedtorches/textures/default_torch_on_floor_animated.png b/games/minitest/mods/animatedtorches/textures/default_torch_on_floor_animated.png new file mode 100644 index 0000000..0b55818 Binary files /dev/null and b/games/minitest/mods/animatedtorches/textures/default_torch_on_floor_animated.png differ diff --git a/games/minitest/mods/beds/README.txt b/games/minitest/mods/beds/README.txt new file mode 100644 index 0000000..0b8f4ac --- /dev/null +++ b/games/minitest/mods/beds/README.txt @@ -0,0 +1,48 @@ +===BEDS MOD for MINETEST-C55=== +by PilzAdam + +Introduction: +This mods brings beds to Minetest. You can use them to sleep at night +to prevent attacks by evil mobs. + +How to install: +Unzip the archive an place it in minetest-base-directory/mods/minetest/ +if you have a windows client or a linux run-in-place client. If you have +a linux system-wide instalation place it in ~/.minetest/mods/minetest/. +If you want to install this mod only in one world create the folder +worldmods/ in your worlddirectory. +For further information or help see: +http://wiki.minetest.com/wiki/Installing_Mods + +How to use the mod: +Craft a bed like this: +red wool blue wool blue wool +stick stick +(Theres no "normal" way to get wool so you can use the commands +"/giveme wool:red" and "/giveme wool:blue 2") +After placing it anywhere you can go to sleep with a leftklick with your +hand on the bed. If it is night a chatmessage wishs you "Good night" and +you sleep until the next morning. To go outside the bed it is recommended +to hit the bed again with a leftklick (it also works if you just go away +but its not so safe). + +License: +Sourcecode: WTFPL (see below) +Graphics: WTFPL (see below) + +See also: +http://minetest.net/ + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/games/minitest/mods/beds/depends.txt b/games/minitest/mods/beds/depends.txt new file mode 100644 index 0000000..470ec30 --- /dev/null +++ b/games/minitest/mods/beds/depends.txt @@ -0,0 +1,2 @@ +default +wool diff --git a/games/minitest/mods/beds/init.lua b/games/minitest/mods/beds/init.lua new file mode 100644 index 0000000..8bd5248 --- /dev/null +++ b/games/minitest/mods/beds/init.lua @@ -0,0 +1,211 @@ +local player_ges = 0 +local player_in_bed = 0 + +minetest.register_node("beds:bed_bottom", { + description = "Bed", + drawtype = "nodebox", + tiles = {"beds_bed_top_bottom.png", "default_wood.png", "beds_bed_side.png", "beds_bed_side.png", "beds_bed_side.png", "beds_bed_side.png"}, + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3}, + sounds = default.node_sound_wood_defaults(), + node_box = { + type = "fixed", + fixed = { + -- bed + {-0.5, 0.0, -0.5, 0.5, 0.3, 0.5}, + + -- stützen + {-0.5, -0.5, -0.5, -0.4, 0.0, -0.4}, + {0.4, 0.0, -0.4, 0.5, -0.5, -0.5}, + } + }, + selection_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.3, 1.5}, + } + }, + + + on_construct = function(pos) + local node = minetest.env:get_node(pos) + local param2 = node.param2 + if param2 == 0 then + node.name = "beds:bed_top" + pos.z = pos.z+1 + minetest.env:set_node(pos, node) + elseif param2 == 1 then + node.name = "beds:bed_top" + pos.x = pos.x+1 + minetest.env:set_node(pos, node) + elseif param2 == 2 then + node.name = "beds:bed_top" + pos.z = pos.z-1 + minetest.env:set_node(pos, node) + elseif param2 == 3 then + node.name = "beds:bed_top" + pos.x = pos.x-1 + minetest.env:set_node(pos, node) + end + end, + + on_destruct = function(pos) + local node = minetest.env:get_node(pos) + local param2 = node.param2 + if param2 == 0 then + pos.z = pos.z+1 + minetest.env:remove_node(pos) + elseif param2 == 1 then + pos.x = pos.x+1 + minetest.env:remove_node(pos) + elseif param2 == 2 then + pos.z = pos.z-1 + minetest.env:remove_node(pos) + elseif param2 == 3 then + pos.x = pos.x-1 + minetest.env:remove_node(pos) + end + end, + + on_punch = function(pos, node, puncher) + if not puncher:is_player() then + return + end + if puncher:get_wielded_item():get_name() == "" then + local meta = minetest.env:get_meta(pos) + local param2 = node.param2 + if param2 == 0 then + pos.z = pos.z+1 + elseif param2 == 1 then + pos.x = pos.x+1 + elseif param2 == 2 then + pos.z = pos.z-1 + elseif param2 == 3 then + pos.x = pos.x-1 + end + if puncher:get_player_name() == meta:get_string("player") then + if param2 == 0 then + pos.x = pos.x-1 + elseif param2 == 1 then + pos.z = pos.z+1 + elseif param2 == 2 then + pos.x = pos.x+1 + elseif param2 == 3 then + pos.z = pos.z-1 + end + pos.y = pos.y-0.5 + puncher:setpos(pos) + meta:set_string("player", "") + player_in_bed = player_in_bed-1 + elseif meta:get_string("player") == "" then + pos.y = pos.y-0.5 + puncher:setpos(pos) + meta:set_string("player", puncher:get_player_name()) + player_in_bed = player_in_bed+1 + end + end + end +}) + +minetest.register_node("beds:bed_top", { + drawtype = "nodebox", + tiles = {"beds_bed_top_top.png", "default_wood.png", "beds_bed_side_top_r.png", "beds_bed_side_top_l.png", "default_wood.png", "beds_bed_side.png"}, + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3}, + sounds = default.node_sound_wood_defaults(), + node_box = { + type = "fixed", + fixed = { + -- bed + {-0.5, 0.0, -0.5, 0.5, 0.3, 0.5}, + + -- stützen + {-0.4, 0.0, 0.4, -0.5, -0.5, 0.5}, + {0.5, -0.5, 0.5, 0.4, 0.0, 0.4}, + } + }, + selection_box = { + type = "fixed", + fixed = { + {0, 0, 0, 0, 0, 0}, + } + }, +}) + +minetest.register_alias("beds:bed", "beds:bed_bottom") + +minetest.register_craft({ + output = "beds:bed", + recipe = { + {"wool:red", "wool:blue", "wool:blue", }, + {"default:stick", "", "default:stick", } + } +}) + +minetest.register_on_joinplayer(function(pl) + player_ges = player_ges+1 +end) + +minetest.register_on_leaveplayer(function(pl) + player_ges = player_ges-1 +end) + +local timer = 0 +local wait = false +minetest.register_globalstep(function(dtime) + if timer<10 then + timer = timer+dtime + end + timer = 0 + + if player_ges == player_in_bed and player_ges ~= 0 then + if minetest.env:get_timeofday() < 0.2 or minetest.env:get_timeofday() > 0.805 then + if not wait then + minetest.chat_send_all("Good night!!!") + minetest.after(2, function() + minetest.env:set_timeofday(0.23) + wait = false + end) + wait = true + end + end + end +end) + +minetest.register_abm({ + nodenames = {"beds:bed_bottom"}, + interval = 1, + chance = 1, + action = function(pos, node) + local meta = minetest.env:get_meta(pos) + if meta:get_string("player") ~= "" then + local param2 = node.param2 + if param2 == 0 then + pos.z = pos.z+1 + elseif param2 == 1 then + pos.x = pos.x+1 + elseif param2 == 2 then + pos.z = pos.z-1 + elseif param2 == 3 then + pos.x = pos.x-1 + end + local player = minetest.env:get_player_by_name(meta:get_string("player")) + if player == nil then + meta:set_string("player", "") + player_in_bed = player_in_bed-1 + return + end + local player_pos = player:getpos() + player_pos.x = math.floor(0.5+player_pos.x) + player_pos.y = math.floor(0.5+player_pos.y) + player_pos.z = math.floor(0.5+player_pos.z) + if pos.x ~= player_pos.x or pos.y ~= player_pos.y or pos.z ~= player_pos.z then + meta:set_string("player", "") + player_in_bed = player_in_bed-1 + return + end + end + end +}) diff --git a/games/minitest/mods/beds/textures/beds_bed_side.png b/games/minitest/mods/beds/textures/beds_bed_side.png new file mode 100644 index 0000000..c9e79e2 Binary files /dev/null and b/games/minitest/mods/beds/textures/beds_bed_side.png differ diff --git a/games/minitest/mods/beds/textures/beds_bed_side_top_l.png b/games/minitest/mods/beds/textures/beds_bed_side_top_l.png new file mode 100644 index 0000000..4b8dc66 Binary files /dev/null and b/games/minitest/mods/beds/textures/beds_bed_side_top_l.png differ diff --git a/games/minitest/mods/beds/textures/beds_bed_side_top_r.png b/games/minitest/mods/beds/textures/beds_bed_side_top_r.png new file mode 100644 index 0000000..daae624 Binary files /dev/null and b/games/minitest/mods/beds/textures/beds_bed_side_top_r.png differ diff --git a/games/minitest/mods/beds/textures/beds_bed_top_bottom.png b/games/minitest/mods/beds/textures/beds_bed_top_bottom.png new file mode 100644 index 0000000..8331601 Binary files /dev/null and b/games/minitest/mods/beds/textures/beds_bed_top_bottom.png differ diff --git a/games/minitest/mods/beds/textures/beds_bed_top_top.png b/games/minitest/mods/beds/textures/beds_bed_top_top.png new file mode 100644 index 0000000..fc46ee1 Binary files /dev/null and b/games/minitest/mods/beds/textures/beds_bed_top_top.png differ diff --git a/games/minitest/mods/bucket/README.txt b/games/minitest/mods/bucket/README.txt new file mode 100644 index 0000000..7dad641 --- /dev/null +++ b/games/minitest/mods/bucket/README.txt @@ -0,0 +1,26 @@ +Minetest 0.4 mod: bucket +========================= + +License of source code: +----------------------- +Copyright (C) 2011-2012 Kahrl +Copyright (C) 2011-2012 celeron55, Perttu Ahola + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +http://www.gnu.org/licenses/lgpl-2.1.html + +License of media (textures and sounds) +-------------------------------------- +Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) +http://creativecommons.org/licenses/by-sa/3.0/ + +Authors of media files +----------------------- +Everything not listed in here: +Copyright (C) 2010-2012 celeron55, Perttu Ahola + + diff --git a/games/minitest/mods/bucket/depends.txt b/games/minitest/mods/bucket/depends.txt new file mode 100644 index 0000000..3a7daa1 --- /dev/null +++ b/games/minitest/mods/bucket/depends.txt @@ -0,0 +1,2 @@ +default + diff --git a/games/minitest/mods/bucket/init.lua b/games/minitest/mods/bucket/init.lua new file mode 100644 index 0000000..82949dd --- /dev/null +++ b/games/minitest/mods/bucket/init.lua @@ -0,0 +1,96 @@ +-- Minetest 0.4 mod: bucket +-- See README.txt for licensing and other information. + +minetest.register_alias("bucket", "bucket:bucket_empty") +minetest.register_alias("bucket_water", "bucket:bucket_water") +minetest.register_alias("bucket_lava", "bucket:bucket_lava") + +minetest.register_craft({ + output = 'bucket:bucket_empty 1', + recipe = { + {'default:steel_ingot', '', 'default:steel_ingot'}, + {'', 'default:steel_ingot', ''}, + } +}) + +bucket = {} +bucket.liquids = {} + +-- Register a new liquid +-- source = name of the source node +-- flowing = name of the flowing node +-- itemname = name of the new bucket item (or nil if liquid is not takeable) +-- inventory_image = texture of the new bucket item (ignored if itemname == nil) +-- This function can be called from any mod (that depends on bucket). +function bucket.register_liquid(source, flowing, itemname, inventory_image) + bucket.liquids[source] = { + source = source, + flowing = flowing, + itemname = itemname, + } + bucket.liquids[flowing] = bucket.liquids[source] + + if itemname ~= nil then + minetest.register_craftitem(itemname, { + inventory_image = inventory_image, + stack_max = 1, + liquids_pointable = true, + on_use = function(itemstack, user, pointed_thing) + -- Must be pointing to node + if pointed_thing.type ~= "node" then + return + end + -- Check if pointing to a liquid + n = minetest.env:get_node(pointed_thing.under) + if bucket.liquids[n.name] == nil then + -- Not a liquid + minetest.env:add_node(pointed_thing.above, {name=source}) + elseif n.name ~= source then + -- It's a liquid + minetest.env:add_node(pointed_thing.under, {name=source}) + end + return {name="bucket:bucket_empty"} + end + }) + end +end + +minetest.register_craftitem("bucket:bucket_empty", { + description = "Emtpy bucket", + inventory_image = "bucket.png", + stack_max = 1, + liquids_pointable = true, + on_use = function(itemstack, user, pointed_thing) + -- Must be pointing to node + if pointed_thing.type ~= "node" then + return + end + -- Check if pointing to a liquid source + n = minetest.env:get_node(pointed_thing.under) + liquiddef = bucket.liquids[n.name] + if liquiddef ~= nil and liquiddef.source == n.name and liquiddef.itemname ~= nil then + minetest.env:add_node(pointed_thing.under, {name="air"}) + return {name=liquiddef.itemname} + end + end, +}) + +bucket.register_liquid( + "default:water_source", + "default:water_flowing", + "bucket:bucket_water", + "bucket_water.png" +) + +bucket.register_liquid( + "default:lava_source", + "default:lava_flowing", + "bucket:bucket_lava", + "bucket_lava.png" +) + +minetest.register_craft({ + type = "fuel", + recipe = "bucket:bucket_lava", + burntime = 60, +}) diff --git a/games/minitest/mods/bucket/textures/Thumbs.db b/games/minitest/mods/bucket/textures/Thumbs.db new file mode 100644 index 0000000..73bd4d3 Binary files /dev/null and b/games/minitest/mods/bucket/textures/Thumbs.db differ diff --git a/games/minitest/mods/bucket/textures/bucket.png b/games/minitest/mods/bucket/textures/bucket.png new file mode 100644 index 0000000..dd4d049 Binary files /dev/null and b/games/minitest/mods/bucket/textures/bucket.png differ diff --git a/games/minitest/mods/bucket/textures/bucket_lava.png b/games/minitest/mods/bucket/textures/bucket_lava.png new file mode 100644 index 0000000..66ffc24 Binary files /dev/null and b/games/minitest/mods/bucket/textures/bucket_lava.png differ diff --git a/games/minitest/mods/bucket/textures/bucket_water.png b/games/minitest/mods/bucket/textures/bucket_water.png new file mode 100644 index 0000000..301d686 Binary files /dev/null and b/games/minitest/mods/bucket/textures/bucket_water.png differ diff --git a/games/minitest/mods/carts/README.txt b/games/minitest/mods/carts/README.txt new file mode 100644 index 0000000..84035cc --- /dev/null +++ b/games/minitest/mods/carts/README.txt @@ -0,0 +1,55 @@ +===CARTS MOD for MINETEST-C55=== +by PilzAdam + +Version 29 + +Introduction: +This mod adds carts to minetest. There were rails for so long in minetest +but no carts so that they were useless. But this mod brings what many +players all over the world wanted for so long (I think so...). + +How to install: +Unzip the archive an place it in minetest-base-directory/mods/minetest/ +if you have a windows client or a linux run-in-place client. If you have +a linux system-wide instalation place it in ~/.minetest/mods/minetest/. +If you want to install this mod only in one world create the folder +worldmods/ in your worlddirectory. +For further information or help see: +http://wiki.minetest.com/wiki/Installing_Mods + +How to use the mod: +Read the first post at http://minetest.net/forum/viewtopic.php?id=2451 + +Configuration: +(all variables are in init.lua) +line 4: MAX_SPEED => the maximum speed of the cart +line 9: TRANSPORT_PLAYER => transport the player like a normal item + (this is very laggy NOT RECOMMENDED) +line 13: SOUND_FILES => a table with all soundfiles and there length. To + add your own files copy them into carts/sounds (only .ogg files + are supported) and add there name (without ".ogg") and there + lenght (in seconds) to the table. +line 21: SOUND_GAIN => the gain of the sound. +line 27: RAILS => blocks that are treated as rails. + +License: +Sourcecode: WTFPL (see below) +Sound: WTFPL (provided from Ragnarok) +Graphics: CC0 (provided from kddekadenz) + +See also: +http://minetest.net/ + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/games/minitest/mods/carts/chest.lua b/games/minitest/mods/carts/chest.lua new file mode 100644 index 0000000..b1916be --- /dev/null +++ b/games/minitest/mods/carts/chest.lua @@ -0,0 +1,43 @@ +minetest.register_node("carts:chest", { + description = "Railchest", + tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png^default_rail.png", "default_chest_side.png^default_rail.png", "default_chest_side.png^default_rail.png", "default_chest_front.png"}, + paramtype2 = "facedir", + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3}, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[8,8;]".. + "label[0.5.0,0;In:]".. + "list[current_name;in;0.5,0.5;3,3;]".. + "label[4.5.0,0;Out:]".. + "list[current_name;out;4.5,0.5;3,3;]".. + "list[current_player;main;0,4;8,4;]") + meta:set_string("infotext", "Railchest") + local inv = meta:get_inventory() + inv:set_size("in", 3*3) + inv:set_size("out", 3*3) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return (inv:is_empty("in") and inv:is_empty("out")) + end, +}) + +minetest.register_abm({ + nodenames = {"carts:pickup_plate"}, + interval = 0, + chance = 1, + action = function(pos) + minetest.env:remove_node(pos) + end +}) + +minetest.register_craft({ + output = '"carts:chest" 1', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'default:wood', 'default:rail', 'default:wood'}, + {'default:wood', 'default:wood', 'default:wood'} + } +}) diff --git a/games/minitest/mods/carts/depends.txt b/games/minitest/mods/carts/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/games/minitest/mods/carts/depends.txt @@ -0,0 +1 @@ +default diff --git a/games/minitest/mods/carts/functions.lua b/games/minitest/mods/carts/functions.lua new file mode 100644 index 0000000..99af9b3 --- /dev/null +++ b/games/minitest/mods/carts/functions.lua @@ -0,0 +1,17 @@ +local APPROXIMATION = 0.8 + +equals = function(num1, num2) + if math.abs(num1-num2) <= APPROXIMATION then + return true + else + return false + end +end + +pos_equals = function(pos1, pos2) + if pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z then + return true + else + return false + end +end diff --git a/games/minitest/mods/carts/init.lua b/games/minitest/mods/carts/init.lua new file mode 100644 index 0000000..081dd9e --- /dev/null +++ b/games/minitest/mods/carts/init.lua @@ -0,0 +1,807 @@ +--========= +-- Maximum speed of the cart +--========= +local MAX_SPEED = 4.5 +--========= +-- Transport the player like a normal item +-- Note: This is extremly laggy <- FIXME +--========= +TRANSPORT_PLAYER = true +--========= +-- The name of the Soundfile +--========= +SOUND_FILES = { + {"carts_curved_rails", 2}, + {"carts_railway_crossover", 2}, + {"carts_straight_rails", 1}, + } + +--========= +-- The sound gain +SOUND_GAIN = 0.8 +--========= + +--========= +-- Raillike nodes +--========= +RAILS = {"default:rail", "carts:meseconrail_off", "carts:meseconrail_on", "carts:meseconrail_stop_off", "carts:meseconrail_stop_on"} + +local cart = { + physical = true, + collisionbox = {-0.425, -0.425, -0.425, 0.425, 0.425, 0.425}, + visual = "cube", + textures = {"carts_cart_top.png", "carts_cart_bottom.png", "carts_cart_side.png", "carts_cart_side.png", "carts_cart_side.png", "carts_cart_side.png"}, + visual_size = {x=.85, y=.85, z=0.85}, + --Variables + fahren = false, -- true when the cart drives + fallen = false, -- true when the cart drives downhill + bremsen = false, -- true when the cart brakes + dir = nil, -- direction of the cart + old_dir = nil, -- saves the direction when the cart stops + items = {}, -- list with transported items + weiche = {x=nil, y=nil, z=nil}, -- saves the position of the railroad switch (to prevent double direction changes) + sound_handler = nil, -- soundhandler +} + +-- Returns the current speed of the cart +function cart:get_speed() + if self.dir == "x+" then + return self.object:getvelocity().x + elseif self.dir == "x-" then + return -1*self.object:getvelocity().x + elseif self.dir == "z+" then + return self.object:getvelocity().z + elseif self.dir == "z-" then + return -1*self.object:getvelocity().z + end + return 0 +end + +-- Sets the current speed of the cart +function cart:set_speed(speed) + local newsp = {x=0, y=0, z=0} + if self.dir == "x+" then + newsp.x = speed + elseif self.dir == "x-" then + newsp.x = -1*speed + elseif self.dir == "z+" then + newsp.z = speed + elseif self.dir == "z-" then + newsp.z = -1*speed + end + self.object:setvelocity(newsp) +end + +-- Sets the acceleration of the cart +function cart:set_acceleration(staerke) + if self.dir == "x+" then + self.object:setacceleration({x=staerke, y=-10, z=0}) + elseif self.dir == "x-" then + self.object:setacceleration({x=-staerke, y=-10, z=0}) + elseif self.dir == "z+" then + self.object:setacceleration({x=0, y=-10, z=staerke}) + elseif self.dir == "z-" then + self.object:setacceleration({x=0, y=-10, z=-staerke}) + end +end + +-- Stops the cart +function cart:stop() + self.fahren = false + self.bremsen = false + self.items = {} + self.fallen = false + self.object:setacceleration({x = 0, y = -10, z = 0}) + self:set_speed(0) + -- stop sound + self:sound("stop") +end + +function cart:sound(arg) + if arg == "stop" then + if self.sound_handler ~= nil then + minetest.sound_stop(self.sound_handler) + self.sound_handler = nil + end + elseif arg == "continue" then + if self.sound_handler == nil then + return + end + minetest.sound_stop(self.sound_handler) + local sound = SOUND_FILES[math.random(1, #SOUND_FILES)] + self.sound_handler = minetest.sound_play(sound[1], { + object = self.object, + gain = SOUND_GAIN, + }) + minetest.after(sound[2], function() + self:sound("continue") + end) + elseif arg == "start" then + local sound = SOUND_FILES[math.random(1, #SOUND_FILES)] + self.sound_handler = minetest.sound_play(sound[1], { + object = self.object, + gain = SOUND_GAIN, + }) + minetest.after(sound[2], function() + self:sound("continue") + end) + end +end + +-- Returns the direction the cart has to drive +function cart:get_new_direction(pos) + if pos == nil then + pos = self.object:getpos() + end + if self.dir == nil then + return nil + end + pos.x = math.floor(0.5+pos.x) + pos.y = math.floor(0.5+pos.y) + pos.z = math.floor(0.5+pos.z) + if self.fallen then + for i,rail in ipairs(RAILS) do + if minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == rail then + return "y-" + end + end + end + if self.dir == "x+" then + pos.x = pos.x+1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + pos.x = pos.x-1 + local meta = minetest.env:get_meta(pos) + if meta:get_string("rail_direction") == "right" and not pos_equals(pos, self.weiche) then + pos.z = pos.z+1 + for i,rail1 in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail1 then + self.weiche = {x=pos.x, y=pos.y, z=pos.z-1} + return "z+" + end + end + pos.z = pos.z-1 + elseif meta:get_string("rail_direction") == "left" and not pos_equals(pos, self.weiche) then + pos.z = pos.z-1 + for i,rail1 in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail1 then + self.weiche = {x=pos.x, y=pos.y, z=pos.z+1} + return "z-" + end + end + pos.z = pos.z+1 + end + + return "x+" + end + end + pos.y = pos.y-1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "y-" + end + end + pos.y = pos.y+2 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "y+" + end + end + pos.y = pos.y-1 + pos.x = pos.x-1 + + local tmp = minetest.env:get_meta(pos):get_string("rail_direction") + if tmp == "left" then + pos.z = pos.z+1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "z+" + end + end + pos.z = pos.z-1 + elseif tmp == "right" then + pos.z = pos.z-1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "z-" + end + end + pos.z = pos.z+1 + end + + pos.z = pos.z-1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "z-" + end + end + pos.z = pos.z+2 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "z+" + end + end + pos.z = pos.z-1 + elseif self.dir == "x-" then + pos.x = pos.x-1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + pos.x = pos.x+1 + local meta = minetest.env:get_meta(pos) + if meta:get_string("rail_direction") == "left" and not pos_equals(pos, self.weiche) then + pos.z = pos.z+1 + for i,rail1 in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail1 then + self.weiche = {x=pos.x, y=pos.y, z=pos.z-1} + return "z+" + end + end + pos.z = pos.z-1 + elseif meta:get_string("rail_direction") == "right" and not pos_equals(pos, self.weiche) then + pos.z = pos.z-1 + for i,rail1 in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail1 then + self.weiche = {x=pos.x, y=pos.y, z=pos.z+1} + return "z-" + end + end + pos.z = pos.z+1 + end + + return "x-" + end + end + pos.y = pos.y-1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "y-" + end + end + pos.y = pos.y+2 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "y+" + end + end + pos.y = pos.y-1 + pos.x = pos.x+1 + + local tmp = minetest.env:get_meta(pos):get_string("rail_direction") + if tmp == "left" then + pos.z = pos.z-1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "z-" + end + end + pos.z = pos.z+1 + elseif tmp == "right" then + pos.z = pos.z+1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "z+" + end + end + pos.z = pos.z-1 + end + + pos.z = pos.z+1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "z+" + end + end + pos.z = pos.z-2 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "z-" + end + end + pos.z = pos.z+1 + elseif self.dir == "z+" then + pos.z = pos.z+1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + pos.z = pos.z-1 + local meta = minetest.env:get_meta(pos) + if meta:get_string("rail_direction") == "left" and not pos_equals(pos, self.weiche) then + pos.x = pos.x+1 + for i,rail1 in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail1 then + self.weiche = {x=pos.x-1, y=pos.y, z=pos.z} + return "x+" + end + end + pos.x = pos.x-1 + elseif meta:get_string("rail_direction") == "right" and not pos_equals(pos, self.weiche) then + pos.x = pos.x-1 + for i,rail1 in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail1 then + self.weiche = {x=pos.x+1, y=pos.y, z=pos.z} + return "x-" + end + end + pos.x = pos.x+1 + end + + return "z+" + end + end + pos.y = pos.y-1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "y-" + end + end + pos.y = pos.y+2 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "y+" + end + end + pos.y = pos.y-1 + pos.z = pos.z-1 + + local tmp = minetest.env:get_meta(pos):get_string("rail_direction") + if tmp == "left" then + pos.x = pos.x-1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "x-" + end + end + pos.x = pos.x+1 + elseif tmp == "right" then + pos.x = pos.x+1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "x+" + end + end + pos.x = pos.x-1 + end + + pos.x = pos.x+1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "x+" + end + end + pos.x = pos.x-2 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "x-" + end + end + pos.x = pos.x+1 + elseif self.dir == "z-" then + pos.z = pos.z-1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + pos.z = pos.z+1 + local meta = minetest.env:get_meta(pos) + if meta:get_string("rail_direction") == "right" and not pos_equals(pos, self.weiche) then + pos.x = pos.x+1 + for i,rail1 in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail1 then + self.weiche = {x=pos.x-1, y=pos.y, z=pos.z} + return "x+" + end + end + pos.x = pos.x-1 + elseif meta:get_string("rail_direction") == "left" and not pos_equals(pos, self.weiche) then + pos.x = pos.x-1 + for i,rail1 in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail1 then + self.weiche = {x=pos.x+1, y=pos.y, z=pos.z} + return "x-" + end + end + pos.x = pos.x+1 + end + + return "z-" + end + end + pos.y = pos.y-1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "y-" + end + end + pos.y = pos.y+2 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "y+" + end + end + pos.y = pos.y-1 + pos.z = pos.z+1 + + local tmp = minetest.env:get_meta(pos):get_string("rail_direction") + if tmp == "left" then + pos.x = pos.x+1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "x+" + end + end + pos.x = pos.x-1 + elseif tmp == "right" then + pos.x = pos.x-1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "x-" + end + end + pos.x = pos.x+1 + end + + pos.x = pos.x-1 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "x-" + end + end + pos.x = pos.x+2 + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + return "x+" + end + end + pos.x = pos.x-1 + end + return nil +end + +-- This method does several things. +function cart:on_step(dtime) + -- if the cart dont drives set gravity and return + if not self.fahren then + self.object:setacceleration({x=0, y=-10, z=0}) + return + end + + local newdir = self:get_new_direction() + if newdir == nil and not self.fallen then + -- end of rail + -- chek if the cart derailed + local pos = self.object:getpos() + if self.dir == "x+" then + pos.x = pos.x-1 + elseif self.dir == "x-" then + pos.x = pos.x+1 + elseif self.dir == "z+" then + pos.z = pos.z-1 + elseif self.dir == "z-" then + pos.z = pos.z+1 + end + local checkdir = self:get_new_direction(pos) + if checkdir ~= self.dir and checkdir ~= nil then + self.object:setpos(pos) + self.dir = checkdir + self.old_dir = checkdir + -- change direction + local speed = self:get_speed() + self:set_speed(speed) + else + -- stop + self:stop() + local pos = self.object:getpos() + pos.x = math.floor(0.5+pos.x) + pos.z = math.floor(0.5+pos.z) + self.object:setpos(pos) + end + elseif newdir == "y+" then + -- uphill + self.fallen = false + local vel = self.object:getvelocity() + vel.y = MAX_SPEED + self.object:setvelocity(vel) + elseif newdir == "y-" then + -- downhill + local vel = self.object:getvelocity() + vel.y = -2*MAX_SPEED + self.object:setvelocity(vel) + self.fallen = true + elseif newdir ~= self.dir then + -- curve + self.fallen = false + local pos = self.object:getpos() + -- wait until the cart is nearly on the cornernode + if equals(pos.x, math.floor(0.5+pos.x)) and equals(pos.y, math.floor(0.5+pos.y)) and equals(pos.z, math.floor(0.5+pos.z)) then + -- "jump" exacly on the cornernode + pos.x = math.floor(0.5+pos.x) + pos.z = math.floor(0.5+pos.z) + self.object:setpos(pos) + -- change direction + local speed = self:get_speed() + self.dir = newdir + self.old_dir = newdir + self:set_speed(speed) + end + end + + -- control speed and acceleration + if self.bremsen then + if not equals(self:get_speed(), 0) then + -- if the cart is still driving -> brake + self:set_acceleration(-10) + else + -- if the cart stand still -> stop + self:stop() + end + else + if self.fahren and self:get_speed() < MAX_SPEED then + -- if the cart is too slow -> accelerate + self:set_acceleration(10) + else + self:set_acceleration(0) + end + end + + -- move items + for i,item in ipairs(self.items) do + if item:is_player() then + -- if the item is a player move him 0.5 blocks lowlier + local pos = self.object:getpos() + pos.y = pos.y-0.5 + item:setpos(pos) + else + item:setpos(self.object:getpos()) + end + end + + -- if the cart isnt on a railroad switch reset the variable + local pos_tmp = self.object:getpos() + pos_tmp.x = math.floor(0.5+pos_tmp.x) + pos_tmp.y = math.floor(0.5+pos_tmp.y) + pos_tmp.z = math.floor(0.5+pos_tmp.z) + if not pos_equals(pos_tmp, self.weiche) then + self.weiche = {x=nil, y=nil, z=nil} + end + + -- search for chests + for d=-1,1 do + local pos = {x=self.object:getpos().x+d, y=self.object:getpos().y, z=self.object:getpos().z} + local name1 = minetest.env:get_node(pos).name + pos = {x=self.object:getpos().x, y=self.object:getpos().y, z=self.object:getpos().z+d} + local name2 = minetest.env:get_node(pos).name + if name1 == "carts:chest" then + pos = {x=self.object:getpos().x+d, y=self.object:getpos().y, z=self.object:getpos().z} + elseif name2 == "carts:chest" then + pos = {x=self.object:getpos().x, y=self.object:getpos().y, z=self.object:getpos().z+d} + else + name1 = nil + end + if name1 ~= nil then + pos.x = math.floor(0.5+pos.x) + pos.y = math.floor(0.5+pos.y) + pos.z = math.floor(0.5+pos.z) + local inv = minetest.env:get_meta(pos):get_inventory() + -- drop items + local items_tmp = {} + local inv = minetest.env:get_meta(pos):get_inventory() + for i,item in ipairs(self.items) do + if not item:is_player() and item:get_luaentity().itemstring ~= nil and item:get_luaentity().itemstring ~= "" and inv:room_for_item("in", ItemStack(item:get_luaentity().itemstring)) then + if item:get_luaentity().pickup == nil or not pos_equals(pos, item:get_luaentity().pickup) then + inv:add_item("in", ItemStack(item:get_luaentity().itemstring)) + item:remove() + else + table.insert(items_tmp, item) + end + else + table.insert(items_tmp, item) + end + end + self.items = items_tmp + + --pick up items + for i=1,inv:get_size("out") do + local stack = inv:get_stack("out", i) + if not stack:is_empty() then + local item = minetest.env:add_entity(self.object:getpos(), "__builtin:item") + item:get_luaentity():set_item(stack:get_name().." "..stack:get_count()) + item:get_luaentity().pickup = pos + table.insert(self.items, item) + inv:remove_item("out", stack) + end + end + end + end + + -- mesecons functions + if minetest.get_modpath("mesecons") ~= nil then + local pos = self.object:getpos() + pos.x = math.floor(0.5+pos.x) + pos.y = math.floor(0.5+pos.y) + pos.z = math.floor(0.5+pos.z) + local name = minetest.env:get_node(pos).name + if name == "carts:meseconrail_off" then + minetest.env:set_node(pos, {name="carts:meseconrail_on"}) + if mesecon ~= nil then + mesecon:receptor_on(pos) + end + end + + if name == "carts:meseconrail_stop_on" then + self:stop() + local pos = self.object:getpos() + pos.x = math.floor(0.5+pos.x) + pos.z = math.floor(0.5+pos.z) + self.object:setpos(pos) + end + end +end + +-- rightclick starts/stops the cart +function cart:on_rightclick(clicker) + if self.fahren then + self.bremsen = true + else + -- find out the direction + local pos_cart = self.object:getpos() + local pos_player = clicker:getpos() + local res = {x=pos_cart.x-pos_player.x, z=pos_cart.z-pos_player.z} + if math.abs(res.x) > math.abs(res.z) then + if res.x < 0 then + self.dir = "x-" + self.old_dir = "x-" + if self:get_new_direction() ~= "x-" then + if res.z < 0 then + self.dir = "z-" + self.old_dir = "z-" + else + self.dir = "z+" + self.old_dir = "z+" + end + if self:get_new_direction() ~= self.dir then + self.dir = "x-" + self.old_dir = "x-" + end + end + else + self.dir = "x+" + self.old_dir = "x+" + if self:get_new_direction() ~= "x+" then + if res.z < 0 then + self.dir = "z-" + self.old_dir = "z-" + else + self.dir = "z+" + self.old_dir = "z+" + end + if self:get_new_direction() ~= self.dir then + self.dir = "x+" + self.old_dir = "x+" + end + end + end + else + if res.z < 0 then + self.dir = "z-" + self.old_dir = "z-" + if self:get_new_direction() ~= "z-" then + if res.x < 0 then + self.dir = "x-" + self.old_dir = "x-" + else + self.dir = "x+" + self.old_dir = "x+" + end + if self:get_new_direction() ~= self.dir then + self.dir = "z-" + self.old_dir = "z-" + end + end + else + self.dir = "z+" + self.old_dir = "z+" + if self:get_new_direction() ~= "z+" then + if res.x < 0 then + self.dir = "x-" + self.old_dir = "x-" + else + self.dir = "x+" + self.old_dir = "x+" + end + if self:get_new_direction() ~= self.dir then + self.dir = "z+" + self.old_dir = "z+" + end + end + end + end + + -- detect items + local tmp = minetest.env:get_objects_inside_radius(self.object:getpos(), 1) + for i,item in ipairs(tmp) do + if not item:is_player() and item:get_luaentity().name ~= "carts:cart" then + table.insert(self.items, item) + elseif item:is_player() and TRANSPORT_PLAYER then + table.insert(self.items, item) + end + end + + -- start sound + self:sound("start") + + self.fahren = true + end +end + +-- remove the cart and place it in the inventory +function cart:on_punch(hitter) + -- stop sound + self:sound("stop") + self.object:remove() + hitter:get_inventory():add_item("main", "carts:cart") +end + +-- save the probprties of the cart if unloaded +function cart:get_staticdata() + local str = tostring(self.fahren) + str = str.."," + if self.fahren then + str = str..self.dir + end + self.object:setvelocity({x=0, y=0, z=0}) + return str +end + +-- set gravity +function cart:on_activate(staticdata) + self.object:setacceleration({x = 0, y = -10, z = 0}) + self.items = {} + if staticdata ~= nil then + -- if the cart was unloaded + if string.find(staticdata, ",") ~= nil then + -- restore the probprties + if string.sub(staticdata, 1, string.find(staticdata, ",")-1)=="true" then + self.dir = string.sub(staticdata, string.find(staticdata, ",")+1) + self.old_dir = dir + self.fahren = true + end + end + end +end + +minetest.register_entity("carts:cart", cart) + +-- inventoryitem +minetest.register_craftitem("carts:cart", { + description = "Cart", + image = minetest.inventorycube("carts_cart_top.png", "carts_cart_side.png", "carts_cart_side.png"), + wield_image = "carts_cart_top.png", + stack_max = 1, + -- replace it with the object + on_place = function(itemstack, placer, pointed) + local pos = pointed.under + local bool = false + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + bool = true + end + end + if not bool then + pos = pointed.above + end + pos = {x = math.floor(0.5+pos.x), y = math.floor(0.5+pos.y), z = math.floor(0.5+pos.z)} + minetest.env:add_entity(pos, "carts:cart") + itemstack:take_item(1) + return itemstack + end, +}) + +minetest.register_craft({ + output = '"carts:cart" 1', + recipe = { + {'default:steel_ingot', '', 'default:steel_ingot'}, + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'} + } +}) + +dofile(minetest.get_modpath("carts").."/switches.lua") +dofile(minetest.get_modpath("carts").."/mesecons.lua") +dofile(minetest.get_modpath("carts").."/chest.lua") +dofile(minetest.get_modpath("carts").."/functions.lua") diff --git a/games/minitest/mods/carts/mesecons.lua b/games/minitest/mods/carts/mesecons.lua new file mode 100644 index 0000000..b4863f3 --- /dev/null +++ b/games/minitest/mods/carts/mesecons.lua @@ -0,0 +1,248 @@ +if minetest.get_modpath("mesecons") ~= nil then + minetest.after(0, function() + mesecon:register_on_signal_on(function(pos, node) + for i,rail in ipairs(RAILS) do + if node.name == rail then + local carts = minetest.env:get_objects_inside_radius(pos, 1) + for i,cart in ipairs(carts) do + if not cart:is_player() and cart:get_luaentity().name == "carts:cart" and not cart:get_luaentity().fahren then + local self = cart:get_luaentity() + -- find out the direction + local dir_table + if self.old_dir ~= nil then + dir_table = {self.old_dir, "x+", "x-", "z+", "z-"} + else + dir_table = {"x+", "x-", "z+", "z-"} + end + for i,dir in ipairs(dir_table) do + self.dir = dir + if self:get_new_direction() == self.dir then + break + end + end + -- detect items + local tmp = minetest.env:get_objects_inside_radius(self.object:getpos(), 1) + for i,item in ipairs(tmp) do + if not item:is_player() and item:get_luaentity().name ~= "carts:cart" then + table.insert(self.items, item) + elseif item:is_player() and TRANSPORT_PLAYER then + table.insert(self.items, item) + end + end + + -- start sound + self:sound("start") + + self.fahren = true + end + end + end + end + if node.name == "carts:switch_left" then + node.name = "carts:switch_right" + minetest.env:set_node(pos, node) + local par2 = minetest.env:get_node(pos).param2 + if par2 == 0 then + pos.z = pos.z-1 + elseif par2 == 1 then + pos.x = pos.x-1 + elseif par2 == 2 then + pos.z = pos.z+1 + elseif par2 == 3 then + pos.x = pos.x+1 + end + + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + local meta = minetest.env:get_meta(pos) + meta:set_string("rail_direction", "right") + end + end + elseif node.name == "carts:switch_right" then + node.name = "carts:switch_left" + minetest.env:set_node(pos, node) + local par2 = minetest.env:get_node(pos).param2 + if par2 == 0 then + pos.z = pos.z-1 + elseif par2 == 1 then + pos.x = pos.x-1 + elseif par2 == 2 then + pos.z = pos.z+1 + elseif par2 == 3 then + pos.x = pos.x+1 + end + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + local meta = minetest.env:get_meta(pos) + meta:set_string("rail_direction", "left") + end + end + end + + if node.name == "carts:meseconrail_stop_off" then + node.name = "carts:meseconrail_stop_on" + minetest.env:set_node(pos, node) + end + end) + + mesecon:register_on_signal_off(function(pos, node) + if node.name == "carts:meseconrail_stop_on" then + node.name = "carts:meseconrail_stop_off" + minetest.env:set_node(pos, node) + local carts = minetest.env:get_objects_inside_radius(pos, 1) + for i,cart in ipairs(carts) do + if not cart:is_player() and cart:get_luaentity().name == "carts:cart" and not cart:get_luaentity().fahren then + local self = cart:get_luaentity() + -- find out the direction + if self.old_dir ~= nil then + self.dir = self.old_dir + else + for i,dir in ipairs({"x+", "x-", "z+", "z-"}) do + self.dir = dir + if self:get_new_direction() == self.dir then + break + end + end + end + -- detect items + local tmp = minetest.env:get_objects_inside_radius(self.object:getpos(), 1) + for i,item in ipairs(tmp) do + if not item:is_player() and item:get_luaentity().name ~= "carts:cart" then + table.insert(self.items, item) + elseif item:is_player() and TRANSPORT_PLAYER then + table.insert(self.items, item) + end + end + + -- start sound + self:sound("start") + + self.fahren = true + end + end + end + end) + end) + + minetest.register_node("carts:meseconrail_off", { + description = "Meseconrail", + drawtype = "raillike", + tiles = {"carts_meseconrail_off.png", "carts_meseconrail_curved_off.png", "carts_meseconrail_t_junction_off.png", "carts_meseconrail_crossing_off.png",}, + inventory_image = "carts_meseconrail_off.png", + wield_image = "carts_meseconrail_off.png", + paramtype = "light", + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2}, + }, + groups = {bendy=2,snappy=1,dig_immediate=2}, + }) + + minetest.register_node("carts:meseconrail_on", { + drawtype = "raillike", + tiles = {"carts_meseconrail_on.png", "carts_meseconrail_curved_on.png", "carts_meseconrail_t_junction_on.png", "carts_meseconrail_crossing_on.png",}, + paramtype = "light", + light_source = LIGHT_MAX-11, + drop = "carts:meseconrail_off", + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2}, + }, + groups = {bendy=2, snappy=1, dig_immediate=2, not_in_creative_inventory=1}, + after_destruct = function(pos, oldnode) + if mesecon ~= nil then + mesecon:receptor_off(pos) + end + end, + }) + + minetest.register_alias("carts:meseconrail", "carts:meseconrail_off") + + minetest.after(0, function() + mesecon:add_receptor_node("carts:meseconrail_on") + mesecon:add_receptor_node_off("carts:meseconrail_off") + end) + + minetest.register_abm({ + nodenames = {"carts:meseconrail_on"}, + interval = 1.0, + chance = 1, + action = function(pos, node) + local tmp = minetest.env:get_objects_inside_radius(pos, 1) + local cart_is_there = false + for i,cart in ipairs(tmp) do + if not cart:is_player() and cart:get_luaentity().name == "carts:cart" then + cart_is_there = true + end + end + if not cart_is_there then + minetest.env:set_node(pos, {name="carts:meseconrail_off"}) + if mesecon ~= nil then + mesecon:receptor_off(pos) + end + end + end + }) + + minetest.register_craft({ + output = '"carts:meseconrail_off" 1', + recipe = { + {'default:rail', 'mesecons:mesecon_off', 'default:rail'}, + {'default:rail', 'mesecons:mesecon_off', 'default:rail'}, + {'default:rail', 'mesecons:mesecon_off', 'default:rail'}, + } + }) + + minetest.register_node("carts:meseconrail_stop_off", { + description = "Meseconrail stop", + drawtype = "raillike", + tiles = {"carts_meseconrail_stop_off.png", "carts_meseconrail_stop_curved_off.png", "carts_meseconrail_stop_t_junction_off.png", "carts_meseconrail_stop_crossing_off.png",}, + inventory_image = "carts_meseconrail_stop_off.png", + wield_image = "carts_meseconrail_stop_off.png", + paramtype = "light", + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2}, + }, + groups = {bendy=2,snappy=1,dig_immediate=2}, + after_destruct = function(pos, oldnode) + if mesecon ~= nil then + mesecon:receptor_off(pos) + end + end, + }) + + minetest.register_node("carts:meseconrail_stop_on", { + drawtype = "raillike", + tiles = {"carts_meseconrail_stop_on.png", "carts_meseconrail_stop_curved_on.png", "carts_meseconrail_stop_t_junction_on.png", "carts_meseconrail_stop_crossing_on.png",}, + paramtype = "light", + light_source = LIGHT_MAX-11, + drop = "carts:meseconrail_stop_off", + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2}, + }, + groups = {bendy=2, snappy=1, dig_immediate=2, not_in_creative_inventory=1}, + after_destruct = function(pos, oldnode) + if mesecon ~= nil then + mesecon:receptor_off(pos) + end + end, + }) + + minetest.register_alias("carts:meseconrail_stop", "carts:meseconrail_stop_off") + + minetest.register_craft({ + output = '"carts:meseconrail_stop_off" 1', + recipe = { + {'default:rail', 'mesecons:mesecon_off', 'default:rail'}, + {'default:rail', '', 'default:rail'}, + {'default:rail', 'mesecons:mesecon_off', 'default:rail'}, + } + }) + +end diff --git a/games/minitest/mods/carts/sounds/carts_curved_rails.ogg b/games/minitest/mods/carts/sounds/carts_curved_rails.ogg new file mode 100644 index 0000000..bee25fc Binary files /dev/null and b/games/minitest/mods/carts/sounds/carts_curved_rails.ogg differ diff --git a/games/minitest/mods/carts/sounds/carts_railway_crossover.ogg b/games/minitest/mods/carts/sounds/carts_railway_crossover.ogg new file mode 100644 index 0000000..7eb7019 Binary files /dev/null and b/games/minitest/mods/carts/sounds/carts_railway_crossover.ogg differ diff --git a/games/minitest/mods/carts/sounds/carts_straight_rails.ogg b/games/minitest/mods/carts/sounds/carts_straight_rails.ogg new file mode 100644 index 0000000..8b8d6ab Binary files /dev/null and b/games/minitest/mods/carts/sounds/carts_straight_rails.ogg differ diff --git a/games/minitest/mods/carts/switches.lua b/games/minitest/mods/carts/switches.lua new file mode 100644 index 0000000..f509a0d --- /dev/null +++ b/games/minitest/mods/carts/switches.lua @@ -0,0 +1,235 @@ +minetest.register_node("carts:switch_left", { + paramtype2 = "facedir", + tiles = {"default_wood.png"}, + drop = "carts:switch_middle", + groups = {bendy=2, snappy=1, dig_immediate=2, not_in_creative_inventory=1}, + on_punch = function(pos, node, puncher) + node.name = "carts:switch_middle" + minetest.env:set_node(pos, node) + local par2 = minetest.env:get_node(pos).param2 + if par2 == 0 then + pos.z = pos.z-1 + elseif par2 == 1 then + pos.x = pos.x-1 + elseif par2 == 2 then + pos.z = pos.z+1 + elseif par2 == 3 then + pos.x = pos.x+1 + end + + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + local meta = minetest.env:get_meta(pos) + meta:set_string("rail_direction", "") + end + end + end, + on_destruct = function(pos) + local par2 = minetest.env:get_node(pos).param2 + if par2 == 0 then + pos.z = pos.z-1 + elseif par2 == 1 then + pos.x = pos.x-1 + elseif par2 == 2 then + pos.z = pos.z+1 + elseif par2 == 3 then + pos.x = pos.x+1 + end + + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + local meta = minetest.env:get_meta(pos) + meta:set_string("rail_direction", "") + end + end + end, + + drawtype = "nodebox", + paramtype = "light", + node_box = { + type = "fixed", + fixed = { + -- shaft + {-0.05, -0.5, -0.45, 0.05, -0.4, -0.4}, + {-0.1, -0.4, -0.45, 0, -0.3, -0.4}, + {-0.15, -0.3, -0.45, -0.05, -0.2, -0.4}, + {-0.2, -0.2, -0.45, -0.1, -0.1, -0.4}, + {-0.25, -0.1, -0.45, -0.15, 0, -0.4}, + {-0.3, 0, -0.45, -0.2, 0.1, -0.4}, + -- head + {-0.45, 0.1, -0.5, -0.25, 0.3, -0.35}, + }, + }, + selection_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.35, -0.35}, + } + }, + walkable = false, +}) + +minetest.register_node("carts:switch_middle", { + description = "Switch", + paramtype2 = "facedir", + tiles = {"default_wood.png"}, + groups = {bendy=2, snappy=1, dig_immediate=2}, + on_punch = function(pos, node, puncher) + node.name = "carts:switch_right" + minetest.env:set_node(pos, node) + local par2 = minetest.env:get_node(pos).param2 + if par2 == 0 then + pos.z = pos.z-1 + elseif par2 == 1 then + pos.x = pos.x-1 + elseif par2 == 2 then + pos.z = pos.z+1 + elseif par2 == 3 then + pos.x = pos.x+1 + end + + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + local meta = minetest.env:get_meta(pos) + meta:set_string("rail_direction", "right") + end + end + end, + on_construct = function(pos) + local par2 = minetest.env:get_node(pos).param2 + if par2 == 0 then + pos.z = pos.z-1 + elseif par2 == 1 then + pos.x = pos.x-1 + elseif par2 == 2 then + pos.z = pos.z+1 + elseif par2 == 3 then + pos.x = pos.x+1 + end + + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + local meta = minetest.env:get_meta(pos) + meta:set_string("rail_direction", "") + end + end + end, + on_destruct = function(pos) + local par2 = minetest.env:get_node(pos).param2 + if par2 == 0 then + pos.z = pos.z-1 + elseif par2 == 1 then + pos.x = pos.x-1 + elseif par2 == 2 then + pos.z = pos.z+1 + elseif par2 == 3 then + pos.x = pos.x+1 + end + + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + local meta = minetest.env:get_meta(pos) + meta:set_string("rail_direction", "") + end + end + end, + + drawtype = "nodebox", + paramtype = "light", + node_box = { + type = "fixed", + fixed = { + -- shaft + {-0.05, -0.5, -0.45, 0.05, 0.15, -0.4}, + -- head + {-0.1, 0.15, -0.5, 0.1, 0.35, -0.35}, + }, + }, + selection_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.35, -0.35}, + } + }, + walkable = false, +}) + +minetest.register_node("carts:switch_right", { + paramtype2 = "facedir", + tiles = {"default_wood.png"}, + groups = {bendy=2,snappy=1, dig_immediate=2, not_in_creative_inventory=1}, + drop = "carts:switch_middle", + on_punch = function(pos, node, puncher) + node.name = "carts:switch_left" + minetest.env:set_node(pos, node) + local par2 = minetest.env:get_node(pos).param2 + if par2 == 0 then + pos.z = pos.z-1 + elseif par2 == 1 then + pos.x = pos.x-1 + elseif par2 == 2 then + pos.z = pos.z+1 + elseif par2 == 3 then + pos.x = pos.x+1 + end + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + local meta = minetest.env:get_meta(pos) + meta:set_string("rail_direction", "left") + end + end + end, + on_destruct = function(pos) + local par2 = minetest.env:get_node(pos).param2 + if par2 == 0 then + pos.z = pos.z-1 + elseif par2 == 1 then + pos.x = pos.x-1 + elseif par2 == 2 then + pos.z = pos.z+1 + elseif par2 == 3 then + pos.x = pos.x+1 + end + for i,rail in ipairs(RAILS) do + if minetest.env:get_node(pos).name == rail then + local meta = minetest.env:get_meta(pos) + meta:set_string("rail_direction", "") + end + end + end, + + drawtype = "nodebox", + paramtype = "light", + node_box = { + type = "fixed", + fixed = { + -- shaft + {-0.05, -0.5, -0.45, 0.05, -0.4, -0.4}, + {0, -0.4, -0.45, 0.1, -0.3, -0.4}, + {0.05, -0.3, -0.45, 0.15, -0.2, -0.4}, + {0.1, -0.2, -0.45, 0.2, -0.1, -0.4}, + {0.15, -0.1, -0.45, 0.25, 0, -0.4}, + {0.2, 0, -0.45, 0.3, 0.1, -0.4}, + -- head + {0.25, 0.1, -0.5, 0.45, 0.3, -0.35}, + }, + }, + selection_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.35, -0.35}, + } + }, + walkable = false, +}) + +minetest.register_alias("carts:switch", "carts:switch_middle") + +minetest.register_craft({ + output = '"carts:switch_middle" 1', + recipe = { + {'', 'default:rail', ''}, + {'default:rail', '', ''}, + {'', 'default:rail', ''}, + } +}) diff --git a/games/minitest/mods/carts/textures/carts_cart_bottom.png b/games/minitest/mods/carts/textures/carts_cart_bottom.png new file mode 100644 index 0000000..f84b1ae Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_cart_bottom.png differ diff --git a/games/minitest/mods/carts/textures/carts_cart_side.png b/games/minitest/mods/carts/textures/carts_cart_side.png new file mode 100644 index 0000000..79f6c32 Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_cart_side.png differ diff --git a/games/minitest/mods/carts/textures/carts_cart_top.png b/games/minitest/mods/carts/textures/carts_cart_top.png new file mode 100644 index 0000000..fbd9e1f Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_cart_top.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_crossing_off.png b/games/minitest/mods/carts/textures/carts_meseconrail_crossing_off.png new file mode 100644 index 0000000..74bb900 Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_crossing_off.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_crossing_on.png b/games/minitest/mods/carts/textures/carts_meseconrail_crossing_on.png new file mode 100644 index 0000000..ced5344 Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_crossing_on.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_curved_off.png b/games/minitest/mods/carts/textures/carts_meseconrail_curved_off.png new file mode 100644 index 0000000..e7afbb9 Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_curved_off.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_curved_on.png b/games/minitest/mods/carts/textures/carts_meseconrail_curved_on.png new file mode 100644 index 0000000..e606b3d Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_curved_on.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_off.png b/games/minitest/mods/carts/textures/carts_meseconrail_off.png new file mode 100644 index 0000000..543a829 Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_off.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_on.png b/games/minitest/mods/carts/textures/carts_meseconrail_on.png new file mode 100644 index 0000000..977c76f Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_on.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_stop_crossing_off.png b/games/minitest/mods/carts/textures/carts_meseconrail_stop_crossing_off.png new file mode 100644 index 0000000..98d4507 Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_stop_crossing_off.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_stop_crossing_on.png b/games/minitest/mods/carts/textures/carts_meseconrail_stop_crossing_on.png new file mode 100644 index 0000000..af44782 Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_stop_crossing_on.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_stop_curved_off.png b/games/minitest/mods/carts/textures/carts_meseconrail_stop_curved_off.png new file mode 100644 index 0000000..c09e72a Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_stop_curved_off.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_stop_curved_on.png b/games/minitest/mods/carts/textures/carts_meseconrail_stop_curved_on.png new file mode 100644 index 0000000..8eadf59 Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_stop_curved_on.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_stop_off.png b/games/minitest/mods/carts/textures/carts_meseconrail_stop_off.png new file mode 100644 index 0000000..054030e Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_stop_off.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_stop_on.png b/games/minitest/mods/carts/textures/carts_meseconrail_stop_on.png new file mode 100644 index 0000000..17efb06 Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_stop_on.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_stop_t_junction_off.png b/games/minitest/mods/carts/textures/carts_meseconrail_stop_t_junction_off.png new file mode 100644 index 0000000..1c85ec2 Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_stop_t_junction_off.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_stop_t_junction_on.png b/games/minitest/mods/carts/textures/carts_meseconrail_stop_t_junction_on.png new file mode 100644 index 0000000..f75a815 Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_stop_t_junction_on.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_t_junction_off.png b/games/minitest/mods/carts/textures/carts_meseconrail_t_junction_off.png new file mode 100644 index 0000000..0e1e72c Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_t_junction_off.png differ diff --git a/games/minitest/mods/carts/textures/carts_meseconrail_t_junction_on.png b/games/minitest/mods/carts/textures/carts_meseconrail_t_junction_on.png new file mode 100644 index 0000000..3a8d03f Binary files /dev/null and b/games/minitest/mods/carts/textures/carts_meseconrail_t_junction_on.png differ diff --git a/games/minitest/mods/creative_inventory/README.txt b/games/minitest/mods/creative_inventory/README.txt new file mode 100644 index 0000000..7d49b98 --- /dev/null +++ b/games/minitest/mods/creative_inventory/README.txt @@ -0,0 +1,22 @@ +Minetest 0.4 mod: creative +========================== + +Implements creative mode. + +Switch on by using the "creative_mode" setting. + +Registered items that +- have a description, and +- do not have the group not_in_creative_inventory +are added to the creative inventory. + +License of source code and media files: +--------------------------------------- +Copyright (C) 2012 Perttu Ahola (celeron55) + +This program is free software. It comes without any warranty, to +the extent permitted by applicable law. You can redistribute it +and/or modify it under the terms of the Do What The Fuck You Want +To Public License, Version 2, as published by Sam Hocevar. See +http://sam.zoy.org/wtfpl/COPYING for more details. + diff --git a/games/minitest/mods/creative_inventory/init.lua b/games/minitest/mods/creative_inventory/init.lua new file mode 100644 index 0000000..6106a7d --- /dev/null +++ b/games/minitest/mods/creative_inventory/init.lua @@ -0,0 +1,115 @@ +-- minetest/creative/init.lua + +local creative_inventory = {} + +-- Create detached creative inventory after loading all mods +minetest.after(0, function() + local inv = minetest.create_detached_inventory("creative", { + allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) + if minetest.setting_getbool("creative_mode") then + return count + else + return 0 + end + end, + allow_put = function(inv, listname, index, stack, player) + if minetest.setting_getbool("creative_mode") then + return -1 + else + return 0 + end + end, + allow_take = function(inv, listname, index, stack, player) + if minetest.setting_getbool("creative_mode") then + return -1 + else + return 0 + end + end, + on_move = function(inv, from_list, from_index, to_list, to_index, count, player) + end, + on_put = function(inv, listname, index, stack, player) + end, + on_take = function(inv, listname, index, stack, player) + print(player:get_player_name().." takes item from creative inventory; listname="..dump(listname)..", index="..dump(index)..", stack="..dump(stack)) + if stack then + print("stack:get_name()="..dump(stack:get_name())..", stack:get_count()="..dump(stack:get_count())) + end + end, + }) + local creative_list = {} + for name,def in pairs(minetest.registered_items) do + if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) + and def.description and def.description ~= "" then + table.insert(creative_list, name) + end + end + table.sort(creative_list) + inv:set_size("main", #creative_list) + for _,itemstring in ipairs(creative_list) do + local stack = ItemStack(itemstring) + -- Make a stack of the right number of items + local stack2 = nil + if stack:get_stack_max() == 1 then + stack2 = ItemStack(stack:get_name()) + else + -- Insert half full so that a taken stack can be put back + stack2 = ItemStack(stack:get_name().." "..(stack:get_stack_max()/2)) + end + inv:add_item("main", stack2) + end + creative_inventory.creative_inventory_size = #creative_list + print("creative inventory size: "..dump(creative_inventory.creative_inventory_size)) +end) + +creative_inventory.set_creative_formspec = function(player, start_i, pagenum) + pagenum = math.floor(pagenum) + local pagemax = math.floor((creative_inventory.creative_inventory_size-1) / (6*4) + 1) + player:set_inventory_formspec("size[13,7.5]".. + --"image[6,0.6;1,2;player.png]".. + "list[current_player;main;5,3.5;8,4;]".. + "list[current_player;craft;8,0;3,3;]".. + "list[current_player;craftpreview;12,1;1,1;]".. + "list[detached:creative;main;0.3,0.5;4,6;"..tostring(start_i).."]".. + "label[2.0,6.55;"..tostring(pagenum).."/"..tostring(pagemax).."]".. + "button[0.3,6.5;1.6,1;creative_prev;<<]".. + "button[2.7,6.5;1.6,1;creative_next;>>]") +end +minetest.register_on_joinplayer(function(player) + -- If in creative mode, modify player's inventory forms + if not minetest.setting_getbool("creative_mode") then + return + end + creative_inventory.set_creative_formspec(player, 0, 1) +end) +minetest.register_on_player_receive_fields(function(player, formname, fields) + if not minetest.setting_getbool("creative_mode") then + return + end + -- Figure out current page from formspec + local current_page = 0 + local formspec = player:get_inventory_formspec() + local start_i = string.match(formspec, "list%[detached:creative;main;[%d.]+,[%d.]+;[%d.]+,[%d.]+;(%d+)%]") + start_i = tonumber(start_i) or 0 + + if fields.creative_prev then + start_i = start_i - 4*6 + end + if fields.creative_next then + start_i = start_i + 4*6 + end + + if start_i < 0 then + start_i = start_i + 4*6 + end + if start_i >= creative_inventory.creative_inventory_size then + start_i = start_i - 4*6 + end + + if start_i < 0 or start_i >= creative_inventory.creative_inventory_size then + start_i = 0 + end + + creative_inventory.set_creative_formspec(player, start_i, start_i / (6*4) + 1) +end) + diff --git a/games/minitest/mods/death/init.lua b/games/minitest/mods/death/init.lua new file mode 100644 index 0000000..e16e820 --- /dev/null +++ b/games/minitest/mods/death/init.lua @@ -0,0 +1,15 @@ +minetest.register_on_dieplayer(function(player) + local inv = player:get_inventory() + local pos = player:getpos() + for i,stack in ipairs(inv:get_list("main")) do + local x = math.random(0, 9)/3 + local z = math.random(0, 9)/3 + pos.x = pos.x + x + pos.z = pos.z + z + minetest.env:add_item(pos, stack) + stack:clear() + inv:set_stack("main", i, stack) + pos.x = pos.x - x + pos.z = pos.z - z + end +end) diff --git a/games/minitest/mods/default/README.txt b/games/minitest/mods/default/README.txt new file mode 100644 index 0000000..22dc14d --- /dev/null +++ b/games/minitest/mods/default/README.txt @@ -0,0 +1,64 @@ +Minetest 0.4 mod: default +========================== + +License of source code: +----------------------- +Copyright (C) 2011-2012 celeron55, Perttu Ahola + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +http://www.gnu.org/licenses/lgpl-2.1.html + +License of media (textures and sounds) +-------------------------------------- +Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) +http://creativecommons.org/licenses/by-sa/3.0/ + +Authors of media files +----------------------- +Everything not listed in here: +Copyright (C) 2010-2012 celeron55, Perttu Ahola + +Originating from work by kddekadenz/Dogers: + default_grass_footstep.{1,2,3}.ogg + default_dig_crumbly.{1,2}.ogg + +Cisoun's WTFPL texture pack: + default_chest_front.png + default_chest_lock.png + default_chest_side.png + default_chest_top.png + default_cobble.png + default_dirt.png + default_grass.png + default_grass_side.png + default_jungletree.png + default_jungletree_top.png + default_lava.png + default_leaves.png + default_mossycobble.png + default_sand.png + default_sapling.png + default_sign_wall.png + default_stone.png + default_tool_mesepick.png + default_tool_steelpick.png + default_tool_steelshovel.png + default_tool_steelsword.png + default_tool_stonepick.png + default_tool_stoneshovel.png + default_tool_woodpick.png + default_tool_woodshovel.png + default_tree.png + default_tree_top.png + default_water.png + +Originating from G4JC's Almost MC Texture Pack: + default_wood.png + default_torch.png + default_torch_on_ceiling.png + default_torch_on_floor.png + diff --git a/games/minitest/mods/default/init.lua b/games/minitest/mods/default/init.lua new file mode 100644 index 0000000..0762c15 --- /dev/null +++ b/games/minitest/mods/default/init.lua @@ -0,0 +1,1756 @@ +-- Minetest 0.4 mod: default +-- See README.txt for licensing and other information. + +-- The API documentation in here was moved into doc/lua_api.txt + +WATER_ALPHA = 160 +WATER_VISC = 1 +LAVA_VISC = 7 +LIGHT_MAX = 14 + +-- Definitions made by this mod that other mods can use too +default = {} + +-- Load other files +dofile(minetest.get_modpath("default").."/mapgen.lua") +dofile(minetest.get_modpath("default").."/leafdecay.lua") + +-- +-- Tool definition +-- + +-- The hand +minetest.register_item(":", { + type = "none", + wield_image = "wieldhand.png", + wield_scale = {x=1,y=1,z=2.5}, + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level = 0, + groupcaps = { + fleshy = {times={[2]=2.00, [3]=1.00}, uses=0, maxlevel=1}, + crumbly = {times={[2]=3.00, [3]=0.70}, uses=0, maxlevel=1}, + snappy = {times={[3]=0.40}, uses=0, maxlevel=1}, + oddly_breakable_by_hand = {times={[1]=7.00,[2]=4.00,[3]=1.40}, uses=0, maxlevel=3}, + } + } +}) + +minetest.register_tool("default:pick_wood", { + description = "Wooden Pickaxe", + inventory_image = "default_tool_woodpick.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + cracky={times={[2]=2.00, [3]=1.20}, uses=10, maxlevel=1} + } + }, +}) +minetest.register_tool("default:pick_stone", { + description = "Stone Pickaxe", + inventory_image = "default_tool_stonepick.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + cracky={times={[1]=3.00, [2]=1.20, [3]=0.80}, uses=20, maxlevel=1} + } + }, +}) +minetest.register_tool("default:pick_steel", { + description = "Steel Pickaxe", + inventory_image = "default_tool_steelpick.png", + tool_capabilities = { + max_drop_level=1, + groupcaps={ + cracky={times={[1]=4.00, [2]=1.60, [3]=1.00}, uses=30, maxlevel=2} + } + }, +}) +minetest.register_tool("default:pick_mese", { + description = "Mese Pickaxe", + inventory_image = "default_tool_mesepick.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=3, + groupcaps={ + cracky={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, + crumbly={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, + snappy={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3} + } + }, +}) +minetest.register_tool("default:shovel_wood", { + description = "Wooden Shovel", + inventory_image = "default_tool_woodshovel.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + crumbly={times={[1]=3.00, [2]=0.80, [3]=0.50}, uses=10, maxlevel=1} + } + }, +}) +minetest.register_tool("default:shovel_stone", { + description = "Stone Shovel", + inventory_image = "default_tool_stoneshovel.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + crumbly={times={[1]=1.50, [2]=0.50, [3]=0.30}, uses=20, maxlevel=1} + } + }, +}) +minetest.register_tool("default:shovel_steel", { + description = "Steel Shovel", + inventory_image = "default_tool_steelshovel.png", + tool_capabilities = { + max_drop_level=1, + groupcaps={ + crumbly={times={[1]=1.50, [2]=0.70, [3]=0.60}, uses=30, maxlevel=2} + } + }, +}) +minetest.register_tool("default:axe_wood", { + description = "Wooden Axe", + inventory_image = "default_tool_woodaxe.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + choppy={times={[2]=1.40, [3]=0.80}, uses=10, maxlevel=1}, + fleshy={times={[2]=1.50, [3]=0.80}, uses=10, maxlevel=1} + } + }, +}) +minetest.register_tool("default:axe_stone", { + description = "Stone Axe", + inventory_image = "default_tool_stoneaxe.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + choppy={times={[1]=3.00, [2]=1.00, [3]=0.60}, uses=20, maxlevel=1}, + fleshy={times={[2]=1.30, [3]=0.70}, uses=20, maxlevel=1} + } + }, +}) +minetest.register_tool("default:axe_steel", { + description = "Steel Axe", + inventory_image = "default_tool_steelaxe.png", + tool_capabilities = { + max_drop_level=1, + groupcaps={ + choppy={times={[1]=3.00, [2]=1.60, [3]=1.00}, uses=30, maxlevel=2}, + fleshy={times={[2]=1.10, [3]=0.60}, uses=40, maxlevel=1} + } + }, +}) +minetest.register_tool("default:sword_wood", { + description = "Wooden Sword", + inventory_image = "default_tool_woodsword.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=0, + groupcaps={ + fleshy={times={[2]=1.10, [3]=0.60}, uses=10, maxlevel=1}, + snappy={times={[2]=1.00, [3]=0.50}, uses=10, maxlevel=1}, + choppy={times={[3]=1.00}, uses=20, maxlevel=0} + } + } +}) +minetest.register_tool("default:sword_stone", { + description = "Stone Sword", + inventory_image = "default_tool_stonesword.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=0, + groupcaps={ + fleshy={times={[2]=0.80, [3]=0.40}, uses=20, maxlevel=1}, + snappy={times={[2]=0.80, [3]=0.40}, uses=20, maxlevel=1}, + choppy={times={[3]=0.90}, uses=20, maxlevel=0} + } + } +}) +minetest.register_tool("default:sword_steel", { + description = "Steel Sword", + inventory_image = "default_tool_steelsword.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=1, + groupcaps={ + fleshy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=10, maxlevel=2}, + snappy={times={[2]=0.70, [3]=0.30}, uses=40, maxlevel=1}, + choppy={times={[3]=0.70}, uses=40, maxlevel=0} + } + } +}) + +-- +-- Crafting definition +-- + +minetest.register_craft({ + output = 'default:wood 4', + recipe = { + {'default:tree'}, + } +}) + +minetest.register_craft({ + output = 'default:stick 4', + recipe = { + {'default:wood'}, + {'default:wood'}, + } +}) + +minetest.register_craft({ + output = 'default:fence_wood 2', + recipe = { + {'default:stick', 'default:stick', 'default:stick'}, + {'default:stick', 'default:stick', 'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:sign_wall', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'default:wood', 'default:wood', 'default:wood'}, + {'', 'default:stick', ''}, + } +}) + +minetest.register_craft({ + output = 'default:torch 4', + recipe = { + {'default:coal_lump'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:pick_wood', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'', 'default:stick', ''}, + {'', 'default:stick', ''}, + } +}) + +minetest.register_craft({ + output = 'default:pick_stone', + recipe = { + {'default:cobble', 'default:cobble', 'default:cobble'}, + {'', 'default:stick', ''}, + {'', 'default:stick', ''}, + } +}) + +minetest.register_craft({ + output = 'default:pick_steel', + recipe = { + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + {'', 'default:stick', ''}, + {'', 'default:stick', ''}, + } +}) + +minetest.register_craft({ + output = 'default:pick_mese', + recipe = { + {'default:mese', 'default:mese', 'default:mese'}, + {'', 'default:stick', ''}, + {'', 'default:stick', ''}, + } +}) + +minetest.register_craft({ + output = 'default:shovel_wood', + recipe = { + {'default:wood'}, + {'default:stick'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:shovel_stone', + recipe = { + {'default:cobble'}, + {'default:stick'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:shovel_steel', + recipe = { + {'default:steel_ingot'}, + {'default:stick'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:axe_wood', + recipe = { + {'default:wood', 'default:wood'}, + {'default:wood', 'default:stick'}, + {'', 'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:axe_stone', + recipe = { + {'default:cobble', 'default:cobble'}, + {'default:cobble', 'default:stick'}, + {'', 'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:axe_steel', + recipe = { + {'default:steel_ingot', 'default:steel_ingot'}, + {'default:steel_ingot', 'default:stick'}, + {'', 'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:sword_wood', + recipe = { + {'default:wood'}, + {'default:wood'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:sword_stone', + recipe = { + {'default:cobble'}, + {'default:cobble'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:sword_steel', + recipe = { + {'default:steel_ingot'}, + {'default:steel_ingot'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:rail 15', + recipe = { + {'default:steel_ingot', '', 'default:steel_ingot'}, + {'default:steel_ingot', 'default:stick', 'default:steel_ingot'}, + {'default:steel_ingot', '', 'default:steel_ingot'}, + } +}) + +minetest.register_craft({ + output = 'default:chest', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'default:wood', '', 'default:wood'}, + {'default:wood', 'default:wood', 'default:wood'}, + } +}) + +minetest.register_craft({ + output = 'default:chest_locked', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'default:wood', 'default:steel_ingot', 'default:wood'}, + {'default:wood', 'default:wood', 'default:wood'}, + } +}) + +minetest.register_craft({ + output = 'default:furnace', + recipe = { + {'default:cobble', 'default:cobble', 'default:cobble'}, + {'default:cobble', '', 'default:cobble'}, + {'default:cobble', 'default:cobble', 'default:cobble'}, + } +}) + +minetest.register_craft({ + output = 'default:steelblock', + recipe = { + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + } +}) + +minetest.register_craft({ + output = 'default:sandstone', + recipe = { + {'default:sand', 'default:sand'}, + {'default:sand', 'default:sand'}, + } +}) + +minetest.register_craft({ + output = 'default:clay', + recipe = { + {'default:clay_lump', 'default:clay_lump'}, + {'default:clay_lump', 'default:clay_lump'}, + } +}) + +minetest.register_craft({ + output = 'default:brick', + recipe = { + {'default:clay_brick', 'default:clay_brick'}, + {'default:clay_brick', 'default:clay_brick'}, + } +}) + +minetest.register_craft({ + output = 'default:paper', + recipe = { + {'default:papyrus', 'default:papyrus', 'default:papyrus'}, + } +}) + +minetest.register_craft({ + output = 'default:book', + recipe = { + {'default:paper'}, + {'default:paper'}, + {'default:paper'}, + } +}) + +minetest.register_craft({ + output = 'default:bookshelf', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'default:book', 'default:book', 'default:book'}, + {'default:wood', 'default:wood', 'default:wood'}, + } +}) + +minetest.register_craft({ + output = 'default:ladder', + recipe = { + {'default:stick', '', 'default:stick'}, + {'default:stick', 'default:stick', 'default:stick'}, + {'default:stick', '', 'default:stick'}, + } +}) + +-- +-- Crafting (tool repair) +-- +minetest.register_craft({ + type = "toolrepair", + additional_wear = -0.02, +}) + +-- +-- Cooking recipes +-- + +minetest.register_craft({ + type = "cooking", + output = "default:glass", + recipe = "default:sand", +}) + +minetest.register_craft({ + type = "cooking", + output = "default:glass", + recipe = "default:desert_sand", +}) + +minetest.register_craft({ + type = "cooking", + output = "default:stone", + recipe = "default:cobble", +}) + +minetest.register_craft({ + type = "cooking", + output = "default:steel_ingot", + recipe = "default:iron_lump", +}) + +minetest.register_craft({ + type = "cooking", + output = "default:clay_brick", + recipe = "default:clay_lump", +}) + +-- +-- Fuels +-- + +minetest.register_craft({ + type = "fuel", + recipe = "default:tree", + burntime = 30, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:jungletree", + burntime = 30, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:junglegrass", + burntime = 2, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:leaves", + burntime = 1, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:cactus", + burntime = 15, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:papyrus", + burntime = 1, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:bookshelf", + burntime = 30, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:fence_wood", + burntime = 15, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:ladder", + burntime = 5, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:wood", + burntime = 7, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:mese", + burntime = 30, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:lava_source", + burntime = 60, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:torch", + burntime = 4, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:sign_wall", + burntime = 10, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:chest", + burntime = 30, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:chest_locked", + burntime = 30, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:nyancat", + burntime = 1, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:nyancat_rainbow", + burntime = 1, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:sapling", + burntime = 10, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:apple", + burntime = 3, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:coal_lump", + burntime = 40, +}) + +-- +-- Node definitions +-- + +-- Default node sounds + +function default.node_sound_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="", gain=1.0} + table.dug = table.dug or + {name="default_dug_node", gain=1.0} + return table +end + +function default.node_sound_stone_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="default_hard_footstep", gain=0.2} + default.node_sound_defaults(table) + return table +end + +function default.node_sound_dirt_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="", gain=0.5} + --table.dug = table.dug or + -- {name="default_dirt_break", gain=0.5} + default.node_sound_defaults(table) + return table +end + +function default.node_sound_sand_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="default_grass_footstep", gain=0.25} + --table.dug = table.dug or + -- {name="default_dirt_break", gain=0.25} + table.dug = table.dug or + {name="", gain=0.25} + default.node_sound_defaults(table) + return table +end + +function default.node_sound_wood_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="default_hard_footstep", gain=0.3} + default.node_sound_defaults(table) + return table +end + +function default.node_sound_leaves_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="default_grass_footstep", gain=0.25} + table.dig = table.dig or + {name="default_dig_crumbly", gain=0.4} + table.dug = table.dug or + {name="", gain=1.0} + default.node_sound_defaults(table) + return table +end + +function default.node_sound_glass_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="default_stone_footstep", gain=0.25} + table.dug = table.dug or + {name="default_break_glass", gain=1.0} + default.node_sound_defaults(table) + return table +end + +-- + +minetest.register_node("default:stone", { + description = "Stone", + tiles = {"default_stone.png"}, + is_ground_content = true, + groups = {cracky=3}, + drop = 'default:cobble', + legacy_mineral = true, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:desert_stone", { + description = "Desert Stone", + tiles = {"default_desert_stone.png"}, + is_ground_content = true, + groups = {cracky=3}, + drop = 'default:desert_stone', + legacy_mineral = true, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:stone_with_coal", { + description = "Coal Ore", + tiles = {"default_stone.png^default_mineral_coal.png"}, + is_ground_content = true, + groups = {cracky=3}, + drop = 'default:coal_lump', + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:stone_with_iron", { + description = "Iron Ore", + tiles = {"default_stone.png^default_mineral_iron.png"}, + is_ground_content = true, + groups = {cracky=3}, + drop = 'default:iron_lump', + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:dirt_with_grass", { + description = "Dirt with Grass", + tiles = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"}, + is_ground_content = true, + groups = {crumbly=3}, + drop = 'default:dirt', + sounds = default.node_sound_dirt_defaults({ + footstep = {name="default_grass_footstep", gain=0.4}, + }), +}) + +minetest.register_node("default:dirt_with_grass_footsteps", { + description = "Dirt with Grass and Footsteps", + tiles = {"default_grass_footsteps.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"}, + is_ground_content = true, + groups = {crumbly=3, not_in_creative_inventory=1}, + drop = 'default:dirt', + sounds = default.node_sound_dirt_defaults({ + footstep = {name="default_grass_footstep", gain=0.4}, + }), +}) + +minetest.register_node("default:dirt", { + description = "Dirt", + tiles = {"default_dirt.png"}, + is_ground_content = true, + groups = {crumbly=3}, + sounds = default.node_sound_dirt_defaults(), +}) + +minetest.register_node("default:sand", { + description = "Sand", + tiles = {"default_sand.png"}, + is_ground_content = true, + groups = {crumbly=3, falling_node=1}, + sounds = default.node_sound_sand_defaults(), +}) + +minetest.register_node("default:desert_sand", { + description = "Desert Sand", + tiles = {"default_desert_sand.png"}, + is_ground_content = true, + groups = {sand=1, crumbly=3, falling_node=1}, + sounds = default.node_sound_sand_defaults(), +}) + +minetest.register_node("default:gravel", { + description = "Gravel", + tiles = {"default_gravel.png"}, + is_ground_content = true, + groups = {crumbly=2, falling_node=1}, + sounds = default.node_sound_dirt_defaults({ + footstep = {name="default_gravel_footstep", gain=0.45}, + }), +}) + +minetest.register_node("default:sandstone", { + description = "Sandstone", + tiles = {"default_sandstone.png"}, + is_ground_content = true, + groups = {crumbly=2,cracky=2}, + drop = 'default:sand', + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:clay", { + description = "Clay", + tiles = {"default_clay.png"}, + is_ground_content = true, + groups = {crumbly=3}, + drop = 'default:clay_lump 4', + sounds = default.node_sound_dirt_defaults({ + footstep = "", + }), +}) + +minetest.register_node("default:brick", { + description = "Brick Block", + tiles = {"default_brick.png"}, + is_ground_content = true, + groups = {cracky=3}, + drop = 'default:clay_brick 4', + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:tree", { + description = "Tree", + tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"}, + is_ground_content = true, + groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:jungletree", { + description = "Jungle Tree", + tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"}, + is_ground_content = true, + groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:junglegrass", { + description = "Jungle Grass", + drawtype = "plantlike", + visual_scale = 1.3, + tiles = {"default_junglegrass.png"}, + inventory_image = "default_junglegrass.png", + wield_image = "default_junglegrass.png", + paramtype = "light", + walkable = false, + groups = {snappy=3,flammable=2}, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("default:leaves", { + description = "Leaves", + drawtype = "allfaces_optional", + visual_scale = 1.3, + tiles = {"default_leaves.png"}, + paramtype = "light", + groups = {snappy=3, leafdecay=3, flammable=2}, + drop = { + max_items = 1, + items = { + { + -- player will get sapling with 1/20 chance + items = {'default:sapling'}, + rarity = 20, + }, + } + }, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("default:cactus", { + description = "Cactus", + tiles = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"}, + is_ground_content = true, + groups = {snappy=2,choppy=3,flammable=2}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:papyrus", { + description = "Papyrus", + drawtype = "plantlike", + tiles = {"default_papyrus.png"}, + inventory_image = "default_papyrus.png", + wield_image = "default_papyrus.png", + paramtype = "light", + is_ground_content = true, + walkable = false, + groups = {snappy=3,flammable=2}, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("default:bookshelf", { + description = "Bookshelf", + tiles = {"default_wood.png", "default_wood.png", "default_bookshelf.png"}, + is_ground_content = true, + groups = {snappy=2,choppy=3,oddly_breakable_by_hand=2,flammable=3}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:glass", { + description = "Glass", + drawtype = "glasslike", + tiles = {"default_glass.png"}, + inventory_image = minetest.inventorycube("default_glass.png"), + paramtype = "light", + sunlight_propagates = true, + is_ground_content = true, + groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3}, + sounds = default.node_sound_glass_defaults(), +}) + +minetest.register_node("default:fence_wood", { + description = "Wooden Fence", + drawtype = "fencelike", + tiles = {"default_wood.png"}, + inventory_image = "default_fence.png", + wield_image = "default_fence.png", + paramtype = "light", + is_ground_content = true, + selection_box = { + type = "fixed", + fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, + }, + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:rail", { + description = "Rail", + drawtype = "raillike", + tiles = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"}, + inventory_image = "default_rail.png", + wield_image = "default_rail.png", + paramtype = "light", + is_ground_content = true, + walkable = false, + selection_box = { + type = "fixed", + -- but how to specify the dimensions for curved and sideways rails? + fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2}, + }, + groups = {bendy=2,snappy=1,dig_immediate=2}, +}) + +minetest.register_node("default:ladder", { + description = "Ladder", + drawtype = "signlike", + tiles = {"default_ladder.png"}, + inventory_image = "default_ladder.png", + wield_image = "default_ladder.png", + paramtype = "light", + paramtype2 = "wallmounted", + is_ground_content = true, + walkable = false, + climbable = true, + selection_box = { + type = "wallmounted", + --wall_top = = + --wall_bottom = = + --wall_side = = + }, + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=3,flammable=2}, + legacy_wallmounted = true, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:wood", { + description = "Wooden Planks", + tiles = {"default_wood.png"}, + is_ground_content = true, + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:mese", { + description = "Mese", + tiles = {"default_mese.png"}, + is_ground_content = true, + groups = {cracky=1}, + sounds = default.node_sound_defaults(), +}) + +minetest.register_node("default:cloud", { + description = "Cloud", + tiles = {"default_cloud.png"}, + is_ground_content = true, + sounds = default.node_sound_defaults(), + groups = {not_in_creative_inventory=1}, +}) + +minetest.register_node("default:water_flowing", { + description = "Flowing Water", + inventory_image = minetest.inventorycube("default_water.png"), + drawtype = "flowingliquid", + tiles = {"default_water.png"}, + special_tiles = { + {name="default_water.png", backface_culling=false}, + {name="default_water.png", backface_culling=true}, + }, + alpha = WATER_ALPHA, + paramtype = "light", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + liquidtype = "flowing", + liquid_alternative_flowing = "default:water_flowing", + liquid_alternative_source = "default:water_source", + liquid_viscosity = WATER_VISC, + post_effect_color = {a=64, r=100, g=100, b=200}, + groups = {water=3, liquid=3, puts_out_fire=1, not_in_creative_inventory=1}, +}) + +minetest.register_node("default:water_source", { + description = "Water Source", + inventory_image = minetest.inventorycube("default_water.png"), + drawtype = "liquid", + tiles = {"default_water.png"}, + special_tiles = { + -- New-style water source material (mostly unused) + {name="default_water.png", backface_culling=false}, + }, + alpha = WATER_ALPHA, + paramtype = "light", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + liquidtype = "source", + liquid_alternative_flowing = "default:water_flowing", + liquid_alternative_source = "default:water_source", + liquid_viscosity = WATER_VISC, + post_effect_color = {a=64, r=100, g=100, b=200}, + groups = {water=3, liquid=3, puts_out_fire=1}, +}) + +minetest.register_node("default:lava_flowing", { + description = "Flowing Lava", + inventory_image = minetest.inventorycube("default_lava.png"), + drawtype = "flowingliquid", + tiles = {"default_lava.png"}, + special_tiles = { + { + image="default_lava_flowing_animated.png", + backface_culling=false, + animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3} + }, + { + image="default_lava_flowing_animated.png", + backface_culling=true, + animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3} + }, + }, + paramtype = "light", + light_source = LIGHT_MAX - 1, + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + liquidtype = "flowing", + liquid_alternative_flowing = "default:lava_flowing", + liquid_alternative_source = "default:lava_source", + liquid_viscosity = LAVA_VISC, + damage_per_second = 4*2, + post_effect_color = {a=192, r=255, g=64, b=0}, + groups = {lava=3, liquid=2, hot=3, igniter=1, not_in_creative_inventory=1}, +}) + +minetest.register_node("default:lava_source", { + description = "Lava Source", + inventory_image = minetest.inventorycube("default_lava.png"), + drawtype = "liquid", + tiles = { + {name="default_lava_source_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}} + }, + special_tiles = { + -- New-style lava source material (mostly unused) + {name="default_lava.png", backface_culling=false}, + }, + paramtype = "light", + light_source = LIGHT_MAX - 1, + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + liquidtype = "source", + liquid_alternative_flowing = "default:lava_flowing", + liquid_alternative_source = "default:lava_source", + liquid_viscosity = LAVA_VISC, + damage_per_second = 4*2, + post_effect_color = {a=192, r=255, g=64, b=0}, + groups = {lava=3, liquid=2, hot=3, igniter=1}, +}) + +minetest.register_node("default:torch", { + description = "Torch", + drawtype = "torchlike", + tiles = {"default_torch_on_floor.png", "default_torch_on_ceiling.png", "default_torch.png"}, + inventory_image = "default_torch_on_floor.png", + wield_image = "default_torch_on_floor.png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + walkable = false, + light_source = LIGHT_MAX-1, + selection_box = { + type = "wallmounted", + wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1}, + wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, + wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1}, + }, + groups = {choppy=2,dig_immediate=3,flammable=1}, + legacy_wallmounted = true, + sounds = default.node_sound_defaults(), +}) + +minetest.register_node("default:sign_wall", { + description = "Sign", + drawtype = "signlike", + tiles = {"default_sign_wall.png"}, + inventory_image = "default_sign_wall.png", + wield_image = "default_sign_wall.png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + walkable = false, + metadata_name = "sign", + selection_box = { + type = "wallmounted", + --wall_top = + --wall_bottom = + --wall_side = + }, + groups = {choppy=2,dig_immediate=2}, + legacy_wallmounted = true, + sounds = default.node_sound_defaults(), + on_construct = function(pos) + --local n = minetest.env:get_node(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", "hack:sign_text_input") + meta:set_string("infotext", "\"\"") + end, + on_receive_fields = function(pos, formname, fields, sender) + --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields)) + local meta = minetest.env:get_meta(pos) + fields.text = fields.text or "" + print((sender:get_player_name() or "").." wrote \""..fields.text.. + "\" to sign at "..minetest.pos_to_string(pos)) + meta:set_string("text", fields.text) + meta:set_string("infotext", '"'..fields.text..'"') + end, +}) + +minetest.register_node("default:chest", { + description = "Chest", + tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png", + "default_chest_side.png", "default_chest_side.png", "default_chest_front.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[8,9;]".. + "list[current_name;main;0,0;8,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Chest") + local inv = meta:get_inventory() + inv:set_size("main", 8*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + end, +}) + +local function has_locked_chest_privilege(meta, player) + if player:get_player_name() ~= meta:get_string("owner") then + return false + end + return true +end + +minetest.register_node("default:chest_locked", { + description = "Locked Chest", + tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png", + "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + after_place_node = function(pos, placer) + local meta = minetest.env:get_meta(pos) + meta:set_string("owner", placer:get_player_name() or "") + meta:set_string("infotext", "Locked Chest (owned by ".. + meta:get_string("owner")..")") + end, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[8,9;]".. + "list[current_name;main;0,0;8,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Locked Chest") + meta:set_string("owner", "") + local inv = meta:get_inventory() + inv:set_size("main", 8*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return count + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from locked chest at "..minetest.pos_to_string(pos)) + end, +}) + +default.furnace_inactive_formspec = + "invsize[8,9;]".. + "image[2,2;1,1;default_furnace_fire_bg.png]".. + "list[current_name;fuel;2,3;1,1;]".. + "list[current_name;src;2,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]" + +minetest.register_node("default:furnace", { + description = "Furnace", + tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png", + "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"}, + paramtype2 = "facedir", + groups = {cracky=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_stone_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", default.furnace_inactive_formspec) + meta:set_string("infotext", "Furnace") + local inv = meta:get_inventory() + inv:set_size("fuel", 1) + inv:set_size("src", 1) + inv:set_size("dst", 4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + if not inv:is_empty("fuel") then + return false + elseif not inv:is_empty("dst") then + return false + elseif not inv:is_empty("src") then + return false + end + return true + end, +}) + +minetest.register_node("default:furnace_active", { + description = "Furnace", + tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png", + "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front_active.png"}, + paramtype2 = "facedir", + light_source = 8, + drop = "default:furnace", + groups = {cracky=2, not_in_creative_inventory=1}, + legacy_facedir_simple = true, + sounds = default.node_sound_stone_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", default.furnace_inactive_formspec) + meta:set_string("infotext", "Furnace"); + local inv = meta:get_inventory() + inv:set_size("fuel", 1) + inv:set_size("src", 1) + inv:set_size("dst", 4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + if not inv:is_empty("fuel") then + return false + elseif not inv:is_empty("dst") then + return false + elseif not inv:is_empty("src") then + return false + end + return true + end, +}) + +function hacky_swap_node(pos,name) + local node = minetest.env:get_node(pos) + local meta = minetest.env:get_meta(pos) + local meta0 = meta:to_table() + if node.name == name then + return + end + node.name = name + local meta0 = meta:to_table() + minetest.env:set_node(pos,node) + meta = minetest.env:get_meta(pos) + meta:from_table(meta0) +end + +minetest.register_abm({ + nodenames = {"default:furnace","default:furnace_active"}, + interval = 1.0, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local meta = minetest.env:get_meta(pos) + for i, name in ipairs({ + "fuel_totaltime", + "fuel_time", + "src_totaltime", + "src_time" + }) do + if meta:get_string(name) == "" then + meta:set_float(name, 0.0) + end + end + + local inv = meta:get_inventory() + + local srclist = inv:get_list("src") + local cooked = nil + + if srclist then + cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) + end + + local was_active = false + + if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then + was_active = true + meta:set_float("fuel_time", meta:get_float("fuel_time") + 1) + meta:set_float("src_time", meta:get_float("src_time") + 1) + if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then + -- check if there's room for output in "dst" list + if inv:room_for_item("dst",cooked.item) then + -- Put result in "dst" list + inv:add_item("dst", cooked.item) + -- take stuff from "src" list + srcstack = inv:get_stack("src", 1) + srcstack:take_item() + inv:set_stack("src", 1, srcstack) + else + print("Could not insert '"..cooked.item.."'") + end + meta:set_string("src_time", 0) + end + end + + if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then + local percent = math.floor(meta:get_float("fuel_time") / + meta:get_float("fuel_totaltime") * 100) + meta:set_string("infotext","Furnace active: "..percent.."%") + hacky_swap_node(pos,"default:furnace_active") + meta:set_string("formspec", + "invsize[8,9;]".. + "image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:".. + (100-percent)..":default_furnace_fire_fg.png]".. + "list[current_name;fuel;2,3;1,1;]".. + "list[current_name;src;2,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]") + return + end + + local fuel = nil + local cooked = nil + local fuellist = inv:get_list("fuel") + local srclist = inv:get_list("src") + + if srclist then + cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) + end + if fuellist then + fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) + end + + if fuel.time <= 0 then + meta:set_string("infotext","Furnace out of fuel") + hacky_swap_node(pos,"default:furnace") + meta:set_string("formspec", default.furnace_inactive_formspec) + return + end + + if cooked.item:is_empty() then + if was_active then + meta:set_string("infotext","Furnace is empty") + hacky_swap_node(pos,"default:furnace") + meta:set_string("formspec", default.furnace_inactive_formspec) + end + return + end + + meta:set_string("fuel_totaltime", fuel.time) + meta:set_string("fuel_time", 0) + + local stack = inv:get_stack("fuel", 1) + stack:take_item() + inv:set_stack("fuel", 1, stack) + end, +}) + +minetest.register_node("default:cobble", { + description = "Cobblestone", + tiles = {"default_cobble.png"}, + is_ground_content = true, + groups = {cracky=3}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:mossycobble", { + description = "Mossy Cobblestone", + tiles = {"default_mossycobble.png"}, + is_ground_content = true, + groups = {cracky=3}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:steelblock", { + description = "Steel Block", + tiles = {"default_steel_block.png"}, + is_ground_content = true, + groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:nyancat", { + description = "Nyan Cat", + tiles = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png", + "default_nc_side.png", "default_nc_back.png", "default_nc_front.png"}, + inventory_image = "default_nc_front.png", + paramtype2 = "facedir", + groups = {cracky=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_defaults(), +}) + +minetest.register_node("default:nyancat_rainbow", { + description = "Nyan Cat Rainbow", + tiles = {"default_nc_rb.png"}, + inventory_image = "default_nc_rb.png", + groups = {cracky=2}, + sounds = default.node_sound_defaults(), +}) + +minetest.register_node("default:sapling", { + description = "Sapling", + drawtype = "plantlike", + visual_scale = 1.0, + tiles = {"default_sapling.png"}, + inventory_image = "default_sapling.png", + wield_image = "default_sapling.png", + paramtype = "light", + walkable = false, + groups = {snappy=2,dig_immediate=3,flammable=2}, + sounds = default.node_sound_defaults(), +}) + +minetest.register_node("default:apple", { + description = "Apple", + drawtype = "plantlike", + visual_scale = 1.0, + tiles = {"default_apple.png"}, + inventory_image = "default_apple.png", + paramtype = "light", + sunlight_propagates = true, + walkable = false, + groups = {fleshy=3,dig_immediate=3,flammable=2}, + on_use = minetest.item_eat(4), + sounds = default.node_sound_defaults(), +}) + +minetest.register_node("default:dry_shrub", { + description = "Dry Shrub", + drawtype = "plantlike", + visual_scale = 1.0, + tiles = {"default_dry_shrub.png"}, + inventory_image = "default_dry_shrub.png", + wield_image = "default_dry_shrub.png", + paramtype = "light", + walkable = false, + groups = {snappy=3,flammable=3}, + sounds = default.node_sound_leaves_defaults(), + selection_box = { + type = "fixed", + fixed = {-1/3, -1/2, -1/3, 1/3, 1/6, 1/3}, + }, +}) + +-- +-- Crafting items +-- + +minetest.register_craftitem("default:stick", { + description = "Stick", + inventory_image = "default_stick.png", +}) + +minetest.register_craftitem("default:paper", { + description = "Paper", + inventory_image = "default_paper.png", +}) + +minetest.register_craftitem("default:book", { + description = "Book", + inventory_image = "default_book.png", +}) + +minetest.register_craftitem("default:coal_lump", { + description = "Coal Lump", + inventory_image = "default_coal_lump.png", +}) + +minetest.register_craftitem("default:iron_lump", { + description = "Iron Lump", + inventory_image = "default_iron_lump.png", +}) + +minetest.register_craftitem("default:clay_lump", { + description = "Clay Lump", + inventory_image = "default_clay_lump.png", +}) + +minetest.register_craftitem("default:steel_ingot", { + description = "Steel Ingot", + inventory_image = "default_steel_ingot.png", +}) + +minetest.register_craftitem("default:clay_brick", { + description = "Clay Brick", + inventory_image = "default_steel_ingot.png", + inventory_image = "default_clay_brick.png", +}) + +minetest.register_craftitem("default:scorched_stuff", { + description = "Scorched Stuff", + inventory_image = "default_scorched_stuff.png", +}) + +-- +-- Falling stuff +-- + +minetest.register_entity("default:falling_node", { + initial_properties = { + physical = true, + collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, + visual = "wielditem", + textures = {}, + visual_size = {x=0.667, y=0.667}, + }, + + nodename = "", + + set_node = function(self, nodename) + self.nodename = nodename + local stack = ItemStack(nodename) + local itemtable = stack:to_table() + local itemname = nil + if itemtable then + itemname = stack:to_table().name + end + local item_texture = nil + local item_type = "" + if minetest.registered_items[itemname] then + item_texture = minetest.registered_items[itemname].inventory_image + item_type = minetest.registered_items[itemname].type + end + prop = { + is_visible = true, + textures = {nodename}, + } + self.object:set_properties(prop) + end, + + get_staticdata = function(self) + return self.nodename + end, + + on_activate = function(self, staticdata) + self.nodename = staticdata + self.object:set_armor_groups({immortal=1}) + --self.object:setacceleration({x=0, y=-10, z=0}) + self:set_node(self.nodename) + end, + + on_step = function(self, dtime) + -- Set gravity + self.object:setacceleration({x=0, y=-10, z=0}) + -- Turn to actual sand when collides to ground or just move + local pos = self.object:getpos() + local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point + local bcn = minetest.env:get_node(bcp) + -- Note: walkable is in the node definition, not in item groups + if minetest.registered_nodes[bcn.name] and + minetest.registered_nodes[bcn.name].walkable then + local np = {x=bcp.x, y=bcp.y+1, z=bcp.z} + -- Check what's here + local n2 = minetest.env:get_node(np) + -- If it's not air or liquid, remove node and replace it with + -- it's drops + if n2.name ~= "air" and (not minetest.registered_nodes[n2.name] or + minetest.registered_nodes[n2.name].liquidtype == "none") then + local drops = minetest.get_node_drops(n2.name, "") + minetest.env:remove_node(np) + -- Add dropped items + local _, dropped_item + for _, dropped_item in ipairs(drops) do + minetest.env:add_item(np, dropped_item) + end + -- Run script hook + local _, callback + for _, callback in ipairs(minetest.registered_on_dignodes) do + callback(np, n2, nil) + end + end + -- Create node and remove entity + minetest.env:add_node(np, {name=self.nodename}) + self.object:remove() + else + -- Do nothing + end + end +}) + +function default.spawn_falling_node(p, nodename) + obj = minetest.env:add_entity(p, "default:falling_node") + obj:get_luaentity():set_node(nodename) +end + +-- Horrible crap to support old code +-- Don't use this and never do what this does, it's completely wrong! +-- (More specifically, the client and the C++ code doesn't get the group) +function default.register_falling_node(nodename, texture) + minetest.log("error", debug.traceback()) + minetest.log('error', "WARNING: default.register_falling_node is deprecated") + if minetest.registered_nodes[nodename] then + minetest.registered_nodes[nodename].groups.falling_node = 1 + end +end + +-- +-- Some common functions +-- + +function nodeupdate_single(p) + n = minetest.env:get_node(p) + if minetest.get_node_group(n.name, "falling_node") ~= 0 then + p_bottom = {x=p.x, y=p.y-1, z=p.z} + n_bottom = minetest.env:get_node(p_bottom) + -- Note: walkable is in the node definition, not in item groups + if minetest.registered_nodes[n_bottom.name] and + not minetest.registered_nodes[n_bottom.name].walkable then + minetest.env:remove_node(p) + default.spawn_falling_node(p, n.name) + nodeupdate(p) + end + end +end + +function nodeupdate(p) + for x = -1,1 do + for y = -1,1 do + for z = -1,1 do + p2 = {x=p.x+x, y=p.y+y, z=p.z+z} + nodeupdate_single(p2) + end + end + end +end + +-- +-- Global callbacks +-- + +-- Global environment step function +function on_step(dtime) + -- print("on_step") +end +minetest.register_globalstep(on_step) + +function on_placenode(p, node) + --print("on_placenode") + nodeupdate(p) +end +minetest.register_on_placenode(on_placenode) + +function on_dignode(p, node) + --print("on_dignode") + nodeupdate(p) +end +minetest.register_on_dignode(on_dignode) + +function on_punchnode(p, node) +end +minetest.register_on_punchnode(on_punchnode) + +-- END diff --git a/games/minitest/mods/default/init.lua~ b/games/minitest/mods/default/init.lua~ new file mode 100644 index 0000000..58d3977 --- /dev/null +++ b/games/minitest/mods/default/init.lua~ @@ -0,0 +1,1906 @@ +-- Minetest 0.4 mod: default +-- See README.txt for licensing and other information. + +-- The API documentation in here was moved into doc/lua_api.txt + +WATER_ALPHA = 160 +WATER_VISC = 1 +LAVA_VISC = 7 +LIGHT_MAX = 14 + +-- Definitions made by this mod that other mods can use too +default = {} + +-- Load other files +dofile(minetest.get_modpath("default").."/mapgen.lua") +dofile(minetest.get_modpath("default").."/leafdecay.lua") + +-- +-- Tool definition +-- + +-- The hand +minetest.register_item(":", { + type = "none", + wield_image = "wieldhand.png", + wield_scale = {x=1,y=1,z=2.5}, + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level = 0, + groupcaps = { + fleshy = {times={[2]=2.00, [3]=1.00}, uses=0, maxlevel=1}, + crumbly = {times={[2]=3.00, [3]=0.70}, uses=0, maxlevel=1}, + snappy = {times={[3]=0.40}, uses=0, maxlevel=1}, + oddly_breakable_by_hand = {times={[1]=7.00,[2]=4.00,[3]=1.40}, uses=0, maxlevel=3}, + } + } +}) + +minetest.register_tool("default:pick_wood", { + description = "Wooden Pickaxe", + inventory_image = "default_tool_woodpick.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + cracky={times={[2]=2.00, [3]=1.20}, uses=10, maxlevel=1} + } + }, +}) +minetest.register_tool("default:pick_stone", { + description = "Stone Pickaxe", + inventory_image = "default_tool_stonepick.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + cracky={times={[1]=3.00, [2]=1.20, [3]=0.80}, uses=20, maxlevel=1} + } + }, +}) +minetest.register_tool("default:pick_steel", { + description = "Steel Pickaxe", + inventory_image = "default_tool_steelpick.png", + tool_capabilities = { + max_drop_level=1, + groupcaps={ + cracky={times={[1]=4.00, [2]=1.60, [3]=1.00}, uses=30, maxlevel=2} + } + }, +}) +minetest.register_tool("default:pick_mese", { + description = "Mese Pickaxe", + inventory_image = "default_tool_mesepick.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=3, + groupcaps={ + cracky={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, + crumbly={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, + snappy={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3} + } + }, +}) +minetest.register_tool("default:shovel_wood", { + description = "Wooden Shovel", + inventory_image = "default_tool_woodshovel.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + crumbly={times={[1]=3.00, [2]=0.80, [3]=0.50}, uses=10, maxlevel=1} + } + }, +}) +minetest.register_tool("default:shovel_stone", { + description = "Stone Shovel", + inventory_image = "default_tool_stoneshovel.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + crumbly={times={[1]=1.50, [2]=0.50, [3]=0.30}, uses=20, maxlevel=1} + } + }, +}) +minetest.register_tool("default:shovel_steel", { + description = "Steel Shovel", + inventory_image = "default_tool_steelshovel.png", + tool_capabilities = { + max_drop_level=1, + groupcaps={ + crumbly={times={[1]=1.50, [2]=0.70, [3]=0.60}, uses=30, maxlevel=2} + } + }, +}) +minetest.register_tool("default:axe_wood", { + description = "Wooden Axe", + inventory_image = "default_tool_woodaxe.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + choppy={times={[2]=1.40, [3]=0.80}, uses=10, maxlevel=1}, + fleshy={times={[2]=1.50, [3]=0.80}, uses=10, maxlevel=1} + } + }, +}) +minetest.register_tool("default:axe_stone", { + description = "Stone Axe", + inventory_image = "default_tool_stoneaxe.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + choppy={times={[1]=3.00, [2]=1.00, [3]=0.60}, uses=20, maxlevel=1}, + fleshy={times={[2]=1.30, [3]=0.70}, uses=20, maxlevel=1} + } + }, +}) +minetest.register_tool("default:axe_steel", { + description = "Steel Axe", + inventory_image = "default_tool_steelaxe.png", + tool_capabilities = { + max_drop_level=1, + groupcaps={ + choppy={times={[1]=3.00, [2]=1.60, [3]=1.00}, uses=30, maxlevel=2}, + fleshy={times={[2]=1.10, [3]=0.60}, uses=40, maxlevel=1} + } + }, +}) +minetest.register_tool("default:sword_wood", { + description = "Wooden Sword", + inventory_image = "default_tool_woodsword.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=0, + groupcaps={ + fleshy={times={[2]=1.10, [3]=0.60}, uses=10, maxlevel=1}, + snappy={times={[2]=1.00, [3]=0.50}, uses=10, maxlevel=1}, + choppy={times={[3]=1.00}, uses=20, maxlevel=0} + } + } +}) +minetest.register_tool("default:sword_stone", { + description = "Stone Sword", + inventory_image = "default_tool_stonesword.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=0, + groupcaps={ + fleshy={times={[2]=0.80, [3]=0.40}, uses=20, maxlevel=1}, + snappy={times={[2]=0.80, [3]=0.40}, uses=20, maxlevel=1}, + choppy={times={[3]=0.90}, uses=20, maxlevel=0} + } + } +}) +minetest.register_tool("default:sword_steel", { + description = "Steel Sword", + inventory_image = "default_tool_steelsword.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=1, + groupcaps={ + fleshy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=10, maxlevel=2}, + snappy={times={[2]=0.70, [3]=0.30}, uses=40, maxlevel=1}, + choppy={times={[3]=0.70}, uses=40, maxlevel=0} + } + } +}) + +-- +-- Crafting definition +-- + +minetest.register_craft({ + output = 'default:wood 4', + recipe = { + {'default:tree'}, + } +}) + +minetest.register_craft({ + output = 'default:stick 4', + recipe = { + {'default:wood'}, + } +}) + +minetest.register_craft({ + output = 'default:fence_wood 2', + recipe = { + {'default:stick', 'default:stick', 'default:stick'}, + {'default:stick', 'default:stick', 'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:sign_wall', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'default:wood', 'default:wood', 'default:wood'}, + {'', 'default:stick', ''}, + } +}) + +minetest.register_craft({ + output = 'default:torch 4', + recipe = { + {'default:coal_lump'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:pick_wood', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'', 'default:stick', ''}, + {'', 'default:stick', ''}, + } +}) + +minetest.register_craft({ + output = 'default:pick_stone', + recipe = { + {'default:cobble', 'default:cobble', 'default:cobble'}, + {'', 'default:stick', ''}, + {'', 'default:stick', ''}, + } +}) + +minetest.register_craft({ + output = 'default:pick_steel', + recipe = { + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + {'', 'default:stick', ''}, + {'', 'default:stick', ''}, + } +}) + +minetest.register_craft({ + output = 'default:pick_mese', + recipe = { + {'default:mese', 'default:mese', 'default:mese'}, + {'', 'default:stick', ''}, + {'', 'default:stick', ''}, + } +}) + +minetest.register_craft({ + output = 'default:shovel_wood', + recipe = { + {'default:wood'}, + {'default:stick'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:shovel_stone', + recipe = { + {'default:cobble'}, + {'default:stick'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:shovel_steel', + recipe = { + {'default:steel_ingot'}, + {'default:stick'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:axe_wood', + recipe = { + {'default:wood', 'default:wood'}, + {'default:wood', 'default:stick'}, + {'', 'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:axe_stone', + recipe = { + {'default:cobble', 'default:cobble'}, + {'default:cobble', 'default:stick'}, + {'', 'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:axe_steel', + recipe = { + {'default:steel_ingot', 'default:steel_ingot'}, + {'default:steel_ingot', 'default:stick'}, + {'', 'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:sword_wood', + recipe = { + {'default:wood'}, + {'default:wood'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:sword_stone', + recipe = { + {'default:cobble'}, + {'default:cobble'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:sword_steel', + recipe = { + {'default:steel_ingot'}, + {'default:steel_ingot'}, + {'default:stick'}, + } +}) + +minetest.register_craft({ + output = 'default:rail 15', + recipe = { + {'default:steel_ingot', '', 'default:steel_ingot'}, + {'default:steel_ingot', 'default:stick', 'default:steel_ingot'}, + {'default:steel_ingot', '', 'default:steel_ingot'}, + } +}) + +minetest.register_craft({ + output = 'default:chest', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'default:wood', '', 'default:wood'}, + {'default:wood', 'default:wood', 'default:wood'}, + } +}) + +minetest.register_craft({ + output = 'default:chest_locked', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'default:wood', 'default:steel_ingot', 'default:wood'}, + {'default:wood', 'default:wood', 'default:wood'}, + } +}) + +minetest.register_craft({ + output = 'default:furnace', + recipe = { + {'default:cobble', 'default:cobble', 'default:cobble'}, + {'default:cobble', '', 'default:cobble'}, + {'default:cobble', 'default:cobble', 'default:cobble'}, + } +}) + +minetest.register_craft({ + output = 'default:steelblock', + recipe = { + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + } +}) + +minetest.register_craft({ + output = 'default:sandstone', + recipe = { + {'default:sand', 'default:sand'}, + {'default:sand', 'default:sand'}, + } +}) + +minetest.register_craft({ + output = 'default:clay', + recipe = { + {'default:clay_lump', 'default:clay_lump'}, + {'default:clay_lump', 'default:clay_lump'}, + } +}) + +minetest.register_craft({ + output = 'default:brick', + recipe = { + {'default:clay_brick', 'default:clay_brick'}, + {'default:clay_brick', 'default:clay_brick'}, + } +}) + +minetest.register_craft({ + output = 'default:paper', + recipe = { + {'default:papyrus', 'default:papyrus', 'default:papyrus'}, + } +}) + +minetest.register_craft({ + output = 'default:book', + recipe = { + {'default:paper'}, + {'default:paper'}, + {'default:paper'}, + } +}) + +minetest.register_craft({ + output = 'default:bookshelf', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'default:book', 'default:book', 'default:book'}, + {'default:wood', 'default:wood', 'default:wood'}, + } +}) + +minetest.register_craft({ + output = 'default:ladder', + recipe = { + {'default:stick', '', 'default:stick'}, + {'default:stick', 'default:stick', 'default:stick'}, + {'default:stick', '', 'default:stick'}, + } +}) + +-- +-- Crafting (tool repair) +-- +minetest.register_craft({ + type = "toolrepair", + additional_wear = -0.02, +}) + +-- +-- Cooking recipes +-- + +minetest.register_craft({ + type = "cooking", + output = "default:glass", + recipe = "default:sand", +}) + +minetest.register_craft({ + type = "cooking", + output = "default:glass", + recipe = "default:desert_sand", +}) + +minetest.register_craft({ + type = "cooking", + output = "default:stone", + recipe = "default:cobble", +}) + +minetest.register_craft({ + type = "cooking", + output = "default:steel_ingot", + recipe = "default:iron_lump", +}) + +minetest.register_craft({ + type = "cooking", + output = "default:clay_brick", + recipe = "default:clay_lump", +}) + +-- +-- Fuels +-- + +minetest.register_craft({ + type = "fuel", + recipe = "default:tree", + burntime = 30, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:jungletree", + burntime = 30, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:junglegrass", + burntime = 2, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:leaves", + burntime = 1, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:cactus", + burntime = 15, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:papyrus", + burntime = 1, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:bookshelf", + burntime = 30, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:fence_wood", + burntime = 15, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:ladder", + burntime = 5, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:wood", + burntime = 7, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:mese", + burntime = 30, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:lava_source", + burntime = 60, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:torch", + burntime = 4, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:sign_wall", + burntime = 10, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:chest", + burntime = 30, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:chest_locked", + burntime = 30, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:nyancat", + burntime = 1, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:nyancat_rainbow", + burntime = 1, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:sapling", + burntime = 10, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:apple", + burntime = 3, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:coal_lump", + burntime = 40, +}) + +-- +-- Node definitions +-- + +-- Default node sounds + +function default.node_sound_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="", gain=1.0} + table.dug = table.dug or + {name="default_dug_node", gain=1.0} + return table +end + +function default.node_sound_stone_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="default_hard_footstep", gain=0.2} + default.node_sound_defaults(table) + return table +end + +function default.node_sound_dirt_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="", gain=0.5} + --table.dug = table.dug or + -- {name="default_dirt_break", gain=0.5} + default.node_sound_defaults(table) + return table +end + +function default.node_sound_sand_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="default_grass_footstep", gain=0.25} + --table.dug = table.dug or + -- {name="default_dirt_break", gain=0.25} + table.dug = table.dug or + {name="", gain=0.25} + default.node_sound_defaults(table) + return table +end + +function default.node_sound_wood_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="default_hard_footstep", gain=0.3} + default.node_sound_defaults(table) + return table +end + +function default.node_sound_leaves_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="default_grass_footstep", gain=0.25} + table.dig = table.dig or + {name="default_dig_crumbly", gain=0.4} + table.dug = table.dug or + {name="", gain=1.0} + default.node_sound_defaults(table) + return table +end + +function default.node_sound_glass_defaults(table) + table = table or {} + table.footstep = table.footstep or + {name="default_stone_footstep", gain=0.25} + table.dug = table.dug or + {name="default_break_glass", gain=1.0} + default.node_sound_defaults(table) + return table +end + +-- + +minetest.register_node("default:stone", { + description = "Stone", + tiles = {"default_stone.png"}, + is_ground_content = true, + groups = {cracky=3}, + drop = 'default:cobble', + legacy_mineral = true, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:desert_stone", { + description = "Desert Stone", + tiles = {"default_desert_stone.png"}, + is_ground_content = true, + groups = {cracky=3}, + drop = 'default:desert_stone', + legacy_mineral = true, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:stone_with_coal", { + description = "Coal Ore", + tiles = {"default_stone.png^default_mineral_coal.png"}, + is_ground_content = true, + groups = {cracky=3}, + drop = 'default:coal_lump', + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:stone_with_iron", { + description = "Iron Ore", + tiles = {"default_stone.png^default_mineral_iron.png"}, + is_ground_content = true, + groups = {cracky=3}, + drop = 'default:iron_lump', + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:dirt_with_grass", { + description = "Dirt with Grass", + tiles = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"}, + is_ground_content = true, + groups = {crumbly=3}, + drop = 'default:dirt', + sounds = default.node_sound_dirt_defaults({ + footstep = {name="default_grass_footstep", gain=0.4}, + }), +}) + +minetest.register_node("default:dirt_with_grass_footsteps", { + description = "Dirt with Grass and Footsteps", + tiles = {"default_grass_footsteps.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"}, + is_ground_content = true, + groups = {crumbly=3}, + drop = 'default:dirt', + sounds = default.node_sound_dirt_defaults({ + footstep = {name="default_grass_footstep", gain=0.4}, + }), +}) + +minetest.register_node("default:dirt", { + description = "Dirt", + tiles = {"default_dirt.png"}, + is_ground_content = true, + groups = {crumbly=3}, + sounds = default.node_sound_dirt_defaults(), +}) + +minetest.register_node("default:sand", { + description = "Sand", + tiles = {"default_sand.png"}, + is_ground_content = true, + groups = {crumbly=3, falling_node=1}, + sounds = default.node_sound_sand_defaults(), +}) + +minetest.register_node("default:desert_sand", { + description = "Desert Sand", + tiles = {"default_desert_sand.png"}, + is_ground_content = true, + groups = {sand=1, crumbly=3, falling_node=1}, + sounds = default.node_sound_sand_defaults(), +}) + +minetest.register_node("default:gravel", { + description = "Gravel", + tiles = {"default_gravel.png"}, + is_ground_content = true, + groups = {crumbly=2, falling_node=1}, + sounds = default.node_sound_dirt_defaults({ + footstep = {name="default_gravel_footstep", gain=0.45}, + }), +}) + +minetest.register_node("default:sandstone", { + description = "Sandstone", + tiles = {"default_sandstone.png"}, + is_ground_content = true, + groups = {crumbly=2,cracky=2}, + drop = 'default:sand', + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:clay", { + description = "Clay", + tiles = {"default_clay.png"}, + is_ground_content = true, + groups = {crumbly=3}, + drop = 'default:clay_lump 4', + sounds = default.node_sound_dirt_defaults({ + footstep = "", + }), +}) + +minetest.register_node("default:brick", { + description = "Brick Block", + tiles = {"default_brick.png"}, + is_ground_content = true, + groups = {cracky=3}, + drop = 'default:clay_brick 4', + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:tree", { + description = "Tree", + tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"}, + is_ground_content = true, + groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:jungletree", { + description = "Jungle Tree", + tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"}, + is_ground_content = true, + groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:junglegrass", { + description = "Jungle Grass", + drawtype = "plantlike", + visual_scale = 1.3, + tiles = {"default_junglegrass.png"}, + inventory_image = "default_junglegrass.png", + wield_image = "default_junglegrass.png", + paramtype = "light", + walkable = false, + groups = {snappy=3,flammable=2}, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("default:leaves", { + description = "Leaves", + drawtype = "allfaces_optional", + visual_scale = 1.3, + tiles = {"default_leaves.png"}, + paramtype = "light", + groups = {snappy=3, leafdecay=3, flammable=2}, + drop = { + max_items = 1, + items = { + { + -- player will get sapling with 1/20 chance + items = {'default:sapling'}, + rarity = 20, + }, + { + -- player will get leaves only if he get no saplings, + -- this is because max_items is 1 + items = {'default:leaves'}, + } + } + }, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("default:cactus", { + description = "Cactus", + tiles = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"}, + is_ground_content = true, + groups = {snappy=2,choppy=3,flammable=2}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:papyrus", { + description = "Papyrus", + drawtype = "plantlike", + tiles = {"default_papyrus.png"}, + inventory_image = "default_papyrus.png", + wield_image = "default_papyrus.png", + paramtype = "light", + is_ground_content = true, + walkable = false, + groups = {snappy=3,flammable=2}, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("default:bookshelf", { + description = "Bookshelf", + tiles = {"default_wood.png", "default_wood.png", "default_bookshelf.png"}, + is_ground_content = true, + groups = {snappy=2,choppy=3,oddly_breakable_by_hand=2,flammable=3}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:glass", { + description = "Glass", + drawtype = "glasslike", + tiles = {"default_glass.png"}, + inventory_image = minetest.inventorycube("default_glass.png"), + paramtype = "light", + sunlight_propagates = true, + is_ground_content = true, + groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3}, + sounds = default.node_sound_glass_defaults(), +}) + +minetest.register_node("default:fence_wood", { + description = "Wooden Fence", + drawtype = "fencelike", + tiles = {"default_wood.png"}, + inventory_image = "default_fence.png", + wield_image = "default_fence.png", + paramtype = "light", + is_ground_content = true, + selection_box = { + type = "fixed", + fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, + }, + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:rail", { + description = "Rail", + drawtype = "raillike", + tiles = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"}, + inventory_image = "default_rail.png", + wield_image = "default_rail.png", + paramtype = "light", + is_ground_content = true, + walkable = false, + selection_box = { + type = "fixed", + --fixed = + }, + groups = {bendy=2,snappy=1,dig_immediate=2}, +}) + +minetest.register_node("default:ladder", { + description = "Ladder", + drawtype = "signlike", + tiles = {"default_ladder.png"}, + inventory_image = "default_ladder.png", + wield_image = "default_ladder.png", + paramtype = "light", + paramtype2 = "wallmounted", + is_ground_content = true, + walkable = false, + climbable = true, + selection_box = { + type = "wallmounted", + --wall_top = = + --wall_bottom = = + --wall_side = = + }, + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=3,flammable=2}, + legacy_wallmounted = true, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:wood", { + description = "Wooden Planks", + tiles = {"default_wood.png"}, + is_ground_content = true, + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("default:mese", { + description = "Mese", + tiles = {"default_mese.png"}, + is_ground_content = true, + groups = {cracky=1}, + sounds = default.node_sound_defaults(), +}) + +minetest.register_node("default:cloud", { + description = "Cloud", + tiles = {"default_cloud.png"}, + is_ground_content = true, + sounds = default.node_sound_defaults(), +}) + +minetest.register_node("default:water_flowing", { + description = "Flowing Water", + inventory_image = minetest.inventorycube("default_water.png"), + drawtype = "flowingliquid", + tiles = {"default_water.png"}, + special_tiles = { + {name="default_water.png", backface_culling=false}, + {name="default_water.png", backface_culling=true}, + }, + alpha = WATER_ALPHA, + paramtype = "light", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + liquidtype = "flowing", + liquid_alternative_flowing = "default:water_flowing", + liquid_alternative_source = "default:water_source", + liquid_viscosity = WATER_VISC, + post_effect_color = {a=64, r=100, g=100, b=200}, + groups = {water=3, liquid=3, puts_out_fire=1}, +}) + +minetest.register_node("default:water_source", { + description = "Water Source", + inventory_image = minetest.inventorycube("default_water.png"), + drawtype = "liquid", + tiles = {"default_water.png"}, + special_tiles = { + -- New-style water source material (mostly unused) + {name="default_water.png", backface_culling=false}, + }, + alpha = WATER_ALPHA, + paramtype = "light", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + liquidtype = "source", + liquid_alternative_flowing = "default:water_flowing", + liquid_alternative_source = "default:water_source", + liquid_viscosity = WATER_VISC, + post_effect_color = {a=64, r=100, g=100, b=200}, + groups = {water=3, liquid=3, puts_out_fire=1}, +}) + +minetest.register_node("default:lava_flowing", { + description = "Flowing Lava", + inventory_image = minetest.inventorycube("default_lava.png"), + drawtype = "flowingliquid", + tiles = {"default_lava.png"}, + special_tiles = { + { + image="default_lava_flowing_animated.png", + backface_culling=false, + animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3} + }, + { + image="default_lava_flowing_animated.png", + backface_culling=true, + animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3} + }, + }, + paramtype = "light", + light_source = LIGHT_MAX - 1, + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + liquidtype = "flowing", + liquid_alternative_flowing = "default:lava_flowing", + liquid_alternative_source = "default:lava_source", + liquid_viscosity = LAVA_VISC, + damage_per_second = 4*2, + post_effect_color = {a=192, r=255, g=64, b=0}, + groups = {lava=3, liquid=2, hot=3, igniter=2}, +}) + +minetest.register_node("default:lava_source", { + description = "Lava Source", + inventory_image = minetest.inventorycube("default_lava.png"), + drawtype = "liquid", + tiles = { + {name="default_lava_source_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}} + }, + special_tiles = { + -- New-style lava source material (mostly unused) + {name="default_lava.png", backface_culling=false}, + }, + paramtype = "light", + light_source = LIGHT_MAX - 1, + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + liquidtype = "source", + liquid_alternative_flowing = "default:lava_flowing", + liquid_alternative_source = "default:lava_source", + liquid_viscosity = LAVA_VISC, + damage_per_second = 4*2, + post_effect_color = {a=192, r=255, g=64, b=0}, + groups = {lava=3, liquid=2, hot=3, igniter=2}, +}) + +minetest.register_node("default:torch", { + description = "Torch", + drawtype = "torchlike", + tiles = {"default_torch_on_floor.png", "default_torch_on_ceiling.png", "default_torch.png"}, + inventory_image = "default_torch_on_floor.png", + wield_image = "default_torch_on_floor.png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + walkable = false, + light_source = LIGHT_MAX-1, + selection_box = { + type = "wallmounted", + wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1}, + wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, + wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1}, + }, + groups = {choppy=2,dig_immediate=3,flammable=1}, + legacy_wallmounted = true, + sounds = default.node_sound_defaults(), +}) + +minetest.register_node("default:sign_wall", { + description = "Sign", + drawtype = "signlike", + tiles = {"default_sign_wall.png"}, + inventory_image = "default_sign_wall.png", + wield_image = "default_sign_wall.png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + walkable = false, + metadata_name = "sign", + selection_box = { + type = "wallmounted", + --wall_top = + --wall_bottom = + --wall_side = + }, + groups = {choppy=2,dig_immediate=2}, + legacy_wallmounted = true, + sounds = default.node_sound_defaults(), + on_construct = function(pos) + --local n = minetest.env:get_node(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", "hack:sign_text_input") + meta:set_string("infotext", "\"\"") + end, + on_receive_fields = function(pos, formname, fields, sender) + --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields)) + local meta = minetest.env:get_meta(pos) + fields.text = fields.text or "" + print((sender:get_player_name() or "").." wrote \""..fields.text.. + "\" to sign at "..minetest.pos_to_string(pos)) + meta:set_string("text", fields.text) + meta:set_string("infotext", '"'..fields.text..'"') + end, +}) + +minetest.register_node("default:chest", { + description = "Chest", + tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png", + "default_chest_side.png", "default_chest_side.png", "default_chest_front.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[8,9;]".. + "list[current_name;main;0,0;8,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Chest") + local inv = meta:get_inventory() + inv:set_size("main", 8*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + on_metadata_inventory_move = function(pos, from_list, from_index, + to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_move_allow_all( + pos, from_list, from_index, to_list, to_index, count, player) + end, + on_metadata_inventory_offer = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_offer_allow_all( + pos, listname, index, stack, player) + end, + on_metadata_inventory_take = function(pos, listname, index, count, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_take_allow_all( + pos, listname, index, count, player) + end, +}) + +local function has_locked_chest_privilege(meta, player) + if player:get_player_name() ~= meta:get_string("owner") then + return false + end + return true +end + +minetest.register_node("default:chest_locked", { + description = "Locked Chest", + tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png", + "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + after_place_node = function(pos, placer) + local meta = minetest.env:get_meta(pos) + meta:set_string("owner", placer:get_player_name() or "") + meta:set_string("infotext", "Locked Chest (owned by ".. + meta:get_string("owner")..")") + end, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[8,9;]".. + "list[current_name;main;0,0;8,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Locked Chest") + meta:set_string("owner", "") + local inv = meta:get_inventory() + inv:set_size("main", 8*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + on_metadata_inventory_move = function(pos, from_list, from_index, + to_list, to_index, count, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return + end + minetest.log("action", player:get_player_name().. + " moves stuff in locked chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_move_allow_all( + pos, from_list, from_index, to_list, to_index, count, player) + end, + on_metadata_inventory_offer = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return stack + end + minetest.log("action", player:get_player_name().. + " moves stuff to locked chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_offer_allow_all( + pos, listname, index, stack, player) + end, + on_metadata_inventory_take = function(pos, listname, index, count, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return + end + minetest.log("action", player:get_player_name().. + " takes stuff from locked chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_take_allow_all( + pos, listname, index, count, player) + end, +}) + +default.furnace_inactive_formspec = + "invsize[8,9;]".. + "image[2,2;1,1;default_furnace_fire_bg.png]".. + "list[current_name;fuel;2,3;1,1;]".. + "list[current_name;src;2,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]" + +minetest.register_node("default:furnace", { + description = "Furnace", + tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png", + "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"}, + paramtype2 = "facedir", + groups = {cracky=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_stone_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", default.furnace_inactive_formspec) + meta:set_string("infotext", "Furnace") + local inv = meta:get_inventory() + inv:set_size("fuel", 1) + inv:set_size("src", 1) + inv:set_size("dst", 4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + if not inv:is_empty("fuel") then + return false + elseif not inv:is_empty("dst") then + return false + elseif not inv:is_empty("src") then + return false + end + return true + end, +}) + +minetest.register_node("default:furnace_active", { + description = "Furnace", + tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png", + "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front_active.png"}, + paramtype2 = "facedir", + light_source = 8, + drop = "default:furnace", + groups = {cracky=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_stone_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", default.furnace_inactive_formspec) + meta:set_string("infotext", "Furnace"); + local inv = meta:get_inventory() + inv:set_size("fuel", 1) + inv:set_size("src", 1) + inv:set_size("dst", 4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + if not inv:is_empty("fuel") then + return false + elseif not inv:is_empty("dst") then + return false + elseif not inv:is_empty("src") then + return false + end + return true + end, +}) + +function hacky_swap_node(pos,name) + local node = minetest.env:get_node(pos) + local meta = minetest.env:get_meta(pos) + local meta0 = meta:to_table() + if node.name == name then + return + end + node.name = name + local meta0 = meta:to_table() + minetest.env:set_node(pos,node) + meta = minetest.env:get_meta(pos) + meta:from_table(meta0) +end + +minetest.register_abm({ + nodenames = {"default:furnace","default:furnace_active"}, + interval = 1.0, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local meta = minetest.env:get_meta(pos) + for i, name in ipairs({ + "fuel_totaltime", + "fuel_time", + "src_totaltime", + "src_time" + }) do + if meta:get_string(name) == "" then + meta:set_float(name, 0.0) + end + end + + local inv = meta:get_inventory() + + local srclist = inv:get_list("src") + local cooked = nil + + if srclist then + cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) + end + + local was_active = false + + if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then + was_active = true + meta:set_float("fuel_time", meta:get_float("fuel_time") + 1) + meta:set_float("src_time", meta:get_float("src_time") + 1) + if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then + -- check if there's room for output in "dst" list + if inv:room_for_item("dst",cooked.item) then + -- Put result in "dst" list + inv:add_item("dst", cooked.item) + -- take stuff from "src" list + srcstack = inv:get_stack("src", 1) + srcstack:take_item() + inv:set_stack("src", 1, srcstack) + else + print("Could not insert '"..cooked.item.."'") + end + meta:set_string("src_time", 0) + end + end + + if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then + local percent = math.floor(meta:get_float("fuel_time") / + meta:get_float("fuel_totaltime") * 100) + meta:set_string("infotext","Furnace active: "..percent.."%") + hacky_swap_node(pos,"default:furnace_active") + meta:set_string("formspec", + "invsize[8,9;]".. + "image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:".. + (100-percent)..":default_furnace_fire_fg.png]".. + "list[current_name;fuel;2,3;1,1;]".. + "list[current_name;src;2,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]") + return + end + + local fuel = nil + local cooked = nil + local fuellist = inv:get_list("fuel") + local srclist = inv:get_list("src") + + if srclist then + cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) + end + if fuellist then + fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) + end + + if fuel.time <= 0 then + meta:set_string("infotext","Furnace out of fuel") + hacky_swap_node(pos,"default:furnace") + meta:set_string("formspec", default.furnace_inactive_formspec) + return + end + + if cooked.item:is_empty() then + if was_active then + meta:set_string("infotext","Furnace is empty") + hacky_swap_node(pos,"default:furnace") + meta:set_string("formspec", default.furnace_inactive_formspec) + end + return + end + + meta:set_string("fuel_totaltime", fuel.time) + meta:set_string("fuel_time", 0) + + local stack = inv:get_stack("fuel", 1) + stack:take_item() + inv:set_stack("fuel", 1, stack) + end, +}) + +minetest.register_node("default:cobble", { + description = "Cobblestone", + tiles = {"default_cobble.png"}, + is_ground_content = true, + groups = {cracky=3}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:mossycobble", { + description = "Mossy Cobblestone", + tiles = {"default_mossycobble.png"}, + is_ground_content = true, + groups = {cracky=3}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:steelblock", { + description = "Steel Block", + tiles = {"default_steel_block.png"}, + is_ground_content = true, + groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:nyancat", { + description = "Nyan Cat", + tiles = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png", + "default_nc_side.png", "default_nc_back.png", "default_nc_front.png"}, + inventory_image = "default_nc_front.png", + paramtype2 = "facedir", + groups = {cracky=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_defaults(), +}) + +minetest.register_node("default:nyancat_rainbow", { + description = "Nyan Cat Rainbow", + tiles = {"default_nc_rb.png"}, + inventory_image = "default_nc_rb.png", + groups = {cracky=2}, + sounds = default.node_sound_defaults(), +}) + +minetest.register_node("default:sapling", { + description = "Sapling", + drawtype = "plantlike", + visual_scale = 1.0, + tiles = {"default_sapling.png"}, + inventory_image = "default_sapling.png", + wield_image = "default_sapling.png", + paramtype = "light", + walkable = false, + groups = {snappy=2,dig_immediate=3,flammable=2}, + sounds = default.node_sound_defaults(), +}) + +minetest.register_node("default:apple", { + description = "Apple", + drawtype = "plantlike", + visual_scale = 1.0, + tiles = {"default_apple.png"}, + inventory_image = "default_apple.png", + paramtype = "light", + sunlight_propagates = true, + walkable = false, + groups = {fleshy=3,dig_immediate=3,flammable=2}, + on_use = minetest.item_eat(4), + sounds = default.node_sound_defaults(), +}) + +minetest.register_node("default:dry_shrub", { + description = "Dry Shrub", + drawtype = "plantlike", + visual_scale = 1.0, + tiles = {"default_dry_shrub.png"}, + inventory_image = "default_dry_shrub.png", + wield_image = "default_dry_shrub.png", + paramtype = "light", + walkable = false, + groups = {snappy=3,flammable=3}, + sounds = default.node_sound_leaves_defaults(), + selection_box = { + type = "fixed", + fixed = {-1/3, -1/2, -1/3, 1/3, 1/6, 1/3}, + }, +}) + +-- +-- Crafting items +-- + +minetest.register_craftitem("default:stick", { + description = "Stick", + inventory_image = "default_stick.png", +}) + +minetest.register_craftitem("default:paper", { + description = "Paper", + inventory_image = "default_paper.png", +}) + +minetest.register_craftitem("default:book", { + description = "Book", + inventory_image = "default_book.png", +}) + +minetest.register_craftitem("default:coal_lump", { + description = "Coal Lump", + inventory_image = "default_coal_lump.png", +}) + +minetest.register_craftitem("default:iron_lump", { + description = "Iron Lump", + inventory_image = "default_iron_lump.png", +}) + +minetest.register_craftitem("default:clay_lump", { + description = "Clay Lump", + inventory_image = "default_clay_lump.png", +}) + +minetest.register_craftitem("default:steel_ingot", { + description = "Steel Ingot", + inventory_image = "default_steel_ingot.png", +}) + +minetest.register_craftitem("default:clay_brick", { + description = "Clay Brick", + inventory_image = "default_steel_ingot.png", + inventory_image = "default_clay_brick.png", +}) + +minetest.register_craftitem("default:scorched_stuff", { + description = "Scorched Stuff", + inventory_image = "default_scorched_stuff.png", +}) + +-- +-- Creative inventory +-- + +minetest.add_to_creative_inventory('default:pick_mese') +minetest.add_to_creative_inventory('default:pick_steel') +minetest.add_to_creative_inventory('default:axe_steel') +minetest.add_to_creative_inventory('default:shovel_steel') + +minetest.add_to_creative_inventory('default:torch') +minetest.add_to_creative_inventory('default:cobble') +minetest.add_to_creative_inventory('default:dirt') +minetest.add_to_creative_inventory('default:stone') +minetest.add_to_creative_inventory('default:sand') +minetest.add_to_creative_inventory('default:sandstone') +minetest.add_to_creative_inventory('default:clay') +minetest.add_to_creative_inventory('default:brick') +minetest.add_to_creative_inventory('default:tree') +minetest.add_to_creative_inventory('default:wood') +minetest.add_to_creative_inventory('default:leaves') +minetest.add_to_creative_inventory('default:cactus') +minetest.add_to_creative_inventory('default:papyrus') +minetest.add_to_creative_inventory('default:bookshelf') +minetest.add_to_creative_inventory('default:glass') +minetest.add_to_creative_inventory('default:fence_wood') +minetest.add_to_creative_inventory('default:rail') +minetest.add_to_creative_inventory('default:mese') +minetest.add_to_creative_inventory('default:chest') +minetest.add_to_creative_inventory('default:furnace') +minetest.add_to_creative_inventory('default:sign_wall') +minetest.add_to_creative_inventory('default:water_source') +minetest.add_to_creative_inventory('default:lava_source') +minetest.add_to_creative_inventory('default:ladder') + +-- +-- Falling stuff +-- + +minetest.register_entity("default:falling_node", { + initial_properties = { + physical = true, + collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, + visual = "wielditem", + textures = {}, + visual_size = {x=0.667, y=0.667}, + }, + + nodename = "", + + set_node = function(self, nodename) + self.nodename = nodename + local stack = ItemStack(nodename) + local itemtable = stack:to_table() + local itemname = nil + if itemtable then + itemname = stack:to_table().name + end + local item_texture = nil + local item_type = "" + if minetest.registered_items[itemname] then + item_texture = minetest.registered_items[itemname].inventory_image + item_type = minetest.registered_items[itemname].type + end + prop = { + is_visible = true, + textures = {nodename}, + } + self.object:set_properties(prop) + end, + + get_staticdata = function(self) + return self.nodename + end, + + on_activate = function(self, staticdata) + self.nodename = staticdata + self.object:set_armor_groups({immortal=1}) + --self.object:setacceleration({x=0, y=-10, z=0}) + self:set_node(self.nodename) + end, + + on_step = function(self, dtime) + -- Set gravity + self.object:setacceleration({x=0, y=-10, z=0}) + -- Turn to actual sand when collides to ground or just move + local pos = self.object:getpos() + local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point + local bcn = minetest.env:get_node(bcp) + -- Note: walkable is in the node definition, not in item groups + if minetest.registered_nodes[bcn.name] and + minetest.registered_nodes[bcn.name].walkable then + local np = {x=bcp.x, y=bcp.y+1, z=bcp.z} + -- Check what's here + local n2 = minetest.env:get_node(np) + -- If it's not air or liquid, remove node and replace it with + -- it's drops + if n2.name ~= "air" and (not minetest.registered_nodes[n2.name] or + minetest.registered_nodes[n2.name].liquidtype == "none") then + local drops = minetest.get_node_drops(n2.name, "") + minetest.env:remove_node(np) + -- Add dropped items + local _, dropped_item + for _, dropped_item in ipairs(drops) do + minetest.env:add_item(np, dropped_item) + end + -- Run script hook + local _, callback + for _, callback in ipairs(minetest.registered_on_dignodes) do + callback(np, n2, nil) + end + end + -- Create node and remove entity + minetest.env:add_node(np, {name=self.nodename}) + self.object:remove() + else + -- Do nothing + end + end +}) + +function default.spawn_falling_node(p, nodename) + obj = minetest.env:add_entity(p, "default:falling_node") + obj:get_luaentity():set_node(nodename) +end + +-- Horrible crap to support old code +-- Don't use this and never do what this does, it's completely wrong! +-- (More specifically, the client and the C++ code doesn't get the group) +function default.register_falling_node(nodename, texture) + minetest.log("error", debug.traceback()) + minetest.log('error', "WARNING: default.register_falling_node is deprecated") + if minetest.registered_nodes[nodename] then + minetest.registered_nodes[nodename].groups.falling_node = 1 + end +end + +-- +-- Some common functions +-- + +function nodeupdate_single(p) + n = minetest.env:get_node(p) + if minetest.get_node_group(n.name, "falling_node") ~= 0 then + p_bottom = {x=p.x, y=p.y-1, z=p.z} + n_bottom = minetest.env:get_node(p_bottom) + -- Note: walkable is in the node definition, not in item groups + if minetest.registered_nodes[n_bottom.name] and + not minetest.registered_nodes[n_bottom.name].walkable then + minetest.env:remove_node(p) + default.spawn_falling_node(p, n.name) + nodeupdate(p) + end + end +end + +function nodeupdate(p) + for x = -1,1 do + for y = -1,1 do + for z = -1,1 do + p2 = {x=p.x+x, y=p.y+y, z=p.z+z} + nodeupdate_single(p2) + end + end + end +end + +-- +-- Global callbacks +-- + +-- Global environment step function +function on_step(dtime) + -- print("on_step") +end +minetest.register_globalstep(on_step) + +function on_placenode(p, node) + --print("on_placenode") + nodeupdate(p) +end +minetest.register_on_placenode(on_placenode) + +function on_dignode(p, node) + --print("on_dignode") + nodeupdate(p) +end +minetest.register_on_dignode(on_dignode) + +function on_punchnode(p, node) +end +minetest.register_on_punchnode(on_punchnode) + +local function handle_give_command(cmd, giver, receiver, stackstring) + if not minetest.get_player_privs(giver)["give"] then + minetest.chat_send_player(giver, "error: you don't have permission to give") + return + end + minetest.debug("DEBUG: "..cmd..' invoked, stackstring="'..stackstring..'"') + minetest.log(cmd..' invoked, stackstring="'..stackstring..'"') + local itemstack = ItemStack(stackstring) + if itemstack:is_empty() then + minetest.chat_send_player(giver, 'error: cannot give an empty item') + return + elseif not itemstack:is_known() then + minetest.chat_send_player(giver, 'error: cannot give an unknown item') + return + end + local receiverref = minetest.env:get_player_by_name(receiver) + if receiverref == nil then + minetest.chat_send_player(giver, receiver..' is not a known player') + return + end + local leftover = receiverref:get_inventory():add_item("main", itemstack) + if leftover:is_empty() then + partiality = "" + elseif leftover:get_count() == itemstack:get_count() then + partiality = "could not be " + else + partiality = "partially " + end + -- The actual item stack string may be different from what the "giver" + -- entered (e.g. big numbers are always interpreted as 2^16-1). + stackstring = itemstack:to_string() + if giver == receiver then + minetest.chat_send_player(giver, '"'..stackstring + ..'" '..partiality..'added to inventory.'); + else + minetest.chat_send_player(giver, '"'..stackstring + ..'" '..partiality..'added to '..receiver..'\'s inventory.'); + minetest.chat_send_player(receiver, '"'..stackstring + ..'" '..partiality..'added to inventory.'); + end +end + +minetest.register_on_chat_message(function(name, message) + --print("default on_chat_message: name="..dump(name).." message="..dump(message)) + local cmd = "/giveme" + if message:sub(0, #cmd) == cmd then + local stackstring = string.match(message, cmd.." (.*)") + if stackstring == nil then + minetest.chat_send_player(name, 'usage: '..cmd..' stackstring') + return true -- Handled chat message + end + handle_give_command(cmd, name, name, stackstring) + return true + end + local cmd = "/give" + if message:sub(0, #cmd) == cmd then + local receiver, stackstring = string.match(message, cmd.." ([%a%d_-]+) (.*)") + if receiver == nil or stackstring == nil then + minetest.chat_send_player(name, 'usage: '..cmd..' name stackstring') + return true -- Handled chat message + end + handle_give_command(cmd, name, receiver, stackstring) + return true + end + local cmd = "/spawnentity" + if message:sub(0, #cmd) == cmd then + if not minetest.get_player_privs(name)["give"] then + minetest.chat_send_player(name, "you don't have permission to spawn (give)") + return true -- Handled chat message + end + if not minetest.get_player_privs(name)["interact"] then + minetest.chat_send_player(name, "you don't have permission to interact") + return true -- Handled chat message + end + local entityname = string.match(message, cmd.." (.*)") + if entityname == nil then + minetest.chat_send_player(name, 'usage: '..cmd..' entityname') + return true -- Handled chat message + end + print(cmd..' invoked, entityname="'..entityname..'"') + local player = minetest.env:get_player_by_name(name) + if player == nil then + print("Unable to spawn entity, player is nil") + return true -- Handled chat message + end + local p = player:getpos() + p.y = p.y + 1 + minetest.env:add_entity(p, entityname) + minetest.chat_send_player(name, '"'..entityname + ..'" spawned.'); + return true -- Handled chat message + end + local cmd = "/pulverize" + if message:sub(0, #cmd) == cmd then + local player = minetest.env:get_player_by_name(name) + if player == nil then + print("Unable to pulverize, player is nil") + return true -- Handled chat message + end + if player:get_wielded_item():is_empty() then + minetest.chat_send_player(name, 'Unable to pulverize, no item in hand.') + else + player:set_wielded_item(nil) + minetest.chat_send_player(name, 'An item was pulverized.') + end + return true + end +end) + +-- END diff --git a/games/minitest/mods/default/leafdecay.lua b/games/minitest/mods/default/leafdecay.lua new file mode 100644 index 0000000..8f4ff97 --- /dev/null +++ b/games/minitest/mods/default/leafdecay.lua @@ -0,0 +1,92 @@ +-- minetest/default/leafdecay.lua + +-- To enable leaf decay for a node, add it to the "leafdecay" group. +-- +-- The rating of the group determines how far from a node in the group "tree" +-- the node can be without decaying. +-- +-- If param2 of the node is ~= 0, the node will always be preserved. Thus, if +-- the player places a node of that kind, you will want to set param2=1 or so. + +default.leafdecay_trunk_cache = {} +default.leafdecay_enable_cache = true +-- Spread the load of finding trunks +default.leafdecay_trunk_find_allow_accumulator = 0 + +minetest.register_globalstep(function(dtime) + local finds_per_second = 5000 + default.leafdecay_trunk_find_allow_accumulator = + math.floor(dtime * finds_per_second) +end) + +minetest.register_abm({ + nodenames = {"group:leafdecay"}, + neighbors = {"air", "group:liquid"}, + -- A low interval and a high inverse chance spreads the load + interval = 2, + chance = 5, + + action = function(p0, node, _, _) + --print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")") + local do_preserve = false + local d = minetest.registered_nodes[node.name].groups.leafdecay + if not d or d == 0 then + --print("not groups.leafdecay") + return + end + local n0 = minetest.env:get_node(p0) + if n0.param2 ~= 0 then + --print("param2 ~= 0") + return + end + local p0_hash = nil + if default.leafdecay_enable_cache then + p0_hash = minetest.hash_node_position(p0) + local trunkp = default.leafdecay_trunk_cache[p0_hash] + if trunkp then + local n = minetest.env:get_node(trunkp) + local reg = minetest.registered_nodes[n.name] + -- Assume ignore is a trunk, to make the thing work at the border of the active area + if n.name == "ignore" or (reg.groups.tree and reg.groups.tree ~= 0) then + --print("cached trunk still exists") + return + end + --print("cached trunk is invalid") + -- Cache is invalid + table.remove(default.leafdecay_trunk_cache, p0_hash) + end + end + if default.leafdecay_trunk_find_allow_accumulator <= 0 then + return + end + default.leafdecay_trunk_find_allow_accumulator = + default.leafdecay_trunk_find_allow_accumulator - 1 + -- Assume ignore is a trunk, to make the thing work at the border of the active area + local p1 = minetest.env:find_node_near(p0, d, {"ignore", "group:tree"}) + if p1 then + do_preserve = true + if default.leafdecay_enable_cache then + --print("caching trunk") + -- Cache the trunk + default.leafdecay_trunk_cache[p0_hash] = p1 + end + end + if not do_preserve then + -- Drop stuff other than the node itself + itemstacks = minetest.get_node_drops(n0.name) + for _, itemname in ipairs(itemstacks) do + if itemname ~= n0.name then + local p_drop = { + x = p0.x - 0.5 + math.random(), + y = p0.y - 0.5 + math.random(), + z = p0.z - 0.5 + math.random(), + } + minetest.env:add_item(p_drop, itemname) + end + end + -- Remove node + minetest.env:remove_node(p0) + end + end +}) + diff --git a/games/minitest/mods/default/mapgen.lua b/games/minitest/mods/default/mapgen.lua new file mode 100644 index 0000000..35fc065 --- /dev/null +++ b/games/minitest/mods/default/mapgen.lua @@ -0,0 +1,275 @@ +-- minetest/default/mapgen.lua + +-- +-- Aliases for map generator outputs +-- + +minetest.register_alias("mapgen_air", "air") +minetest.register_alias("mapgen_stone", "default:stone") +minetest.register_alias("mapgen_tree", "default:tree") +minetest.register_alias("mapgen_leaves", "default:leaves") +minetest.register_alias("mapgen_apple", "default:apple") +minetest.register_alias("mapgen_water_source", "default:water_source") +minetest.register_alias("mapgen_dirt", "default:dirt") +minetest.register_alias("mapgen_sand", "default:sand") +minetest.register_alias("mapgen_gravel", "default:gravel") +minetest.register_alias("mapgen_clay", "default:clay") +minetest.register_alias("mapgen_lava_source", "default:lava_source") +minetest.register_alias("mapgen_cobble", "default:cobble") +minetest.register_alias("mapgen_mossycobble", "default:mossycobble") +minetest.register_alias("mapgen_dirt_with_grass", "default:dirt_with_grass") +minetest.register_alias("mapgen_junglegrass", "default:junglegrass") +minetest.register_alias("mapgen_stone_with_coal", "default:stone_with_coal") +minetest.register_alias("mapgen_stone_with_iron", "default:stone_with_iron") +minetest.register_alias("mapgen_mese", "default:mese") +minetest.register_alias("mapgen_desert_sand", "default:desert_sand") +minetest.register_alias("mapgen_desert_stone", "default:desert_stone") + +-- +-- Ore generation +-- + +local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max) + if maxp.y < height_min or minp.y > height_max then + return + end + local y_min = math.max(minp.y, height_min) + local y_max = math.min(maxp.y, height_max) + local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1) + local pr = PseudoRandom(seed) + local num_chunks = math.floor(chunks_per_volume * volume) + local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk) + --print("generate_ore num_chunks: "..dump(num_chunks)) + for i=1,num_chunks do + local y0 = pr:next(y_min, y_max-chunk_size+1) + if y0 >= height_min and y0 <= height_max then + local x0 = pr:next(minp.x, maxp.x-chunk_size+1) + local z0 = pr:next(minp.z, maxp.z-chunk_size+1) + local p0 = {x=x0, y=y0, z=z0} + for x1=0,chunk_size-1 do + for y1=0,chunk_size-1 do + for z1=0,chunk_size-1 do + if pr:next(1,inverse_chance) == 1 then + local x2 = x0+x1 + local y2 = y0+y1 + local z2 = z0+z1 + local p2 = {x=x2, y=y2, z=z2} + if minetest.env:get_node(p2).name == wherein then + minetest.env:set_node(p2, {name=name}) + end + end + end + end + end + end + end + --print("generate_ore done") +end + +function default.make_papyrus(pos, size) + for y=0,size-1 do + local p = {x=pos.x, y=pos.y+y, z=pos.z} + minetest.env:set_node(p, {name="default:papyrus"}) + end +end + +function default.make_cactus(pos, size) + for y=0,size-1 do + local p = {x=pos.x, y=pos.y+y, z=pos.z} + minetest.env:set_node(p, {name="default:cactus"}) + end +end + +-- facedir: 0/1/2/3 (head node facedir value) +-- length: length of rainbow tail +function default.make_nyancat(pos, facedir, length) + local tailvec = {x=0, y=0, z=0} + if facedir == 0 then + tailvec.z = 1 + elseif facedir == 1 then + tailvec.x = 1 + elseif facedir == 2 then + tailvec.z = -1 + elseif facedir == 3 then + tailvec.x = -1 + else + print("default.make_nyancat(): Invalid facedir: "+dump(facedir)) + facedir = 0 + tailvec.z = 1 + end + local p = {x=pos.x, y=pos.y, z=pos.z} + minetest.env:set_node(p, {name="default:nyancat", param2=facedir}) + for i=1,length do + p.x = p.x + tailvec.x + p.z = p.z + tailvec.z + minetest.env:set_node(p, {name="default:nyancat_rainbow"}) + end +end + +function generate_nyancats(seed, minp, maxp) + local height_min = -31000 + local height_max = -32 + if maxp.y < height_min or minp.y > height_max then + return + end + local y_min = math.max(minp.y, height_min) + local y_max = math.min(maxp.y, height_max) + local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1) + local pr = PseudoRandom(seed + 9324342) + local max_num_nyancats = math.floor(volume / (16*16*16)) + for i=1,max_num_nyancats do + if pr:next(0, 1000) == 0 then + local x0 = pr:next(minp.x, maxp.x) + local y0 = pr:next(minp.y, maxp.y) + local z0 = pr:next(minp.z, maxp.z) + local p0 = {x=x0, y=y0, z=z0} + default.make_nyancat(p0, pr:next(0,3), pr:next(3,15)) + end + end +end + +minetest.register_on_generated(function(minp, maxp, seed) + -- Generate regular ores + generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+0, 1/8/8/8, 3, 8, -31000, 64) + generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/12/12/12, 2, 3, -15, 2) + generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/9/9/9, 3, 5, -63, -16) + generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/7/7/7, 3, 5, -31000, -64) + generate_ore("default:mese", "default:stone", minp, maxp, seed+4, 1/16/16/16, 2, 3, -127, -64) + generate_ore("default:mese", "default:stone", minp, maxp, seed+5, 1/9/9/9, 3, 5, -31000,-128) + + generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+7, 1/24/24/24, 6,27, -31000, 0) + generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+6, 1/24/24/24, 6,27, -31000, -64) + + if maxp.y >= 2 and minp.y <= 0 then + -- Generate clay + -- Assume X and Z lengths are equal + local divlen = 4 + local divs = (maxp.x-minp.x)/divlen+1; + for divx=0+1,divs-1-1 do + for divz=0+1,divs-1-1 do + local cx = minp.x + math.floor((divx+0.5)*divlen) + local cz = minp.z + math.floor((divz+0.5)*divlen) + if minetest.env:get_node({x=cx,y=1,z=cz}).name == "default:water_source" and + minetest.env:get_node({x=cx,y=0,z=cz}).name == "default:sand" then + local is_shallow = true + local num_water_around = 0 + if minetest.env:get_node({x=cx-divlen*2,y=1,z=cz+0}).name == "default:water_source" then + num_water_around = num_water_around + 1 end + if minetest.env:get_node({x=cx+divlen*2,y=1,z=cz+0}).name == "default:water_source" then + num_water_around = num_water_around + 1 end + if minetest.env:get_node({x=cx+0,y=1,z=cz-divlen*2}).name == "default:water_source" then + num_water_around = num_water_around + 1 end + if minetest.env:get_node({x=cx+0,y=1,z=cz+divlen*2}).name == "default:water_source" then + num_water_around = num_water_around + 1 end + if num_water_around >= 2 then + is_shallow = false + end + if is_shallow then + for x1=-divlen,divlen do + for z1=-divlen,divlen do + if minetest.env:get_node({x=cx+x1,y=0,z=cz+z1}).name == "default:sand" then + minetest.env:set_node({x=cx+x1,y=0,z=cz+z1}, {name="default:clay"}) + end + end + end + end + end + end + end + -- Generate papyrus + local perlin1 = minetest.env:get_perlin(354, 3, 0.7, 100) + -- Assume X and Z lengths are equal + local divlen = 8 + local divs = (maxp.x-minp.x)/divlen+1; + for divx=0,divs-1 do + for divz=0,divs-1 do + local x0 = minp.x + math.floor((divx+0)*divlen) + local z0 = minp.z + math.floor((divz+0)*divlen) + local x1 = minp.x + math.floor((divx+1)*divlen) + local z1 = minp.z + math.floor((divz+1)*divlen) + -- Determine papyrus amount from perlin noise + local papyrus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 45 - 20) + -- Find random positions for papyrus based on this random + local pr = PseudoRandom(seed+1) + for i=0,papyrus_amount do + local x = pr:next(x0, x1) + local z = pr:next(z0, z1) + if minetest.env:get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and + minetest.env:find_node_near({x=x,y=1,z=z}, 1, "default:water_source") then + default.make_papyrus({x=x,y=2,z=z}, pr:next(2, 4)) + end + end + end + end + -- Generate cactuses + local perlin1 = minetest.env:get_perlin(230, 3, 0.6, 100) + -- Assume X and Z lengths are equal + local divlen = 16 + local divs = (maxp.x-minp.x)/divlen+1; + for divx=0,divs-1 do + for divz=0,divs-1 do + local x0 = minp.x + math.floor((divx+0)*divlen) + local z0 = minp.z + math.floor((divz+0)*divlen) + local x1 = minp.x + math.floor((divx+1)*divlen) + local z1 = minp.z + math.floor((divz+1)*divlen) + -- Determine cactus amount from perlin noise + local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 6 - 3) + -- Find random positions for cactus based on this random + local pr = PseudoRandom(seed+1) + for i=0,cactus_amount do + local x = pr:next(x0, x1) + local z = pr:next(z0, z1) + -- Find ground level (0...15) + local ground_y = nil + for y=30,0,-1 do + if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then + ground_y = y + break + end + end + -- If desert sand, make cactus + if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then + default.make_cactus({x=x,y=ground_y+1,z=z}, pr:next(3, 4)) + end + end + end + end + -- Generate dry shrubs + local perlin1 = minetest.env:get_perlin(329, 3, 0.6, 100) + -- Assume X and Z lengths are equal + local divlen = 16 + local divs = (maxp.x-minp.x)/divlen+1; + for divx=0,divs-1 do + for divz=0,divs-1 do + local x0 = minp.x + math.floor((divx+0)*divlen) + local z0 = minp.z + math.floor((divz+0)*divlen) + local x1 = minp.x + math.floor((divx+1)*divlen) + local z1 = minp.z + math.floor((divz+1)*divlen) + -- Determine cactus amount from perlin noise + local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 5 + 0) + -- Find random positions for cactus based on this random + local pr = PseudoRandom(seed+1) + for i=0,cactus_amount do + local x = pr:next(x0, x1) + local z = pr:next(z0, z1) + -- Find ground level (0...15) + local ground_y = nil + for y=30,0,-1 do + if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then + ground_y = y + break + end + end + -- If desert sand, make cactus + if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then + minetest.env:set_node({x=x,y=ground_y+1,z=z}, {name="default:dry_shrub"}) + end + end + end + end + end + + -- Generate nyan cats + generate_nyancats(seed, minp, maxp) +end) + diff --git a/games/minitest/mods/default/sounds/default_dig_choppy.ogg b/games/minitest/mods/default/sounds/default_dig_choppy.ogg new file mode 100644 index 0000000..d605145 Binary files /dev/null and b/games/minitest/mods/default/sounds/default_dig_choppy.ogg differ diff --git a/games/minitest/mods/default/sounds/default_dig_cracky.ogg b/games/minitest/mods/default/sounds/default_dig_cracky.ogg new file mode 100644 index 0000000..53d45c1 Binary files /dev/null and b/games/minitest/mods/default/sounds/default_dig_cracky.ogg differ diff --git a/games/minitest/mods/default/sounds/default_dig_crumbly.1.ogg b/games/minitest/mods/default/sounds/default_dig_crumbly.1.ogg new file mode 100644 index 0000000..ea5830a Binary files /dev/null and b/games/minitest/mods/default/sounds/default_dig_crumbly.1.ogg differ diff --git a/games/minitest/mods/default/sounds/default_dig_crumbly.2.ogg b/games/minitest/mods/default/sounds/default_dig_crumbly.2.ogg new file mode 100644 index 0000000..f1a9248 Binary files /dev/null and b/games/minitest/mods/default/sounds/default_dig_crumbly.2.ogg differ diff --git a/games/minitest/mods/default/sounds/default_dig_dig_immediate.ogg b/games/minitest/mods/default/sounds/default_dig_dig_immediate.ogg new file mode 100644 index 0000000..526629b Binary files /dev/null and b/games/minitest/mods/default/sounds/default_dig_dig_immediate.ogg differ diff --git a/games/minitest/mods/default/sounds/default_dig_oddly_breakable_by_hand.ogg b/games/minitest/mods/default/sounds/default_dig_oddly_breakable_by_hand.ogg new file mode 100644 index 0000000..d605145 Binary files /dev/null and b/games/minitest/mods/default/sounds/default_dig_oddly_breakable_by_hand.ogg differ diff --git a/games/minitest/mods/default/sounds/default_dug_node.1.ogg b/games/minitest/mods/default/sounds/default_dug_node.1.ogg new file mode 100644 index 0000000..9d56bb8 Binary files /dev/null and b/games/minitest/mods/default/sounds/default_dug_node.1.ogg differ diff --git a/games/minitest/mods/default/sounds/default_grass_footstep.1.ogg b/games/minitest/mods/default/sounds/default_grass_footstep.1.ogg new file mode 100644 index 0000000..ce625d9 Binary files /dev/null and b/games/minitest/mods/default/sounds/default_grass_footstep.1.ogg differ diff --git a/games/minitest/mods/default/sounds/default_grass_footstep.2.ogg b/games/minitest/mods/default/sounds/default_grass_footstep.2.ogg new file mode 100644 index 0000000..330ca47 Binary files /dev/null and b/games/minitest/mods/default/sounds/default_grass_footstep.2.ogg differ diff --git a/games/minitest/mods/default/sounds/default_grass_footstep.3.ogg b/games/minitest/mods/default/sounds/default_grass_footstep.3.ogg new file mode 100644 index 0000000..07acc1e Binary files /dev/null and b/games/minitest/mods/default/sounds/default_grass_footstep.3.ogg differ diff --git a/games/minitest/mods/default/sounds/default_gravel_footstep.1.ogg b/games/minitest/mods/default/sounds/default_gravel_footstep.1.ogg new file mode 100644 index 0000000..68758b2 Binary files /dev/null and b/games/minitest/mods/default/sounds/default_gravel_footstep.1.ogg differ diff --git a/games/minitest/mods/default/sounds/default_gravel_footstep.2.ogg b/games/minitest/mods/default/sounds/default_gravel_footstep.2.ogg new file mode 100644 index 0000000..128ae57 Binary files /dev/null and b/games/minitest/mods/default/sounds/default_gravel_footstep.2.ogg differ diff --git a/games/minitest/mods/default/sounds/default_gravel_footstep.3.ogg b/games/minitest/mods/default/sounds/default_gravel_footstep.3.ogg new file mode 100644 index 0000000..7a5863f Binary files /dev/null and b/games/minitest/mods/default/sounds/default_gravel_footstep.3.ogg differ diff --git a/games/minitest/mods/default/sounds/default_gravel_footstep.4.ogg b/games/minitest/mods/default/sounds/default_gravel_footstep.4.ogg new file mode 100644 index 0000000..8cdadb1 Binary files /dev/null and b/games/minitest/mods/default/sounds/default_gravel_footstep.4.ogg differ diff --git a/games/minitest/mods/default/sounds/default_hard_footstep.1.ogg b/games/minitest/mods/default/sounds/default_hard_footstep.1.ogg new file mode 100644 index 0000000..6b351ff Binary files /dev/null and b/games/minitest/mods/default/sounds/default_hard_footstep.1.ogg differ diff --git a/games/minitest/mods/default/sounds/default_hard_footstep.2.ogg b/games/minitest/mods/default/sounds/default_hard_footstep.2.ogg new file mode 100644 index 0000000..2ce721e Binary files /dev/null and b/games/minitest/mods/default/sounds/default_hard_footstep.2.ogg differ diff --git a/games/minitest/mods/default/sounds/default_place_node.1.ogg b/games/minitest/mods/default/sounds/default_place_node.1.ogg new file mode 100644 index 0000000..526629b Binary files /dev/null and b/games/minitest/mods/default/sounds/default_place_node.1.ogg differ diff --git a/games/minitest/mods/default/sounds/default_place_node.2.ogg b/games/minitest/mods/default/sounds/default_place_node.2.ogg new file mode 100644 index 0000000..012c667 Binary files /dev/null and b/games/minitest/mods/default/sounds/default_place_node.2.ogg differ diff --git a/games/minitest/mods/default/sounds/default_place_node.3.ogg b/games/minitest/mods/default/sounds/default_place_node.3.ogg new file mode 100644 index 0000000..eaf9719 Binary files /dev/null and b/games/minitest/mods/default/sounds/default_place_node.3.ogg differ diff --git a/games/minitest/mods/default/textures/Thumbs.db b/games/minitest/mods/default/textures/Thumbs.db new file mode 100644 index 0000000..c4c6866 Binary files /dev/null and b/games/minitest/mods/default/textures/Thumbs.db differ diff --git a/games/minitest/mods/default/textures/crack_anylength.png b/games/minitest/mods/default/textures/crack_anylength.png new file mode 100644 index 0000000..2a6747f Binary files /dev/null and b/games/minitest/mods/default/textures/crack_anylength.png differ diff --git a/games/minitest/mods/default/textures/default_apple.png b/games/minitest/mods/default/textures/default_apple.png new file mode 100644 index 0000000..435e0f2 Binary files /dev/null and b/games/minitest/mods/default/textures/default_apple.png differ diff --git a/games/minitest/mods/default/textures/default_book.png b/games/minitest/mods/default/textures/default_book.png new file mode 100644 index 0000000..199064b Binary files /dev/null and b/games/minitest/mods/default/textures/default_book.png differ diff --git a/games/minitest/mods/default/textures/default_bookshelf.png b/games/minitest/mods/default/textures/default_bookshelf.png new file mode 100644 index 0000000..14dc69b Binary files /dev/null and b/games/minitest/mods/default/textures/default_bookshelf.png differ diff --git a/games/minitest/mods/default/textures/default_brick.png b/games/minitest/mods/default/textures/default_brick.png new file mode 100644 index 0000000..83e2d01 Binary files /dev/null and b/games/minitest/mods/default/textures/default_brick.png differ diff --git a/games/minitest/mods/default/textures/default_cactus_side.png b/games/minitest/mods/default/textures/default_cactus_side.png new file mode 100644 index 0000000..7663877 Binary files /dev/null and b/games/minitest/mods/default/textures/default_cactus_side.png differ diff --git a/games/minitest/mods/default/textures/default_cactus_top.png b/games/minitest/mods/default/textures/default_cactus_top.png new file mode 100644 index 0000000..5660e41 Binary files /dev/null and b/games/minitest/mods/default/textures/default_cactus_top.png differ diff --git a/games/minitest/mods/default/textures/default_chest_front.png b/games/minitest/mods/default/textures/default_chest_front.png new file mode 100644 index 0000000..ac0bd96 Binary files /dev/null and b/games/minitest/mods/default/textures/default_chest_front.png differ diff --git a/games/minitest/mods/default/textures/default_chest_lock.png b/games/minitest/mods/default/textures/default_chest_lock.png new file mode 100644 index 0000000..ac0bd96 Binary files /dev/null and b/games/minitest/mods/default/textures/default_chest_lock.png differ diff --git a/games/minitest/mods/default/textures/default_chest_side.png b/games/minitest/mods/default/textures/default_chest_side.png new file mode 100644 index 0000000..944cdab Binary files /dev/null and b/games/minitest/mods/default/textures/default_chest_side.png differ diff --git a/games/minitest/mods/default/textures/default_chest_top.png b/games/minitest/mods/default/textures/default_chest_top.png new file mode 100644 index 0000000..c1a23ef Binary files /dev/null and b/games/minitest/mods/default/textures/default_chest_top.png differ diff --git a/games/minitest/mods/default/textures/default_clay.png b/games/minitest/mods/default/textures/default_clay.png new file mode 100644 index 0000000..1c73854 Binary files /dev/null and b/games/minitest/mods/default/textures/default_clay.png differ diff --git a/games/minitest/mods/default/textures/default_clay_brick.png b/games/minitest/mods/default/textures/default_clay_brick.png new file mode 100644 index 0000000..30e08d2 Binary files /dev/null and b/games/minitest/mods/default/textures/default_clay_brick.png differ diff --git a/games/minitest/mods/default/textures/default_clay_lump.png b/games/minitest/mods/default/textures/default_clay_lump.png new file mode 100644 index 0000000..7410201 Binary files /dev/null and b/games/minitest/mods/default/textures/default_clay_lump.png differ diff --git a/games/minitest/mods/default/textures/default_cloud.png b/games/minitest/mods/default/textures/default_cloud.png new file mode 100644 index 0000000..24091a3 Binary files /dev/null and b/games/minitest/mods/default/textures/default_cloud.png differ diff --git a/games/minitest/mods/default/textures/default_coal_lump.png b/games/minitest/mods/default/textures/default_coal_lump.png new file mode 100644 index 0000000..82dc3ea Binary files /dev/null and b/games/minitest/mods/default/textures/default_coal_lump.png differ diff --git a/games/minitest/mods/default/textures/default_cobble.png b/games/minitest/mods/default/textures/default_cobble.png new file mode 100644 index 0000000..4d9cfa6 Binary files /dev/null and b/games/minitest/mods/default/textures/default_cobble.png differ diff --git a/games/minitest/mods/default/textures/default_cooked_rat.png b/games/minitest/mods/default/textures/default_cooked_rat.png new file mode 100644 index 0000000..fda8e4a Binary files /dev/null and b/games/minitest/mods/default/textures/default_cooked_rat.png differ diff --git a/games/minitest/mods/default/textures/default_desert_sand.png b/games/minitest/mods/default/textures/default_desert_sand.png new file mode 100644 index 0000000..9e36263 Binary files /dev/null and b/games/minitest/mods/default/textures/default_desert_sand.png differ diff --git a/games/minitest/mods/default/textures/default_desert_stone.png b/games/minitest/mods/default/textures/default_desert_stone.png new file mode 100644 index 0000000..a1afe6d Binary files /dev/null and b/games/minitest/mods/default/textures/default_desert_stone.png differ diff --git a/games/minitest/mods/default/textures/default_dirt.png b/games/minitest/mods/default/textures/default_dirt.png new file mode 100644 index 0000000..c1b0f3d Binary files /dev/null and b/games/minitest/mods/default/textures/default_dirt.png differ diff --git a/games/minitest/mods/default/textures/default_dry_shrub.png b/games/minitest/mods/default/textures/default_dry_shrub.png new file mode 100644 index 0000000..450d5d9 Binary files /dev/null and b/games/minitest/mods/default/textures/default_dry_shrub.png differ diff --git a/games/minitest/mods/default/textures/default_dungeon_master.png b/games/minitest/mods/default/textures/default_dungeon_master.png new file mode 100644 index 0000000..1549a59 Binary files /dev/null and b/games/minitest/mods/default/textures/default_dungeon_master.png differ diff --git a/games/minitest/mods/default/textures/default_fence.png b/games/minitest/mods/default/textures/default_fence.png new file mode 100644 index 0000000..e05bb51 Binary files /dev/null and b/games/minitest/mods/default/textures/default_fence.png differ diff --git a/games/minitest/mods/default/textures/default_fireball.png b/games/minitest/mods/default/textures/default_fireball.png new file mode 100644 index 0000000..c446a67 Binary files /dev/null and b/games/minitest/mods/default/textures/default_fireball.png differ diff --git a/games/minitest/mods/default/textures/default_firefly.png b/games/minitest/mods/default/textures/default_firefly.png new file mode 100644 index 0000000..40df7fa Binary files /dev/null and b/games/minitest/mods/default/textures/default_firefly.png differ diff --git a/games/minitest/mods/default/textures/default_furnace_bottom.png b/games/minitest/mods/default/textures/default_furnace_bottom.png new file mode 100644 index 0000000..f527075 Binary files /dev/null and b/games/minitest/mods/default/textures/default_furnace_bottom.png differ diff --git a/games/minitest/mods/default/textures/default_furnace_fire_bg.png b/games/minitest/mods/default/textures/default_furnace_fire_bg.png new file mode 100644 index 0000000..1272e10 Binary files /dev/null and b/games/minitest/mods/default/textures/default_furnace_fire_bg.png differ diff --git a/games/minitest/mods/default/textures/default_furnace_fire_fg.png b/games/minitest/mods/default/textures/default_furnace_fire_fg.png new file mode 100644 index 0000000..fbb19df Binary files /dev/null and b/games/minitest/mods/default/textures/default_furnace_fire_fg.png differ diff --git a/games/minitest/mods/default/textures/default_furnace_front.png b/games/minitest/mods/default/textures/default_furnace_front.png new file mode 100644 index 0000000..f9887e0 Binary files /dev/null and b/games/minitest/mods/default/textures/default_furnace_front.png differ diff --git a/games/minitest/mods/default/textures/default_furnace_front_active.png b/games/minitest/mods/default/textures/default_furnace_front_active.png new file mode 100644 index 0000000..5effb1e Binary files /dev/null and b/games/minitest/mods/default/textures/default_furnace_front_active.png differ diff --git a/games/minitest/mods/default/textures/default_furnace_side.png b/games/minitest/mods/default/textures/default_furnace_side.png new file mode 100644 index 0000000..f527075 Binary files /dev/null and b/games/minitest/mods/default/textures/default_furnace_side.png differ diff --git a/games/minitest/mods/default/textures/default_furnace_top.png b/games/minitest/mods/default/textures/default_furnace_top.png new file mode 100644 index 0000000..f527075 Binary files /dev/null and b/games/minitest/mods/default/textures/default_furnace_top.png differ diff --git a/games/minitest/mods/default/textures/default_glass.png b/games/minitest/mods/default/textures/default_glass.png new file mode 100644 index 0000000..b86dfd7 Binary files /dev/null and b/games/minitest/mods/default/textures/default_glass.png differ diff --git a/games/minitest/mods/default/textures/default_grass.png b/games/minitest/mods/default/textures/default_grass.png new file mode 100644 index 0000000..19fb6a3 Binary files /dev/null and b/games/minitest/mods/default/textures/default_grass.png differ diff --git a/games/minitest/mods/default/textures/default_grass_footsteps.png b/games/minitest/mods/default/textures/default_grass_footsteps.png new file mode 100644 index 0000000..19fb6a3 Binary files /dev/null and b/games/minitest/mods/default/textures/default_grass_footsteps.png differ diff --git a/games/minitest/mods/default/textures/default_grass_side.png b/games/minitest/mods/default/textures/default_grass_side.png new file mode 100644 index 0000000..2d877fe Binary files /dev/null and b/games/minitest/mods/default/textures/default_grass_side.png differ diff --git a/games/minitest/mods/default/textures/default_gravel.png b/games/minitest/mods/default/textures/default_gravel.png new file mode 100644 index 0000000..20ab7ea Binary files /dev/null and b/games/minitest/mods/default/textures/default_gravel.png differ diff --git a/games/minitest/mods/default/textures/default_iron_lump.png b/games/minitest/mods/default/textures/default_iron_lump.png new file mode 100644 index 0000000..19490d2 Binary files /dev/null and b/games/minitest/mods/default/textures/default_iron_lump.png differ diff --git a/games/minitest/mods/default/textures/default_item_fence.png b/games/minitest/mods/default/textures/default_item_fence.png new file mode 100644 index 0000000..76a4618 Binary files /dev/null and b/games/minitest/mods/default/textures/default_item_fence.png differ diff --git a/games/minitest/mods/default/textures/default_junglegrass.png b/games/minitest/mods/default/textures/default_junglegrass.png new file mode 100644 index 0000000..93b13df Binary files /dev/null and b/games/minitest/mods/default/textures/default_junglegrass.png differ diff --git a/games/minitest/mods/default/textures/default_jungletree.png b/games/minitest/mods/default/textures/default_jungletree.png new file mode 100644 index 0000000..a116c5d Binary files /dev/null and b/games/minitest/mods/default/textures/default_jungletree.png differ diff --git a/games/minitest/mods/default/textures/default_jungletree_.png b/games/minitest/mods/default/textures/default_jungletree_.png new file mode 100644 index 0000000..cef4962 Binary files /dev/null and b/games/minitest/mods/default/textures/default_jungletree_.png differ diff --git a/games/minitest/mods/default/textures/default_jungletree_top.png b/games/minitest/mods/default/textures/default_jungletree_top.png new file mode 100644 index 0000000..39150b3 Binary files /dev/null and b/games/minitest/mods/default/textures/default_jungletree_top.png differ diff --git a/games/minitest/mods/default/textures/default_ladder.png b/games/minitest/mods/default/textures/default_ladder.png new file mode 100644 index 0000000..992150c Binary files /dev/null and b/games/minitest/mods/default/textures/default_ladder.png differ diff --git a/games/minitest/mods/default/textures/default_lava.png b/games/minitest/mods/default/textures/default_lava.png new file mode 100644 index 0000000..ba79992 Binary files /dev/null and b/games/minitest/mods/default/textures/default_lava.png differ diff --git a/games/minitest/mods/default/textures/default_lava_flowing_animated.png b/games/minitest/mods/default/textures/default_lava_flowing_animated.png new file mode 100644 index 0000000..cef8e36 Binary files /dev/null and b/games/minitest/mods/default/textures/default_lava_flowing_animated.png differ diff --git a/games/minitest/mods/default/textures/default_lava_source_animated.png b/games/minitest/mods/default/textures/default_lava_source_animated.png new file mode 100644 index 0000000..9339a68 Binary files /dev/null and b/games/minitest/mods/default/textures/default_lava_source_animated.png differ diff --git a/games/minitest/mods/default/textures/default_leaves.png b/games/minitest/mods/default/textures/default_leaves.png new file mode 100644 index 0000000..7ed06eb Binary files /dev/null and b/games/minitest/mods/default/textures/default_leaves.png differ diff --git a/games/minitest/mods/default/textures/default_lump_of_clay.png b/games/minitest/mods/default/textures/default_lump_of_clay.png new file mode 100644 index 0000000..be0bab9 Binary files /dev/null and b/games/minitest/mods/default/textures/default_lump_of_clay.png differ diff --git a/games/minitest/mods/default/textures/default_lump_of_coal.png b/games/minitest/mods/default/textures/default_lump_of_coal.png new file mode 100644 index 0000000..bad901e Binary files /dev/null and b/games/minitest/mods/default/textures/default_lump_of_coal.png differ diff --git a/games/minitest/mods/default/textures/default_menulogo.png b/games/minitest/mods/default/textures/default_menulogo.png new file mode 100644 index 0000000..e0dd8b1 Binary files /dev/null and b/games/minitest/mods/default/textures/default_menulogo.png differ diff --git a/games/minitest/mods/default/textures/default_mese.png b/games/minitest/mods/default/textures/default_mese.png new file mode 100644 index 0000000..9423faf Binary files /dev/null and b/games/minitest/mods/default/textures/default_mese.png differ diff --git a/games/minitest/mods/default/textures/default_mineral_coal.png b/games/minitest/mods/default/textures/default_mineral_coal.png new file mode 100644 index 0000000..6119060 Binary files /dev/null and b/games/minitest/mods/default/textures/default_mineral_coal.png differ diff --git a/games/minitest/mods/default/textures/default_mineral_iron.png b/games/minitest/mods/default/textures/default_mineral_iron.png new file mode 100644 index 0000000..5ac5cc6 Binary files /dev/null and b/games/minitest/mods/default/textures/default_mineral_iron.png differ diff --git a/games/minitest/mods/default/textures/default_mossycobble.png b/games/minitest/mods/default/textures/default_mossycobble.png new file mode 100644 index 0000000..242e91b Binary files /dev/null and b/games/minitest/mods/default/textures/default_mossycobble.png differ diff --git a/games/minitest/mods/default/textures/default_mud.png b/games/minitest/mods/default/textures/default_mud.png new file mode 100644 index 0000000..30cd4bf Binary files /dev/null and b/games/minitest/mods/default/textures/default_mud.png differ diff --git a/games/minitest/mods/default/textures/default_nc_back.png b/games/minitest/mods/default/textures/default_nc_back.png new file mode 100644 index 0000000..f09f416 Binary files /dev/null and b/games/minitest/mods/default/textures/default_nc_back.png differ diff --git a/games/minitest/mods/default/textures/default_nc_front.png b/games/minitest/mods/default/textures/default_nc_front.png new file mode 100644 index 0000000..cad9eda Binary files /dev/null and b/games/minitest/mods/default/textures/default_nc_front.png differ diff --git a/games/minitest/mods/default/textures/default_nc_rb.png b/games/minitest/mods/default/textures/default_nc_rb.png new file mode 100644 index 0000000..7ebc993 Binary files /dev/null and b/games/minitest/mods/default/textures/default_nc_rb.png differ diff --git a/games/minitest/mods/default/textures/default_nc_side.png b/games/minitest/mods/default/textures/default_nc_side.png new file mode 100644 index 0000000..f954045 Binary files /dev/null and b/games/minitest/mods/default/textures/default_nc_side.png differ diff --git a/games/minitest/mods/default/textures/default_paper.png b/games/minitest/mods/default/textures/default_paper.png new file mode 100644 index 0000000..7b0e546 Binary files /dev/null and b/games/minitest/mods/default/textures/default_paper.png differ diff --git a/games/minitest/mods/default/textures/default_papyrus.png b/games/minitest/mods/default/textures/default_papyrus.png new file mode 100644 index 0000000..64f8b54 Binary files /dev/null and b/games/minitest/mods/default/textures/default_papyrus.png differ diff --git a/games/minitest/mods/default/textures/default_rail.png b/games/minitest/mods/default/textures/default_rail.png new file mode 100644 index 0000000..18176d9 Binary files /dev/null and b/games/minitest/mods/default/textures/default_rail.png differ diff --git a/games/minitest/mods/default/textures/default_rail_crossing.png b/games/minitest/mods/default/textures/default_rail_crossing.png new file mode 100644 index 0000000..9846405 Binary files /dev/null and b/games/minitest/mods/default/textures/default_rail_crossing.png differ diff --git a/games/minitest/mods/default/textures/default_rail_curved.png b/games/minitest/mods/default/textures/default_rail_curved.png new file mode 100644 index 0000000..62afa3d Binary files /dev/null and b/games/minitest/mods/default/textures/default_rail_curved.png differ diff --git a/games/minitest/mods/default/textures/default_rail_t_junction.png b/games/minitest/mods/default/textures/default_rail_t_junction.png new file mode 100644 index 0000000..9985f63 Binary files /dev/null and b/games/minitest/mods/default/textures/default_rail_t_junction.png differ diff --git a/games/minitest/mods/default/textures/default_rat.png b/games/minitest/mods/default/textures/default_rat.png new file mode 100644 index 0000000..eead17c Binary files /dev/null and b/games/minitest/mods/default/textures/default_rat.png differ diff --git a/games/minitest/mods/default/textures/default_sand.png b/games/minitest/mods/default/textures/default_sand.png new file mode 100644 index 0000000..e09a87c Binary files /dev/null and b/games/minitest/mods/default/textures/default_sand.png differ diff --git a/games/minitest/mods/default/textures/default_sandstone.png b/games/minitest/mods/default/textures/default_sandstone.png new file mode 100644 index 0000000..5e33939 Binary files /dev/null and b/games/minitest/mods/default/textures/default_sandstone.png differ diff --git a/games/minitest/mods/default/textures/default_sapling.png b/games/minitest/mods/default/textures/default_sapling.png new file mode 100644 index 0000000..16343ec Binary files /dev/null and b/games/minitest/mods/default/textures/default_sapling.png differ diff --git a/games/minitest/mods/default/textures/default_scorched_stuff.png b/games/minitest/mods/default/textures/default_scorched_stuff.png new file mode 100644 index 0000000..9ced2fb Binary files /dev/null and b/games/minitest/mods/default/textures/default_scorched_stuff.png differ diff --git a/games/minitest/mods/default/textures/default_sign.png b/games/minitest/mods/default/textures/default_sign.png new file mode 100644 index 0000000..bf81794 Binary files /dev/null and b/games/minitest/mods/default/textures/default_sign.png differ diff --git a/games/minitest/mods/default/textures/default_sign_back.png b/games/minitest/mods/default/textures/default_sign_back.png new file mode 100644 index 0000000..05ceca5 Binary files /dev/null and b/games/minitest/mods/default/textures/default_sign_back.png differ diff --git a/games/minitest/mods/default/textures/default_sign_wall.png b/games/minitest/mods/default/textures/default_sign_wall.png new file mode 100644 index 0000000..c7efca7 Binary files /dev/null and b/games/minitest/mods/default/textures/default_sign_wall.png differ diff --git a/games/minitest/mods/default/textures/default_skybox1_source.png b/games/minitest/mods/default/textures/default_skybox1_source.png new file mode 100644 index 0000000..642e89c Binary files /dev/null and b/games/minitest/mods/default/textures/default_skybox1_source.png differ diff --git a/games/minitest/mods/default/textures/default_steel_block.png b/games/minitest/mods/default/textures/default_steel_block.png new file mode 100644 index 0000000..de365d9 Binary files /dev/null and b/games/minitest/mods/default/textures/default_steel_block.png differ diff --git a/games/minitest/mods/default/textures/default_steel_ingot.png b/games/minitest/mods/default/textures/default_steel_ingot.png new file mode 100644 index 0000000..3b18097 Binary files /dev/null and b/games/minitest/mods/default/textures/default_steel_ingot.png differ diff --git a/games/minitest/mods/default/textures/default_stick.png b/games/minitest/mods/default/textures/default_stick.png new file mode 100644 index 0000000..2bdc8b2 Binary files /dev/null and b/games/minitest/mods/default/textures/default_stick.png differ diff --git a/games/minitest/mods/default/textures/default_stone.png b/games/minitest/mods/default/textures/default_stone.png new file mode 100644 index 0000000..4ab1000 Binary files /dev/null and b/games/minitest/mods/default/textures/default_stone.png differ diff --git a/games/minitest/mods/default/textures/default_tnt_bottom.png b/games/minitest/mods/default/textures/default_tnt_bottom.png new file mode 100644 index 0000000..8ba2fca Binary files /dev/null and b/games/minitest/mods/default/textures/default_tnt_bottom.png differ diff --git a/games/minitest/mods/default/textures/default_tnt_side.png b/games/minitest/mods/default/textures/default_tnt_side.png new file mode 100644 index 0000000..d9a2bc4 Binary files /dev/null and b/games/minitest/mods/default/textures/default_tnt_side.png differ diff --git a/games/minitest/mods/default/textures/default_tnt_top.png b/games/minitest/mods/default/textures/default_tnt_top.png new file mode 100644 index 0000000..a84ffc9 Binary files /dev/null and b/games/minitest/mods/default/textures/default_tnt_top.png differ diff --git a/games/minitest/mods/default/textures/default_tool_mesepick.png b/games/minitest/mods/default/textures/default_tool_mesepick.png new file mode 100644 index 0000000..b09c1fd Binary files /dev/null and b/games/minitest/mods/default/textures/default_tool_mesepick.png differ diff --git a/games/minitest/mods/default/textures/default_tool_steelaxe.png b/games/minitest/mods/default/textures/default_tool_steelaxe.png new file mode 100644 index 0000000..c9eb8a5 Binary files /dev/null and b/games/minitest/mods/default/textures/default_tool_steelaxe.png differ diff --git a/games/minitest/mods/default/textures/default_tool_steelpick.png b/games/minitest/mods/default/textures/default_tool_steelpick.png new file mode 100644 index 0000000..ef32e31 Binary files /dev/null and b/games/minitest/mods/default/textures/default_tool_steelpick.png differ diff --git a/games/minitest/mods/default/textures/default_tool_steelshovel.png b/games/minitest/mods/default/textures/default_tool_steelshovel.png new file mode 100644 index 0000000..efb5781 Binary files /dev/null and b/games/minitest/mods/default/textures/default_tool_steelshovel.png differ diff --git a/games/minitest/mods/default/textures/default_tool_steelsword.png b/games/minitest/mods/default/textures/default_tool_steelsword.png new file mode 100644 index 0000000..476bd15 Binary files /dev/null and b/games/minitest/mods/default/textures/default_tool_steelsword.png differ diff --git a/games/minitest/mods/default/textures/default_tool_stoneaxe.png b/games/minitest/mods/default/textures/default_tool_stoneaxe.png new file mode 100644 index 0000000..86d243e Binary files /dev/null and b/games/minitest/mods/default/textures/default_tool_stoneaxe.png differ diff --git a/games/minitest/mods/default/textures/default_tool_stonepick.png b/games/minitest/mods/default/textures/default_tool_stonepick.png new file mode 100644 index 0000000..ac16d62 Binary files /dev/null and b/games/minitest/mods/default/textures/default_tool_stonepick.png differ diff --git a/games/minitest/mods/default/textures/default_tool_stoneshovel.png b/games/minitest/mods/default/textures/default_tool_stoneshovel.png new file mode 100644 index 0000000..855974f Binary files /dev/null and b/games/minitest/mods/default/textures/default_tool_stoneshovel.png differ diff --git a/games/minitest/mods/default/textures/default_tool_stonesword.png b/games/minitest/mods/default/textures/default_tool_stonesword.png new file mode 100644 index 0000000..61de22d Binary files /dev/null and b/games/minitest/mods/default/textures/default_tool_stonesword.png differ diff --git a/games/minitest/mods/default/textures/default_tool_woodaxe.png b/games/minitest/mods/default/textures/default_tool_woodaxe.png new file mode 100644 index 0000000..e1e2a6f Binary files /dev/null and b/games/minitest/mods/default/textures/default_tool_woodaxe.png differ diff --git a/games/minitest/mods/default/textures/default_tool_woodpick.png b/games/minitest/mods/default/textures/default_tool_woodpick.png new file mode 100644 index 0000000..1f00f47 Binary files /dev/null and b/games/minitest/mods/default/textures/default_tool_woodpick.png differ diff --git a/games/minitest/mods/default/textures/default_tool_woodshovel.png b/games/minitest/mods/default/textures/default_tool_woodshovel.png new file mode 100644 index 0000000..007f9d6 Binary files /dev/null and b/games/minitest/mods/default/textures/default_tool_woodshovel.png differ diff --git a/games/minitest/mods/default/textures/default_tool_woodsword.png b/games/minitest/mods/default/textures/default_tool_woodsword.png new file mode 100644 index 0000000..572468b Binary files /dev/null and b/games/minitest/mods/default/textures/default_tool_woodsword.png differ diff --git a/games/minitest/mods/default/textures/default_torch.png b/games/minitest/mods/default/textures/default_torch.png new file mode 100644 index 0000000..b6d77b1 Binary files /dev/null and b/games/minitest/mods/default/textures/default_torch.png differ diff --git a/games/minitest/mods/default/textures/default_torch_on_ceiling.png b/games/minitest/mods/default/textures/default_torch_on_ceiling.png new file mode 100644 index 0000000..c7d9f0b Binary files /dev/null and b/games/minitest/mods/default/textures/default_torch_on_ceiling.png differ diff --git a/games/minitest/mods/default/textures/default_torch_on_floor.png b/games/minitest/mods/default/textures/default_torch_on_floor.png new file mode 100644 index 0000000..c1849c1 Binary files /dev/null and b/games/minitest/mods/default/textures/default_torch_on_floor.png differ diff --git a/games/minitest/mods/default/textures/default_tree.png b/games/minitest/mods/default/textures/default_tree.png new file mode 100644 index 0000000..e7596a5 Binary files /dev/null and b/games/minitest/mods/default/textures/default_tree.png differ diff --git a/games/minitest/mods/default/textures/default_tree_top.png b/games/minitest/mods/default/textures/default_tree_top.png new file mode 100644 index 0000000..39150b3 Binary files /dev/null and b/games/minitest/mods/default/textures/default_tree_top.png differ diff --git a/games/minitest/mods/default/textures/default_water.png b/games/minitest/mods/default/textures/default_water.png new file mode 100644 index 0000000..caadf5d Binary files /dev/null and b/games/minitest/mods/default/textures/default_water.png differ diff --git a/games/minitest/mods/default/textures/default_wood.png b/games/minitest/mods/default/textures/default_wood.png new file mode 100644 index 0000000..bbc6c20 Binary files /dev/null and b/games/minitest/mods/default/textures/default_wood.png differ diff --git a/games/minitest/mods/default/textures/heart.png b/games/minitest/mods/default/textures/heart.png new file mode 100644 index 0000000..75c452b Binary files /dev/null and b/games/minitest/mods/default/textures/heart.png differ diff --git a/games/minitest/mods/default/textures/player.png b/games/minitest/mods/default/textures/player.png new file mode 100644 index 0000000..27b951c Binary files /dev/null and b/games/minitest/mods/default/textures/player.png differ diff --git a/games/minitest/mods/default/textures/player_back.png b/games/minitest/mods/default/textures/player_back.png new file mode 100644 index 0000000..b2d1442 Binary files /dev/null and b/games/minitest/mods/default/textures/player_back.png differ diff --git a/games/minitest/mods/default/textures/treeprop.png b/games/minitest/mods/default/textures/treeprop.png new file mode 100644 index 0000000..77ea4d6 Binary files /dev/null and b/games/minitest/mods/default/textures/treeprop.png differ diff --git a/games/minitest/mods/default/textures/wieldhand.png b/games/minitest/mods/default/textures/wieldhand.png new file mode 100644 index 0000000..fd457ca Binary files /dev/null and b/games/minitest/mods/default/textures/wieldhand.png differ diff --git a/games/minitest/mods/dye/README.txt b/games/minitest/mods/dye/README.txt new file mode 100644 index 0000000..c7ae077 --- /dev/null +++ b/games/minitest/mods/dye/README.txt @@ -0,0 +1,13 @@ +Minetest 0.4 mod: dye +====================== + +License of source code and media files: +--------------------------------------- +Copyright (C) 2012 Perttu Ahola (celeron55) + +This program is free software. It comes without any warranty, to +the extent permitted by applicable law. You can redistribute it +and/or modify it under the terms of the Do What The Fuck You Want +To Public License, Version 2, as published by Sam Hocevar. See +http://sam.zoy.org/wtfpl/COPYING for more details. + diff --git a/games/minitest/mods/dye/depends.txt b/games/minitest/mods/dye/depends.txt new file mode 100644 index 0000000..e69de29 diff --git a/games/minitest/mods/dye/init.lua b/games/minitest/mods/dye/init.lua new file mode 100644 index 0000000..9a6bb64 --- /dev/null +++ b/games/minitest/mods/dye/init.lua @@ -0,0 +1,135 @@ +-- minetest/dye/init.lua + +-- To make recipes that will work with any dye ever made by anybody, define +-- them based on groups. +-- You can select any group of groups, based on your need for amount of colors. +-- basecolor: 9, excolor: 17, unicolor: 89 +-- +-- Example of one shapeless recipe using a color group: +-- Note: As this uses basecolor_*, you'd need 9 of these. +-- minetest.register_craft({ +-- type = "shapeless", +-- output = ':item_yellow', +-- recipe = {':item_no_color', 'group:basecolor_yellow'}, +-- }) + +-- Other mods can use these for looping through available colors +local dye = {} +dye.basecolors = {"white", "grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta"} +dye.excolors = {"white", "lightgrey", "grey", "darkgrey", "black", "red", "orange", "yellow", "lime", "green", "aqua", "cyan", "sky_blue", "blue", "violet", "magenta", "red_violet"} + +-- Base color groups: +-- - basecolor_white +-- - basecolor_grey +-- - basecolor_black +-- - basecolor_red +-- - basecolor_yellow +-- - basecolor_green +-- - basecolor_cyan +-- - basecolor_blue +-- - basecolor_magenta + +-- Extended color groups (* = equal to a base color): +-- * excolor_white +-- - excolor_lightgrey +-- * excolor_grey +-- - excolor_darkgrey +-- * excolor_black +-- * excolor_red +-- - excolor_orange +-- * excolor_yellow +-- - excolor_lime +-- * excolor_green +-- - excolor_aqua +-- * excolor_cyan +-- - excolor_sky_blue +-- * excolor_blue +-- - excolor_violet +-- * excolor_magenta +-- - excolor_red_violet + +-- The whole unifieddyes palette as groups: +-- - unicolor_ +-- For the following, no white/grey/black is allowed: +-- - unicolor_medium_ +-- - unicolor_dark_ +-- - unicolor_light_ +-- - unicolor__s50 +-- - unicolor_medium__s50 +-- - unicolor_dark__s50 + +-- Local stuff +local dyelocal = {} + +-- This collection of colors is partly a historic thing, partly something else. +dyelocal.dyes = { + {"white", "White dye", {dye=1, basecolor_white=1, excolor_white=1, unicolor_white=1}}, + {"grey", "Grey dye", {dye=1, basecolor_grey=1, excolor_grey=1, unicolor_grey=1}}, + {"dark_grey", "Dark grey dye", {dye=1, basecolor_grey=1, excolor_darkgrey=1, unicolor_darkgrey=1}}, + {"black", "Black dye", {dye=1, basecolor_black=1, excolor_black=1, unicolor_black=1}}, + {"violet", "Violet dye", {dye=1, basecolor_magenta=1, excolor_violet=1, unicolor_violet=1}}, + {"blue", "Blue dye", {dye=1, basecolor_blue=1, excolor_blue=1, unicolor_blue=1}}, + {"cyan", "Cyan dye", {dye=1, basecolor_cyan=1, excolor_cyan=1, unicolor_cyan=1}}, + {"dark_green", "Dark green dye",{dye=1, basecolor_green=1, excolor_green=1, unicolor_dark_green=1}}, + {"green", "Green dye", {dye=1, basecolor_green=1, excolor_green=1, unicolor_green=1}}, + {"yellow", "Yellow dye", {dye=1, basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1}}, + {"brown", "Brown dye", {dye=1, basecolor_yellow=1, excolor_orange=1, unicolor_dark_orange=1}}, + {"orange", "Orange dye", {dye=1, basecolor_orange=1, excolor_orange=1, unicolor_orange=1}}, + {"red", "Red dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_red=1}}, + {"magenta", "Magenta dye", {dye=1, basecolor_magenta=1, excolor_red_violet=1,unicolor_red_violet=1}}, + {"pink", "Pink dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_light_red=1}}, +} + +-- Define items +for _, row in ipairs(dyelocal.dyes) do + local name = row[1] + local description = row[2] + local groups = row[3] + local item_name = "dye:"..name + local item_image = "dye_"..name..".png" + minetest.register_craftitem(item_name, { + inventory_image = item_image, + description = description, + groups = groups, + max_stack = 64, + }) +end + +-- Mix recipes +-- Just mix everything to everything somehow sanely + +dyelocal.mixbases = {"magenta", "red", "orange", "brown", "yellow", "green", "dark_green", "cyan", "blue", "violet", "black", "dark_grey", "grey", "white"} + +dyelocal.mixes = { + -- magenta, red, orange, brown, yellow, green, dark_green, cyan, blue, violet, black, dark_grey, grey, white + white = {"pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "violet", "grey", "grey", "white", "white"}, + grey = {"pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "pink", "dark_grey","grey", "grey"}, + dark_grey={"brown","brown", "brown", "brown", "brown","dark_green","dark_green","blue","blue","violet","black", "black"}, + black = {"black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black"}, + violet= {"magenta","magenta","red", "brown", "red", "cyan", "brown", "blue", "violet","violet"}, + blue = {"violet", "magenta","brown","brown","dark_green","cyan","cyan", "cyan", "blue"}, + cyan = {"blue","brown","dark_green","dark_grey","green","cyan","dark_green","cyan"}, + dark_green={"brown","brown","brown", "brown", "green", "green", "dark_green"}, + green = {"brown", "yellow","yellow","dark_green","green","green"}, + yellow= {"red", "orange", "yellow","orange", "yellow"}, + brown = {"brown", "brown","orange", "brown"}, + orange= {"red", "orange","orange"}, + red = {"magenta","red"}, + magenta={"magenta"}, +} + +for one,results in pairs(dyelocal.mixes) do + for i,result in ipairs(results) do + local another = dyelocal.mixbases[i] + minetest.register_craft({ + type = "shapeless", + output = 'dye:'..result..' 2', + recipe = {'dye:'..one, 'dye:'..another}, + }) + end +end + +-- Hide dyelocal +dyelocal = nil + +-- EOF diff --git a/games/minitest/mods/dye/textures/dye_black.png b/games/minitest/mods/dye/textures/dye_black.png new file mode 100644 index 0000000..ef526e6 Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_black.png differ diff --git a/games/minitest/mods/dye/textures/dye_blue.png b/games/minitest/mods/dye/textures/dye_blue.png new file mode 100644 index 0000000..d3e9791 Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_blue.png differ diff --git a/games/minitest/mods/dye/textures/dye_brown.png b/games/minitest/mods/dye/textures/dye_brown.png new file mode 100644 index 0000000..5b27085 Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_brown.png differ diff --git a/games/minitest/mods/dye/textures/dye_cyan.png b/games/minitest/mods/dye/textures/dye_cyan.png new file mode 100644 index 0000000..3ae44e2 Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_cyan.png differ diff --git a/games/minitest/mods/dye/textures/dye_dark_green.png b/games/minitest/mods/dye/textures/dye_dark_green.png new file mode 100644 index 0000000..784b785 Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_dark_green.png differ diff --git a/games/minitest/mods/dye/textures/dye_dark_grey.png b/games/minitest/mods/dye/textures/dye_dark_grey.png new file mode 100644 index 0000000..adaa014 Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_dark_grey.png differ diff --git a/games/minitest/mods/dye/textures/dye_green.png b/games/minitest/mods/dye/textures/dye_green.png new file mode 100644 index 0000000..e88631c Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_green.png differ diff --git a/games/minitest/mods/dye/textures/dye_grey.png b/games/minitest/mods/dye/textures/dye_grey.png new file mode 100644 index 0000000..c4706e7 Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_grey.png differ diff --git a/games/minitest/mods/dye/textures/dye_magenta.png b/games/minitest/mods/dye/textures/dye_magenta.png new file mode 100644 index 0000000..4946c71 Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_magenta.png differ diff --git a/games/minitest/mods/dye/textures/dye_orange.png b/games/minitest/mods/dye/textures/dye_orange.png new file mode 100644 index 0000000..347964d Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_orange.png differ diff --git a/games/minitest/mods/dye/textures/dye_pink.png b/games/minitest/mods/dye/textures/dye_pink.png new file mode 100644 index 0000000..ec2acf5 Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_pink.png differ diff --git a/games/minitest/mods/dye/textures/dye_red.png b/games/minitest/mods/dye/textures/dye_red.png new file mode 100644 index 0000000..9f8c151 Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_red.png differ diff --git a/games/minitest/mods/dye/textures/dye_violet.png b/games/minitest/mods/dye/textures/dye_violet.png new file mode 100644 index 0000000..0ee216c Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_violet.png differ diff --git a/games/minitest/mods/dye/textures/dye_white.png b/games/minitest/mods/dye/textures/dye_white.png new file mode 100644 index 0000000..508e32f Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_white.png differ diff --git a/games/minitest/mods/dye/textures/dye_yellow.png b/games/minitest/mods/dye/textures/dye_yellow.png new file mode 100644 index 0000000..d00a5b8 Binary files /dev/null and b/games/minitest/mods/dye/textures/dye_yellow.png differ diff --git a/games/minitest/mods/fire/README.txt b/games/minitest/mods/fire/README.txt new file mode 100644 index 0000000..564d4a2 --- /dev/null +++ b/games/minitest/mods/fire/README.txt @@ -0,0 +1,30 @@ +Minetest 0.4 mod: fire +====================== + +License of source code: +----------------------- +Copyright (C) 2012 Perttu Ahola (celeron55) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +http://www.gnu.org/licenses/lgpl-2.1.html + +License of media (textures and sounds) +-------------------------------------- +Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) +http://creativecommons.org/licenses/by-sa/3.0/ + +Authors of media files +----------------------- +Everything not listed in here: +Copyright (C) 2012 Perttu Ahola (celeron55) + +fire_small.ogg sampled from: + http://www.freesound.org/people/dobroide/sounds/4211/ + +fire_large.ogg sampled from: + http://www.freesound.org/people/Dynamicell/sounds/17548/ + diff --git a/games/minitest/mods/fire/init.lua b/games/minitest/mods/fire/init.lua new file mode 100644 index 0000000..164d893 --- /dev/null +++ b/games/minitest/mods/fire/init.lua @@ -0,0 +1,188 @@ +-- minetest/fire/init.lua + +minetest.register_node("fire:basic_flame", { + description = "Fire", + drawtype = "plantlike", + tile_images = {"fire_basic_flame.png"}, + light_source = 14, + groups = {igniter=2,dig_immediate=3}, + drop = '', + walkable = false, +}) + +local fire = {} +fire.D = 6 +-- key: position hash of low corner of area +-- value: {handle=sound handle, name=sound name} +fire.sounds = {} + +function fire.get_area_p0p1(pos) + local p0 = { + x=math.floor(pos.x/fire.D)*fire.D, + y=math.floor(pos.y/fire.D)*fire.D, + z=math.floor(pos.z/fire.D)*fire.D, + } + local p1 = { + x=p0.x+fire.D-1, + y=p0.y+fire.D-1, + z=p0.z+fire.D-1 + } + return p0, p1 +end + +function fire.update_sounds_around(pos) + local p0, p1 = fire.get_area_p0p1(pos) + local cp = {x=(p0.x+p1.x)/2, y=(p0.y+p1.y)/2, z=(p0.z+p1.z)/2} + local flames_p = minetest.env:find_nodes_in_area(p0, p1, {"fire:basic_flame"}) + --print("number of flames at "..minetest.pos_to_string(p0).."/" + -- ..minetest.pos_to_string(p1)..": "..#flames_p) + local should_have_sound = (#flames_p > 0) + local wanted_sound = nil + if #flames_p >= 9 then + wanted_sound = {name="fire_large", gain=1.5} + elseif #flames_p > 0 then + wanted_sound = {name="fire_small", gain=1.5} + end + local p0_hash = minetest.hash_node_position(p0) + local sound = fire.sounds[p0_hash] + if not sound then + if should_have_sound then + fire.sounds[p0_hash] = { + handle = minetest.sound_play(wanted_sound, {pos=cp, loop=true}), + name = wanted_sound.name, + } + end + else + if not wanted_sound then + minetest.sound_stop(sound.handle) + fire.sounds[p0_hash] = nil + elseif sound.name ~= wanted_sound.name then + minetest.sound_stop(sound.handle) + fire.sounds[p0_hash] = { + handle = minetest.sound_play(wanted_sound, {pos=cp, loop=true}), + name = wanted_sound.name, + } + end + end +end + +function fire.on_flame_add_at(pos) + --print("flame added at "..minetest.pos_to_string(pos)) + fire.update_sounds_around(pos) +end + +function fire.on_flame_remove_at(pos) + --print("flame removed at "..minetest.pos_to_string(pos)) + fire.update_sounds_around(pos) +end + +function fire.find_pos_for_flame_around(pos) + return minetest.env:find_node_near(pos, 1, {"air"}) +end + +function fire.flame_should_extinguish(pos) + --return minetest.env:find_node_near(pos, 1, {"group:puts_out_fire"}) + local p0 = {x=pos.x-2, y=pos.y, z=pos.z-2} + local p1 = {x=pos.x+2, y=pos.y, z=pos.z+2} + local ps = minetest.env:find_nodes_in_area(p0, p1, {"group:puts_out_fire"}) + return (#ps ~= 0) +end + +minetest.register_on_placenode(function(pos, newnode, placer) + if newnode.name == "fire:basic_flame" then + fire.on_flame_add_at(pos) + end +end) + +minetest.register_on_dignode(function(pos, oldnode, digger) + if oldnode.name == "fire:basic_flame" then + fire.on_flame_remove_at(pos) + end +end) + +-- Ignite neighboring nodes +minetest.register_abm({ + nodenames = {"group:flammable"}, + neighbors = {"group:igniter"}, + interval = 1, + chance = 2, + action = function(p0, node, _, _) + -- If there is water or stuff like that around flame, don't ignite + if fire.flame_should_extinguish(p0) then + return + end + local p = fire.find_pos_for_flame_around(p0) + if p then + minetest.env:set_node(p, {name="fire:basic_flame"}) + fire.on_flame_add_at(p) + end + end, +}) + +-- Rarely ignite things from far +minetest.register_abm({ + nodenames = {"group:igniter"}, + neighbors = {"air"}, + interval = 2, + chance = 10, + action = function(p0, node, _, _) + local reg = minetest.registered_nodes[node.name] + if not reg or not reg.groups.igniter or reg.groups.igniter < 2 then + return + end + local d = reg.groups.igniter + local p = minetest.env:find_node_near(p0, d, {"group:flammable"}) + if p then + -- If there is water or stuff like that around flame, don't ignite + if fire.flame_should_extinguish(p) then + return + end + local p2 = fire.find_pos_for_flame_around(p) + if p2 then + minetest.env:set_node(p2, {name="fire:basic_flame"}) + fire.on_flame_add_at(p2) + end + end + end, +}) + +-- Remove flammable nodes and flame +minetest.register_abm({ + nodenames = {"fire:basic_flame"}, + interval = 1, + chance = 2, + action = function(p0, node, _, _) + -- If there is water or stuff like that around flame, remove flame + if fire.flame_should_extinguish(p0) then + minetest.env:remove_node(p0) + fire.on_flame_remove_at(p0) + return + end + -- Make the following things rarer + if math.random(1,3) == 1 then + return + end + -- If there are no flammable nodes around flame, remove flame + if not minetest.env:find_node_near(p0, 1, {"group:flammable"}) then + minetest.env:remove_node(p0) + fire.on_flame_remove_at(p0) + return + end + if math.random(1,4) == 1 then + -- remove a flammable node around flame + local p = minetest.env:find_node_near(p0, 1, {"group:flammable"}) + if p then + -- If there is water or stuff like that around flame, don't remove + if fire.flame_should_extinguish(p0) then + return + end + minetest.env:remove_node(p) + end + else + -- remove flame + minetest.env:remove_node(p0) + fire.on_flame_remove_at(p0) + end + end, +}) + diff --git a/games/minitest/mods/fire/sounds/fire_large.ogg b/games/minitest/mods/fire/sounds/fire_large.ogg new file mode 100644 index 0000000..fe78e62 Binary files /dev/null and b/games/minitest/mods/fire/sounds/fire_large.ogg differ diff --git a/games/minitest/mods/fire/sounds/fire_small.ogg b/games/minitest/mods/fire/sounds/fire_small.ogg new file mode 100644 index 0000000..5aac595 Binary files /dev/null and b/games/minitest/mods/fire/sounds/fire_small.ogg differ diff --git a/games/minitest/mods/fire/textures/fire_basic_flame.png b/games/minitest/mods/fire/textures/fire_basic_flame.png new file mode 100644 index 0000000..a5c2afd Binary files /dev/null and b/games/minitest/mods/fire/textures/fire_basic_flame.png differ diff --git a/games/minitest/mods/growing/README.txt b/games/minitest/mods/growing/README.txt new file mode 100644 index 0000000..51fb24b --- /dev/null +++ b/games/minitest/mods/growing/README.txt @@ -0,0 +1,2 @@ +Growing mod by randomproof +updated by PilzAdam \ No newline at end of file diff --git a/games/minitest/mods/growing/depends.txt b/games/minitest/mods/growing/depends.txt new file mode 100644 index 0000000..3a7daa1 --- /dev/null +++ b/games/minitest/mods/growing/depends.txt @@ -0,0 +1,2 @@ +default + diff --git a/games/minitest/mods/growing/init.lua b/games/minitest/mods/growing/init.lua new file mode 100644 index 0000000..3235c9e --- /dev/null +++ b/games/minitest/mods/growing/init.lua @@ -0,0 +1,61 @@ +math.randomseed(os.time()) + +--[[ +-- growname describes the node that is to grow +-- surfaces is a table of: +-- the name of the node that said node is allowed to grow on top of +-- the odds it has over 1000 to grow at each callback cycle +--]] + +function add_grow_type(growname, surfaces) + minetest.register_abm({ + nodenames = { growname }, + interval = 60, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + if minetest.env:get_meta(pos):get_string("new") == "true" then + minetest.env:get_meta(pos):set_string("new", "false") + return + end + -- First check if there is space above to grow + p_top = {x = pos.x, y = pos.y + 1, z = pos.z} + n_top = minetest.env:get_node(p_top) + + if n_top.name == "air" then + -- Calc current height + cur_height = 1 + p_next = {x = pos.x, y = pos.y - 1, z = pos.z} + n_next = minetest.env:get_node(p_next); + while true do + if n_next.name ~= node.name then + break + end + cur_height = cur_height + 1 + p_next = {x = p_next.x, y = p_next.y - 1, z = p_next.z} + n_next = minetest.env:get_node(p_next) + end + + for _, s in ipairs(surfaces) do + if n_next.name == s.name and (math.random(1, 1000) > (1000 - s.odds)) then + if cur_height < s.max_height then + minetest.env:add_node(p_top, {name = node.name}) + minetest.env:get_meta(p_top):set_string("new", "true") + end + end + end + end + end + }) +end + +add_grow_type("default:papyrus", { +{name = "default:dirt", odds = 500, max_height = 4}, +{name = "default:dirt_with_grass", odds = 500, max_height = 4}, +{name = "default:dirt_with_grass_footsteps", odds = 500, max_height = 4}, +{name = "default:sand", odds = 500, max_height = 4} +}) + +add_grow_type("default:cactus", { +{name = "default:sand", odds = 500, max_height = 4}, +{name = "default:desert_sand", odds = 500, max_height = 4} +}) diff --git a/games/minitest/mods/inventory/init.lua b/games/minitest/mods/inventory/init.lua new file mode 100644 index 0000000..e1335f5 --- /dev/null +++ b/games/minitest/mods/inventory/init.lua @@ -0,0 +1,8 @@ +minetest.register_on_joinplayer(function(player) + player:set_inventory_formspec( + "invsize[8,7.5;]".. + "image[1,0.6;1,2;player.png]".. + "list[current_player;main;0,3.5;8,4;]".. + "list[current_player;craft;3,0;3,3;]".. + "list[current_player;craftpreview;7,1;1,1;]") +end) \ No newline at end of file diff --git a/games/minitest/mods/item_drop/README.txt b/games/minitest/mods/item_drop/README.txt new file mode 100644 index 0000000..7788bdc --- /dev/null +++ b/games/minitest/mods/item_drop/README.txt @@ -0,0 +1,38 @@ +===ITEM_DROP MOD for MINETEST-C55=== +by PilzAdam + +Introduction: +This mod adds Minecraft like drop/pick up of items to Minetest. + +How to install: +Unzip the archive an place it in minetest-base-directory/mods/minetest/ +if you have a windows client or a linux run-in-place client. If you have +a linux system-wide instalation place it in ~/.minetest/mods/minetest/. +If you want to install this mod only in one world create the folder +worldmods/ in your worlddirectory. +For further information or help see: +http://wiki.minetest.com/wiki/Installing_Mods + +How to use the mod: +Just install it an everything works. + +License: +Sourcecode: WTFPL (see below) +Sound: WTFPL (see below) + +See also: +http://minetest.net/ + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/games/minitest/mods/item_drop/init.lua b/games/minitest/mods/item_drop/init.lua new file mode 100644 index 0000000..79d437c --- /dev/null +++ b/games/minitest/mods/item_drop/init.lua @@ -0,0 +1,135 @@ +function item_drop(pos, oldnode, digger) + local anzahl = 1 + if oldnode.name.items ~= nil then + local drops = {} + local max_items = oldnode.name.max_items + for i,item in ipairs(oldnode.name.items) do + local rarity + if item.rarity == nil then + rarity = 1 + else + rarity = item.rarity + end + if math.random(1, rarity) == 1 then + table.insert(drops, item.items[1]) + end + if #drops == max_items then + for j,it in ipairs(drops) do + item_drop(pos, {name=it}, digger) + end + return + end + end + return + else + if string.find(oldnode.name, " ") ~= nil then + anzahl = string.sub(oldnode.name, string.find(oldnode.name, " ")+1, string.len(oldnode.name)) + oldnode.name = string.sub(oldnode.name, 1, string.find(oldnode.name, " ")-1) + end + end + for i=1,anzahl do + if digger:get_inventory():room_for_item("main", ItemStack(oldnode.name)) then + digger:get_inventory():remove_item("main", ItemStack(oldnode.name)) + end + local item = minetest.env:add_item(pos, oldnode) + item:get_luaentity().collect = true + local x = math.random(1, 5) + if math.random(1,2) == 1 then + x = -x + end + local z = math.random(1, 5) + if math.random(1,2) == 1 then + z = -z + end + item:setvelocity({x=1/x, y=item:getvelocity().y, z=1/z}) + end +end + +local item_timer = {} + +minetest.register_globalstep(function(dtime) + for i,player in ipairs(minetest.get_connected_players()) do + local pos = player:getpos() + pos.y = pos.y+0.5 + local items = minetest.env:get_objects_inside_radius(pos,1) + for j,item in ipairs(items) do + if not item:is_player() and item:get_luaentity().itemstring ~= nil then + if item:get_luaentity().itemstring ~= "" and player:get_inventory():room_for_item("main", ItemStack(item:get_luaentity().itemstring)) and item:get_luaentity().collect then + player:get_inventory():add_item("main", ItemStack(item:get_luaentity().itemstring)) + minetest.sound_play("item_drop_pickup", { + to_player = player, + }) + item:remove() + item:get_luaentity().itemstring = "" + end + end + end + + items = minetest.env:get_objects_inside_radius(pos, 2.5) + for j,item in ipairs(items) do + if not item:is_player() and item:get_luaentity().itemstring ~= nil then + if player:get_inventory():room_for_item("main", ItemStack(item:get_luaentity().itemstring)) and item:get_luaentity().collect then + local p = player:getpos() + p.y = p.y+0.5 + local i = item:getpos() + local move = {x=(p.x-i.x)*15, y=(p.y-i.y)*15, z=(p.z-i.z)*15} + item:setacceleration(move) + end + + if item:get_luaentity().collect == nil and item:get_luaentity().itemstring ~= "" then + if item:get_luaentity().timer == nil then + item:get_luaentity().timer = 0 + table.insert(item_timer, item) + end + end + end + end + end + + for i,item in ipairs(item_timer) do + item:get_luaentity().timer = item:get_luaentity().timer + dtime + if item:get_luaentity().timer > 1 then + item:get_luaentity().collect = true + table.remove(item_timer, i) + end + end +end) + +minetest.after(0, function() + for name,node in pairs(minetest.registered_nodes) do + local func + if node.drop == nil then + if node.after_dig_node == nil then + func = function(pos, oldnode, oldmetadata, digger) + item_drop(pos, oldnode, digger) + end + else + func = function(pos, oldnode, oldmetadata, digger) + item_drop(pos, oldnode, digger) + end + end + else + if node.after_dig_node == nil then + func = function(pos, oldnode, oldmetadata, digger) + oldnode.name = node.drop + item_drop(pos, oldnode, digger) + end + else + func = function(pos, oldnode, oldmetadata, digger) + oldnode.name = node.drop + item_drop(pos, oldnode, digger) + end + end + end + + local new_node = { + after_dig_node = func, + stack_max = 64, + } + for str,val in pairs(node) do + new_node[str] = val + end + minetest.register_node(":"..new_node.name, new_node) + end +end) + diff --git a/games/minitest/mods/item_drop/sounds/item_drop_pickup.ogg b/games/minitest/mods/item_drop/sounds/item_drop_pickup.ogg new file mode 100644 index 0000000..f93659b Binary files /dev/null and b/games/minitest/mods/item_drop/sounds/item_drop_pickup.ogg differ diff --git a/games/minitest/mods/particles/README.txt b/games/minitest/mods/particles/README.txt new file mode 100644 index 0000000..82d8fa3 --- /dev/null +++ b/games/minitest/mods/particles/README.txt @@ -0,0 +1 @@ +Particles Mod by sfan5 \ No newline at end of file diff --git a/games/minitest/mods/particles/VERSION b/games/minitest/mods/particles/VERSION new file mode 100644 index 0000000..be58634 --- /dev/null +++ b/games/minitest/mods/particles/VERSION @@ -0,0 +1 @@ +0.3 diff --git a/games/minitest/mods/particles/VERSION~ b/games/minitest/mods/particles/VERSION~ new file mode 100644 index 0000000..e69de29 diff --git a/games/minitest/mods/particles/init.lua b/games/minitest/mods/particles/init.lua new file mode 100644 index 0000000..4c8a7bd --- /dev/null +++ b/games/minitest/mods/particles/init.lua @@ -0,0 +1,174 @@ +------------- Settings -------------- +BLOCK_BREAK_PARTICLES = 16 +------------------------------------- +SMOKE = { + physical = true, + collisionbox = {-0.1,-0.1,-0.1,0,0,0}, + visual = "sprite", + textures = {"smoke.png"}, + on_step = function(self, dtime) + self.object:setacceleration({x=0, y=0.5, z=0}) + self.timer = self.timer + dtime + if self.timer > 3 then + self.object:remove() + end + end, + timer = 0, +} + +minetest.register_entity("particles:smoke", SMOKE) +minetest.register_abm({ + nodenames = {"default:torch"}, + interval = 10, + chance = 10, + action = function(pos) + minetest.env:add_entity({x=pos.x+math.random()*0.5,y=pos.y-0.25,z=pos.z+math.random()*0.5}, "particles:smoke") + end, +}) + +if minetest.get_modpath("jeija") ~= nil then -- Mesecons is installed + MESECONDUST = { + physical = true, + collisionbox = {-0.1,-0.1,-0.1,0,0,0}, + visual = "sprite", + textures = {"mesecondust.png"}, + on_step = function(self, dtime) + self.timer = self.timer + dtime + if self.timer > 2.5 then + self.object:remove() + end + end, + timer = 0, + } + minetest.register_entity("particles:mesecondust", MESECONDUST) + minetest.register_abm({ + nodenames = {"jeija:mesecon_on","jeija:wall_lever_on","jeija:mesecon_torch_on"}, + interval = 1, + chance = 5, + action = function(pos) + --minetest.env:add_entity({x=pos.x+math.random()*0.5,y=pos.y,z=pos.z+math.random()*0.5}, "particles:mesecondust") + end, + }) +end + +nodename2color = { +--Brown +{"default:dirt","brown"}, +{"default:chest","brown"}, +{"default:chest_locked","brown"}, +{"default:wood","brown"}, +{"default:tree","brown"}, +{"default:jungletree","brown"}, +{"default:bookshelf","brown"}, +{"default:sign_wall","brown"}, +{"default:ladder","brown"}, +{"default:fence_wood","brown"}, +--Red +{"default:apple","red"}, +{"default:brick","red"}, +--Green +{"default:cactus","green"}, +{"default:junglegrass","green"}, +{"default:dirt_with_grass","green"}, +{"default:sapling","green"}, +{"default:papyrus","green"}, +{"default:leaves","green"}, +--Gray +{"default:cobble","gray"}, +{"default:furnace","gray"}, +{"default:stone","gray"}, +{"default:stone_with_iron","gray"}, +{"default:rail","gray"}, +{"default:mossycobble","gray"}, +--Lightgray +{"default:steelblock","lightgray"}, +{"default:clay","lightgray"}, +--Yellow +{"default:mese","yellow"}, +{"default:torch","yellow"}, +--Sandcolor +{"default:sand","sandcolor"}, +{"default:sandstone","sandcolor"}, +--Black +{"default:gravel","black"}, +{"default:stone_with_coal","black"}, +--White +{"default:cloud","white"}, +{"default:glass","white"}, +--=== Mesecons ===-- +{"mesecons_powerplant:power_plant", "yellow"}, +{"mesecons_random:removestone", "gray"}, +{"mesecons_lamp:lamp_off", "yellow"}, +{"mesecons_lamp:lamp_on", "yellow"}, +{"mesecons:mesecon_off", "yellow"}, +{"mesecons:mesecon_on", "yellow"}, +{"mesecons_detector:object_detector_off", "lightgray"}, +{"mesecons_detector:object_detector_on", "lightgray"}, +{"mesecons_wireless:wireless_inverter_on", "brown"}, +{"mesecons_wireless:wireless_inverter_off", "brown"}, +{"mesecons_wireless:wireless_receiver_on", "brown"}, +{"mesecons_wireless:wireless_receiver_off", "brown"}, +{"mesecons_wireless:wireless_transmitter_on", "brown"}, +{"mesecons_wireless:wireless_transmitter_off", "brown"}, +{"mesecons_switch:mesecon_switch_off", "gray"}, +{"mesecons_switch:mesecon_switch_off", "gray"}, +{"mesecons_button:button_on", "yellow"}, +{"mesecons_button:button_off", "yellow"}, +{"mesecons_pistons:piston_normal", "brown"}, +{"mesecons_pistons:piston_sticky", "brown"}, +{"mesecons_blinkyplant:blinky_plant_off", "yellow"}, +{"mesecons_blinkyplant:blinky_plant_on", "yellow"}, +{"mesecons_torch:mesecon_torch_off", "yellow"}, +{"mesecons_torch:mesecon_torch_on", "yellow"}, +{"mesecons_hydroturbine:hydro_turbine_off", "gray"}, +{"mesecons_hydroturbine:hydro_turbine_on", "gray"}, +{"mesecons_pressureplates:pressure_plate_stone_off", "gray"}, +{"mesecons_pressureplates:pressure_plate_stone_on", "gray"}, +{"mesecons_pressureplates:pressure_plate_wood_off", "brown"}, +{"mesecons_pressureplates:pressure_plate_wood_on", "brown"}, +{"mesecons_temperest:mesecon_socket_off", "gray"}, +{"mesecons_temperest:mesecon_socket_on", "red"}, +{"mesecons_temperest:mesecon_inverter_off", "gray"}, +{"mesecons_temperest:mesecon_inverter_on", "red"}, +{"mesecons_temperest:mesecon_plug", "black"}, +{"mesecons_movestones:movestone", "gray"}, +{"mesecons_movestones:sticky_movestone", "gray"}, +} + +reg_colors = {} + +for idx, tbl in pairs(nodename2color) do + nn = tbl[1] + color = tbl[2] + if reg_colors[color] == nil then + local TEMP = { + physical = true, + collisionbox = {-0.1,-0.1,-0.1,0,0,0}, + visual = "sprite", + textures = {"p_"..color..".png"}, + timer = 0, + on_step = function(self, dtime) + self.timer = self.timer + dtime + if self.timer > 1 then + self.object:remove() + end + end, + on_activate = function(self, staticdata) + self.object:setacceleration({x=0, y=-7.5, z=0}) + end, + } + minetest.register_entity("particles:p_"..color, TEMP) + reg_colors[color] = true + end +end + +minetest.register_on_dignode(function(pos, oldnode, digger) + for idx, tbl in pairs(nodename2color) do + if oldnode.name == tbl[1] then + for x = 1,BLOCK_BREAK_PARTICLES,1 do + e = minetest.env:add_entity({x=pos.x+1-(math.random()*1.5),y=pos.y+0.25,z=pos.z+1-(math.random()*1.5)}, "particles:p_"..tbl[2]) + e:setvelocity({x=math.random(),y=1,z=math.random()}) + end + end + end +end) diff --git a/games/minitest/mods/particles/init.lua~ b/games/minitest/mods/particles/init.lua~ new file mode 100644 index 0000000..88227e7 --- /dev/null +++ b/games/minitest/mods/particles/init.lua~ @@ -0,0 +1,142 @@ +------------- Settings -------------- +BLOCK_BREAK_PARTICLES = 7 +------------------------------------- +SMOKE = { + physical = true, + collisionbox = {-0.1,-0.1,-0.1,0,0,0}, + visual = "sprite", + textures = {"smoke.png"}, + on_step = function(self, dtime) + self.object:setacceleration({x=0, y=0.5, z=0}) + self.timer = self.timer + dtime + if self.timer > 3 then + self.object:remove() + end + end, + timer = 0, +} + +minetest.register_entity("particles:smoke", SMOKE) +minetest.register_abm({ + nodenames = {"default:torch"}, + interval = 10, + chance = 10, + action = function(pos) + minetest.env:add_entity({x=pos.x+math.random()*0.5,y=pos.y-0.25,z=pos.z+math.random()*0.5}, "particles:smoke") + end, +}) + +if minetest.get_modpath("jeija") ~= nil then -- Mesecons is installed + MESECONDUST = { + physical = true, + collisionbox = {-0.1,-0.1,-0.1,0,0,0}, + visual = "sprite", + textures = {"mesecondust.png"}, + on_step = function(self, dtime) + self.timer = self.timer + dtime + if self.timer > 2.5 then + self.object:remove() + end + end, + timer = 0, + } + minetest.register_entity("particles:mesecondust", MESECONDUST) + minetest.register_abm({ + nodenames = {"jeija:mesecon_on","jeija:wall_lever_on","jeija:mesecon_torch_on"}, + interval = 1, + chance = 5, + action = function(pos) + minetest.env:add_entity({x=pos.x+math.random()*0.5,y=pos.y,z=pos.z+math.random()*0.5}, "particles:mesecondust") + end, + }) +end + +nodename2color = { +--Brown +{"default:dirt","brown"}, +{"default:chest","brown"}, +{"default:chest_locked","brown"}, +{"default:wood","brown"}, +{"default:tree","brown"}, +{"default:jungletree","brown"}, +{"default:bookshelf","brown"}, +{"default:sign_wall","brown"}, +{"default:ladder","brown"}, +{"default:fence_wood","brown"}, +--Red +{"default:apple","red"}, +{"default:brick","red"}, +--Green +{"default:cactus","green"}, +{"default:junglegrass","green"}, +{"default:dirt_with_grass","green"}, +{"default:sapling","green"}, +{"default:papyrus","green"}, +{"default:leaves","green"}, +--Gray +{"default:clay","gray"}, +{"default:cobble","gray"}, +{"default:furnace","gray"}, +{"default:stone","gray"}, +{"default:stone_with_iron","gray"}, +{"default:steelblock","gray"}, +{"default:rail","gray"}, +{"default:mossycobble","gray"}, +--Yellow +{"default:mese","yellow"}, +{"default:torch","yellow"}, +--Sandcolor +{"default:sand","sandcolor"}, +{"default:sandstone","sandcolor"}, +--Black +{"default:gravel","black"}, +{"default:stone_with_coal","black"}, +--White +{"default:cloud","white"}, +{"default:glass","white"}, +} + +reg_colors = {} + +for idx, tbl in pairs(nodename2color) do + nn = tbl[1] + color = tbl[2] + if reg_colors[color] == nil then + local TEMP = { + physical = true, + collisionbox = {-0.1,-0.1,-0.1,0,0,0}, + visual = "sprite", + textures = {"p_"..color..".png"}, + timer = 0, + on_step = function(self, dtime) + self.timer = self.timer + dtime + if self.timer > 1 then + self.object:remove() + end + end, + on_activate = function(self, staticdata) + self.object:setacceleration({x=0, y=-7.5, z=0}) + end, + } + minetest.register_entity("particles:p_"..color, TEMP) + reg_colors[color] = true + end + func,err = loadstring("\ + minetest.register_on_dignode(function(pos, oldnode, digger) \n\ + if oldnode.name == '"..nn.."' then \n\ + for x = 1,"..BLOCK_BREAK_PARTICLES..",1 do \n\ + e = minetest.env:add_entity({x=(pos.x-0.5)+1-(math.random()*2),y=pos.y+0.25,z=(pos.z-0.5)+1-(math.random()*2)}, 'particles:p_"..color.."') \n\ + e:setvelocity({x=math.random(),y=1,z=math.random()}) \n\ + end \n\ + end \n\ + end) \n") + if func == nil then + print("[Particles] ERROR: color="..color.." nn="..nn.." err='"..err.."'") + local n = function() + return nil + end + n()() -- Prevent Minetest from Starting (call nil) + else + func() + end +end diff --git a/games/minitest/mods/particles/textures/mesecondust.png b/games/minitest/mods/particles/textures/mesecondust.png new file mode 100644 index 0000000..d04f092 Binary files /dev/null and b/games/minitest/mods/particles/textures/mesecondust.png differ diff --git a/games/minitest/mods/particles/textures/p_black.png b/games/minitest/mods/particles/textures/p_black.png new file mode 100644 index 0000000..c36352d Binary files /dev/null and b/games/minitest/mods/particles/textures/p_black.png differ diff --git a/games/minitest/mods/particles/textures/p_brown.png b/games/minitest/mods/particles/textures/p_brown.png new file mode 100644 index 0000000..a5f92eb Binary files /dev/null and b/games/minitest/mods/particles/textures/p_brown.png differ diff --git a/games/minitest/mods/particles/textures/p_gray.png b/games/minitest/mods/particles/textures/p_gray.png new file mode 100644 index 0000000..d9a113d Binary files /dev/null and b/games/minitest/mods/particles/textures/p_gray.png differ diff --git a/games/minitest/mods/particles/textures/p_green.png b/games/minitest/mods/particles/textures/p_green.png new file mode 100644 index 0000000..264b6fa Binary files /dev/null and b/games/minitest/mods/particles/textures/p_green.png differ diff --git a/games/minitest/mods/particles/textures/p_lightgray.png b/games/minitest/mods/particles/textures/p_lightgray.png new file mode 100644 index 0000000..c2c2ad4 Binary files /dev/null and b/games/minitest/mods/particles/textures/p_lightgray.png differ diff --git a/games/minitest/mods/particles/textures/p_red.png b/games/minitest/mods/particles/textures/p_red.png new file mode 100644 index 0000000..1e22d04 Binary files /dev/null and b/games/minitest/mods/particles/textures/p_red.png differ diff --git a/games/minitest/mods/particles/textures/p_sandcolor.png b/games/minitest/mods/particles/textures/p_sandcolor.png new file mode 100644 index 0000000..39c7b2d Binary files /dev/null and b/games/minitest/mods/particles/textures/p_sandcolor.png differ diff --git a/games/minitest/mods/particles/textures/p_white.png b/games/minitest/mods/particles/textures/p_white.png new file mode 100644 index 0000000..7ca04b4 Binary files /dev/null and b/games/minitest/mods/particles/textures/p_white.png differ diff --git a/games/minitest/mods/particles/textures/p_yellow.png b/games/minitest/mods/particles/textures/p_yellow.png new file mode 100644 index 0000000..d848973 Binary files /dev/null and b/games/minitest/mods/particles/textures/p_yellow.png differ diff --git a/games/minitest/mods/particles/textures/smoke.png b/games/minitest/mods/particles/textures/smoke.png new file mode 100644 index 0000000..6e5ecd3 Binary files /dev/null and b/games/minitest/mods/particles/textures/smoke.png differ diff --git a/games/minitest/mods/stairs/README.txt b/games/minitest/mods/stairs/README.txt new file mode 100644 index 0000000..716a677 --- /dev/null +++ b/games/minitest/mods/stairs/README.txt @@ -0,0 +1,26 @@ +Minetest 0.4 mod: stairs +========================= + +License of source code: +----------------------- +Copyright (C) 2011-2012 Kahrl +Copyright (C) 2011-2012 celeron55, Perttu Ahola + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +http://www.gnu.org/licenses/lgpl-2.1.html + +License of media (textures and sounds) +-------------------------------------- +Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) +http://creativecommons.org/licenses/by-sa/3.0/ + +Authors of media files +----------------------- +Everything not listed in here: +Copyright (C) 2010-2012 celeron55, Perttu Ahola + + diff --git a/games/minitest/mods/stairs/depends.txt b/games/minitest/mods/stairs/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/games/minitest/mods/stairs/depends.txt @@ -0,0 +1 @@ +default diff --git a/games/minitest/mods/stairs/init.lua b/games/minitest/mods/stairs/init.lua new file mode 100644 index 0000000..1b00ef3 --- /dev/null +++ b/games/minitest/mods/stairs/init.lua @@ -0,0 +1,146 @@ +-- Minetest 0.4 mod: stairs +-- See README.txt for licensing and other information. + +stairs = {} + +-- Node will be called stairs:stair_ +function stairs.register_stair(subname, recipeitem, groups, images, description) + minetest.register_node("stairs:stair_" .. subname, { + description = description, + drawtype = "nodebox", + tiles = images, + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = true, + groups = groups, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + {-0.5, 0, 0, 0.5, 0.5, 0.5}, + }, + }, + }) + + minetest.register_craft({ + output = 'stairs:stair_' .. subname .. ' 4', + recipe = { + {recipeitem, "", ""}, + {recipeitem, recipeitem, ""}, + {recipeitem, recipeitem, recipeitem}, + }, + }) + + -- Flipped recipe for the silly minecrafters + minetest.register_craft({ + output = 'stairs:stair_' .. subname .. ' 4', + recipe = { + {"", "", recipeitem}, + {"", recipeitem, recipeitem}, + {recipeitem, recipeitem, recipeitem}, + }, + }) +end + +-- Node will be called stairs:slab_ +function stairs.register_slab(subname, recipeitem, groups, images, description) + minetest.register_node("stairs:slab_" .. subname, { + description = description, + drawtype = "nodebox", + tiles = images, + paramtype = "light", + is_ground_content = true, + groups = groups, + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, + on_place = function(itemstack, placer, pointed_thing) + if pointed_thing.type ~= "node" then + return itemstack + end + + -- If it's being placed on an another similar one, replace it with + -- a full block + local slabpos = nil + local slabnode = nil + local p0 = pointed_thing.under + local p1 = pointed_thing.above + local n0 = minetest.env:get_node(p0) + local n1 = minetest.env:get_node(p1) + if n0.name == "stairs:slab_" .. subname then + slabpos = p0 + slabnode = n0 + elseif n1.name == "stairs:slab_" .. subname then + slabpos = p1 + slabnode = n1 + end + if slabpos then + -- Remove the slab at slabpos + minetest.env:remove_node(slabpos) + -- Make a fake stack of a single item and try to place it + local fakestack = ItemStack(recipeitem) + pointed_thing.above = slabpos + fakestack = minetest.item_place(fakestack, placer, pointed_thing) + -- If the item was taken from the fake stack, decrement original + if not fakestack or fakestack:is_empty() then + itemstack:take_item(1) + -- Else put old node back + else + minetest.env:set_node(slabpos, slabnode) + end + return itemstack + end + + -- Otherwise place regularly + return minetest.item_place(itemstack, placer, pointed_thing) + end, + }) + + minetest.register_craft({ + output = 'stairs:slab_' .. subname .. ' 3', + recipe = { + {recipeitem, recipeitem, recipeitem}, + }, + }) +end + +-- Nodes will be called stairs:{stair,slab}_ +function stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab) + stairs.register_stair(subname, recipeitem, groups, images, desc_stair) + stairs.register_slab(subname, recipeitem, groups, images, desc_slab) +end + +stairs.register_stair_and_slab("wood", "default:wood", + {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + {"default_wood.png"}, + "Wooden stair", + "Wooden slab") + +stairs.register_stair_and_slab("stone", "default:stone", + {cracky=3}, + {"default_stone.png"}, + "Stone stair", + "Stone slab") + +stairs.register_stair_and_slab("cobble", "default:cobble", + {cracky=3}, + {"default_cobble.png"}, + "Cobble stair", + "Cobble slab") + +stairs.register_stair_and_slab("brick", "default:brick", + {cracky=3}, + {"default_brick.png"}, + "Brick stair", + "Brick slab") + +stairs.register_stair_and_slab("sandstone", "default:sandstone", + {crumbly=2,cracky=2}, + {"default_sandstone.png"}, + "Sandstone stair", + "Sandstone slab") diff --git a/games/minitest/mods/wool/README.txt b/games/minitest/mods/wool/README.txt new file mode 100644 index 0000000..9db1332 --- /dev/null +++ b/games/minitest/mods/wool/README.txt @@ -0,0 +1,28 @@ +Minetest 0.4 mod: wool +====================== + +Mostly backward-compatible with jordach's 16-color wool mod. + +License of source code: +----------------------- +Copyright (C) 2012 Perttu Ahola (celeron55) + +This program is free software. It comes without any warranty, to +the extent permitted by applicable law. You can redistribute it +and/or modify it under the terms of the Do What The Fuck You Want +To Public License, Version 2, as published by Sam Hocevar. See +http://sam.zoy.org/wtfpl/COPYING for more details. + +License of media (textures and sounds) +-------------------------------------- +Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) +http://creativecommons.org/licenses/by-sa/3.0/ + +Authors of media files +----------------------- +Cisoun: +- wool_black.png wool_brown.png wool_dark_green.png wool_green.png +- wool_magenta.png wool_pink.png wool_violet.png wool_yellow.png wool_blue.png +- wool_cyan.png wool_dark_grey.png wool_grey.png wool_orange.png wool_red.png +- wool_white.png + diff --git a/games/minitest/mods/wool/depends.txt b/games/minitest/mods/wool/depends.txt new file mode 100644 index 0000000..e69de29 diff --git a/games/minitest/mods/wool/init.lua b/games/minitest/mods/wool/init.lua new file mode 100644 index 0000000..c0b4467 --- /dev/null +++ b/games/minitest/mods/wool/init.lua @@ -0,0 +1,44 @@ +-- minetest/wool/init.lua + +-- Backwards compatibility with jordach's 16-color wool mod +minetest.register_alias("wool:dark_blue", "wool:blue") +minetest.register_alias("wool:gold", "wool:yellow") + +local wool = {} +wool.dyes = { + {"white", "White"}, + {"grey", "Grey"}, + {"dark_grey", "Dark Grey"}, + {"black", "Black"}, + {"violet", "Violet"}, + {"blue", "Blue"}, + {"cyan", "Cyan"}, + {"dark_green", "Dark Green"}, + {"green", "Green"}, + {"yellow", "Yellow"}, + {"brown", "Brown"}, + {"orange", "Orange"}, + {"red", "Red"}, + {"magenta", "Magenta"}, + {"pink", "Pink"}, +} + +for _, row in ipairs(wool.dyes) do + local name = row[1] + local desc = row[2] + -- Node Definition + minetest.register_node("wool:"..name, { + description = desc.." Wool", + tile_images = {"wool_"..name..".png"}, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=3}, + }) + if name ~= "white" then + -- Crafting from dye and white wool + minetest.register_craft({ + type = "shapeless", + output = 'wool:'..name..' 16', + recipe = {'dye:'..name, 'wool:white'}, + }) + end +end + diff --git a/games/minitest/mods/wool/textures/wool_black.png b/games/minitest/mods/wool/textures/wool_black.png new file mode 100644 index 0000000..f22e3bb Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_black.png differ diff --git a/games/minitest/mods/wool/textures/wool_blue.png b/games/minitest/mods/wool/textures/wool_blue.png new file mode 100644 index 0000000..826d397 Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_blue.png differ diff --git a/games/minitest/mods/wool/textures/wool_brown.png b/games/minitest/mods/wool/textures/wool_brown.png new file mode 100644 index 0000000..0dcee4b Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_brown.png differ diff --git a/games/minitest/mods/wool/textures/wool_cyan.png b/games/minitest/mods/wool/textures/wool_cyan.png new file mode 100644 index 0000000..372ef45 Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_cyan.png differ diff --git a/games/minitest/mods/wool/textures/wool_dark_green.png b/games/minitest/mods/wool/textures/wool_dark_green.png new file mode 100644 index 0000000..54d12f6 Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_dark_green.png differ diff --git a/games/minitest/mods/wool/textures/wool_dark_grey.png b/games/minitest/mods/wool/textures/wool_dark_grey.png new file mode 100644 index 0000000..c15bec4 Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_dark_grey.png differ diff --git a/games/minitest/mods/wool/textures/wool_green.png b/games/minitest/mods/wool/textures/wool_green.png new file mode 100644 index 0000000..d70fe2b Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_green.png differ diff --git a/games/minitest/mods/wool/textures/wool_grey.png b/games/minitest/mods/wool/textures/wool_grey.png new file mode 100644 index 0000000..86e647c Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_grey.png differ diff --git a/games/minitest/mods/wool/textures/wool_magenta.png b/games/minitest/mods/wool/textures/wool_magenta.png new file mode 100644 index 0000000..c4da6ae Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_magenta.png differ diff --git a/games/minitest/mods/wool/textures/wool_orange.png b/games/minitest/mods/wool/textures/wool_orange.png new file mode 100644 index 0000000..2a76cf9 Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_orange.png differ diff --git a/games/minitest/mods/wool/textures/wool_pink.png b/games/minitest/mods/wool/textures/wool_pink.png new file mode 100644 index 0000000..6d59544 Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_pink.png differ diff --git a/games/minitest/mods/wool/textures/wool_red.png b/games/minitest/mods/wool/textures/wool_red.png new file mode 100644 index 0000000..ab4dd64 Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_red.png differ diff --git a/games/minitest/mods/wool/textures/wool_violet.png b/games/minitest/mods/wool/textures/wool_violet.png new file mode 100644 index 0000000..653af58 Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_violet.png differ diff --git a/games/minitest/mods/wool/textures/wool_white.png b/games/minitest/mods/wool/textures/wool_white.png new file mode 100644 index 0000000..f3371aa Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_white.png differ diff --git a/games/minitest/mods/wool/textures/wool_yellow.png b/games/minitest/mods/wool/textures/wool_yellow.png new file mode 100644 index 0000000..5c5d72f Binary files /dev/null and b/games/minitest/mods/wool/textures/wool_yellow.png differ diff --git a/games/minitest/mods/xdoors/README.txt b/games/minitest/mods/xdoors/README.txt new file mode 100644 index 0000000..48024a0 --- /dev/null +++ b/games/minitest/mods/xdoors/README.txt @@ -0,0 +1,2 @@ +xdoors by xyz +License: WTFPL \ No newline at end of file diff --git a/games/minitest/mods/xdoors/depends.txt b/games/minitest/mods/xdoors/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/games/minitest/mods/xdoors/depends.txt @@ -0,0 +1 @@ +default diff --git a/games/minitest/mods/xdoors/init.lua b/games/minitest/mods/xdoors/init.lua new file mode 100644 index 0000000..c37a4f9 --- /dev/null +++ b/games/minitest/mods/xdoors/init.lua @@ -0,0 +1,149 @@ +-- xDoors mod by xyz + +models = { + { + -- bottom part + {-0.5, -0.5, -0.5, -0.4, 0.5, 0.5}, + -- A + {-0.5, 0.5, -0.5, -0.4, 1.5, -0.3}, + -- B + {-0.5, 0.5, 0.3, -0.4, 1.5, 0.5}, + -- C + {-0.5, 1.3, -0.3, -0.4, 1.5, 0.3}, + -- D + {-0.5, 0.5, -0.3, -0.4, 0.6, 0.3}, + -- E + {-0.5, 0.6, -0.05, -0.4, 1.3, 0.05}, + -- F + {-0.5, 0.9, -0.3, -0.4, 1, -0.05}, + -- G + {-0.5, 0.9, 0.05, -0.4, 1, 0.3} + }, + { + {0.4, -0.5, -0.5, 0.5, 0.5, 0.5}, + {0.4, 0.5, -0.5, 0.5, 1.5, -0.3}, + {0.4, 0.5, 0.3, 0.5, 1.5, 0.5}, + {0.4, 1.3, -0.3, 0.5, 1.5, 0.3}, + {0.4, 0.5, -0.3, 0.5, 0.6, 0.3}, + {0.4, 0.6, -0.05, 0.5, 1.3, 0.05}, + {0.4, 0.9, -0.3, 0.5, 1, -0.05}, + {0.4, 0.9, 0.05, 0.5, 1, 0.3} + }, + { + {-0.5, -0.5, -0.5, 0.5, 0.5, -0.4}, + {-0.5, 0.5, -0.5, -0.3, 1.5, -0.4}, + {0.3, 0.5, -0.5, 0.5, 1.5, -0.4}, + {-0.3, 1.3, -0.5, 0.3, 1.5, -0.4}, + {-0.3, 0.5, -0.5, 0.3, 0.6, -0.4}, + {-0.05, 0.6, -0.5, 0.05, 1.3, -0.4}, + {-0.3, 0.9, -0.5, -0.05, 1, -0.4}, + {0.05, 0.9, -0.5, 0.3, 1, -0.4} + }, + { + {-0.5, -0.5, 0.4, 0.5, 0.5, 0.5}, + {-0.5, 0.5, 0.4, -0.3, 1.5, 0.5}, + {0.3, 0.5, 0.4, 0.5, 1.5, 0.5}, + {-0.3, 1.3, 0.4, 0.3, 1.5, 0.5}, + {-0.3, 0.5, 0.4, 0.3, 0.6, 0.5}, + {-0.05, 0.6, 0.4, 0.05, 1.3, 0.5}, + {-0.3, 0.9, 0.4, -0.05, 1, 0.5}, + {0.05, 0.9, 0.4, 0.3, 1, 0.5} + } +} + +selections = { + {-0.5, -0.5, -0.5, -0.4, 1.5, 0.5}, + {0.5, -0.5, -0.5, 0.4, 1.5, 0.5}, + {-0.5, -0.5, -0.5, 0.5, 1.5, -0.4}, + {-0.5, -0.5, 0.4, 0.5, 1.5, 0.5} +} + +transforms = { + door_1_1 = "door_4_2", + door_4_2 = "door_1_1", + door_2_1 = "door_3_2", + door_3_2 = "door_2_1", + door_3_1 = "door_1_2", + door_1_2 = "door_3_1", + door_4_1 = "door_2_2", + door_2_2 = "door_4_1" +} + +function xdoors_transform(pos, node, puncher) + local x, y = node.name:find(":") + local n = node.name:sub(x + 1) + if transforms[n] ~= nil then + minetest.env:add_node(pos, {name = "xdoors:"..transforms[n]}) + else + print("not implemented") + end +end + +for i = 1, 4 do + for j = 1, 2 do + minetest.register_node("xdoors:door_"..i.."_"..j, { + drawtype = "nodebox", + tile_images = {"default_wood.png"}, + paramtype = "light", + is_ground_content = true, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + drop = "xdoors:door", + node_box = { + type = "fixed", + fixed = models[i] + }, + selection_box = { + type = "fixed", + fixed = { + selections[i] + } + }, + on_punch = xdoors_transform + }) + end +end + +minetest.register_node("xdoors:door", { + description = "Wooden door", + node_placement_prediction = "", + inventory_image = 'door_wood.png', + wield_image = 'door_wood.png', + stack_max = 1, + after_dig_node = function(pos, oldnode, oldmetadata, digger) + item_drop(pos, oldnode, digger) + end, + after_place_node = function(node_pos, placer) + local best_distance = 1e50 + local best_number = 1 + local pos = placer:getpos() + for i = 1, 4 do + local box = minetest.registered_nodes["xdoors:door_"..i.."_1"].selection_box.fixed[1] + box = {box[1] + node_pos.x, box[2] + node_pos.y, box[3] + node_pos.z, box[4] + node_pos.x, box[5] + node_pos.y, box[6] + node_pos.z} + local center = {x = (box[1] + box[4]) / 2, y = (box[2] + box[5]) / 2, z = (box[3] + box[6]) / 2} + local dist = math.pow(math.pow(center.x - pos.x, 2) + math.pow(center.y - pos.y, 2) + math.pow(center.z - pos.z, 2), 0.5) + if dist < best_distance then + best_distance = dist + best_number = i + end + end + minetest.env:add_node(node_pos, {name = "xdoors:door_"..best_number.."_1"}) + end +}) + +minetest.register_on_placenode(function(pos, newnode, placer) + local b_pos = {x = pos.x, y = pos.y - 1, z = pos.z} + local node = minetest.env:get_node(b_pos) + if node.name:find("xdoors:door") ~= nil then + minetest.env:remove_node(pos) + minetest.env:add_item(pos, newnode.name) + end +end) + +minetest.register_craft({ + output = 'xdoors:door', + recipe = { + { 'default:wood', 'default:wood', '' }, + { 'default:wood', 'default:wood', '' }, + { 'default:wood', 'default:wood', '' }, + }, +}) diff --git a/games/minitest/mods/xdoors/textures/door_wood.png b/games/minitest/mods/xdoors/textures/door_wood.png new file mode 100644 index 0000000..120fc98 Binary files /dev/null and b/games/minitest/mods/xdoors/textures/door_wood.png differ