diff --git a/CHANGELOG.md b/CHANGELOG.md index 806f6d5..65844dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,35 @@ # Changelog +## [Jun 15th - 16th 2024] Major Update: Survival Update Pt. 3 + +* This update includes lot's of breaking changes! + +- Added Diamonds and Emeralds +- Added Block Variants of Ores +- Added Wheat +- Added Texture to Haybales +- Haybales Now Spawn Naturally in Grasslands +- Added Bread +- Added Waypoints Useable via the `/waypoint` and `/teleportwaypoint` Commands +- Replace Pickaxe with Wooden Pickaxe +- Nerf Hand and Nerf Wooden Pickaxe Breaking Speeds +- Add Iron Pickaxe and Diamond Pickaxe +- Added Iron and Diamond Sword +- Added Dummy Entity +- Added Spellbooks + - Added Fire Spellbook + - Added Explosion Spellbook +- Removed Coins from Resource Lootbox +- Updated Sponge Texture +- Explosions Now Damage Players +- Fire Now Damages Player +- Lava Now Damages Player +- Implement Crates +- Added Crafting Recipe to Crates +- Changed "Useless" Lootbox Type Color Tint to Purple to Tell the Difference Between Crates +- Dirt Will Now Turn Into Grass if No Block is Above it +- Added Coarse Dirt as a Replacement for the Old Dirt + ## [Jun 15th 2024] Minor Update: Minor Texture Change - Updated the Apple Texture diff --git a/PLANS.md b/PLANS.md new file mode 100644 index 0000000..01cfcd3 --- /dev/null +++ b/PLANS.md @@ -0,0 +1,16 @@ +# Plans + +These plans are for updates past the Survival Update Pt. 2 + +Plans: + +- Combat + - Melees + - Ranged + - Magic + +- Mobs + - Cow + - Pig + - Chicken + - Sheep diff --git a/README.md b/README.md index 6bb3de7..1b4a2cf 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,9 @@ Thanks to Estrella for teaching me how I can make better pixel art! Programming and some textures done by me +Minecraft's textures were a great reference and inspiration for this games item textures. +A lot of the game's item textures are modeled after Minecraft's (For example the Ingot and Magic Book) + ## License Project source code and textures licensed under the GNU LGPL License diff --git a/mods/pyutest_cmds/gameplay.lua b/mods/pyutest_cmds/gameplay.lua new file mode 100644 index 0000000..0353b48 --- /dev/null +++ b/mods/pyutest_cmds/gameplay.lua @@ -0,0 +1,59 @@ +--[[ + Format: + + user = { + name = { + pos = {x = 128, y = 50, z = 256}, + idx = 439 + } + } + +]] +local waypoints = {} + +minetest.register_chatcommand("waypoint", { + params = "", + description = "Creates a waypoint at your position called \nIf waypoint is already set, move the waypoint.", + func = function (name, param) + if waypoints[name] == nil then + waypoints[name] = {} + end + + local player = minetest.get_player_by_name(name) + if player == nil then return end + + if waypoints[name][param] ~= nil then + player:hud_remove(waypoints[name][param].idx) + end + + local pos = player:get_pos() + + waypoints[name][param] = {} + waypoints[name][param].pos = pos + + local idx = player:hud_add({ + hud_elem_type = "waypoint", + name = param, + text = "m", + world_pos = pos, + number = 0xFFFFFFFF, + }) + waypoints[name][param].idx = idx + end +}) + +minetest.register_chatcommand("teleportwaypoint", { + params = "", + description = "Teleport to waypoint NAME", + func = function (name, param) + if waypoints[name] == nil then + waypoints[name] = {} + end + if waypoints[name][param] == nil then return end + + local player = minetest.get_player_by_name(name) + if player == nil then return end + + player:set_pos(waypoints[name][param].pos) + end +}) diff --git a/mods/pyutest_cmds/init.lua b/mods/pyutest_cmds/init.lua index 8ede6a5..f622d0b 100644 --- a/mods/pyutest_cmds/init.lua +++ b/mods/pyutest_cmds/init.lua @@ -1,4 +1,4 @@ PyuTestCmds_Path = minetest.get_modpath("pyutest_cmds") dofile(PyuTestCmds_Path.."/worldedit.lua") - +dofile(PyuTestCmds_Path.."/gameplay.lua") diff --git a/mods/pyutest_core/abms.lua b/mods/pyutest_core/abms.lua index 4985873..1616755 100644 --- a/mods/pyutest_core/abms.lua +++ b/mods/pyutest_core/abms.lua @@ -9,9 +9,16 @@ minetest.register_abm({ end }) +local blocks = {} +for k, v in pairs(minetest.registered_nodes) do + if v.groups["block"] ~= nil and k:find("acid") == nil then + table.insert(blocks, k) + end +end + minetest.register_abm({ label = "Contagious Acid Spread", - nodenames = PyuTestCore.building_blocks, + nodenames = blocks, neighbors = {"pyutest_core:contagious_acid"}, interval = 3.4, chance = 3.7, diff --git a/mods/pyutest_core/blocks.lua b/mods/pyutest_core/blocks.lua index 987c2e3..4b918c7 100644 --- a/mods/pyutest_core/blocks.lua +++ b/mods/pyutest_core/blocks.lua @@ -44,6 +44,8 @@ PyuTestCore.make_building_blocks = function (color, dcolor, tex, colortint, cgro local groups = cgroups or { block = PyuTestCore.BLOCK_BREAKABLE_NORMAL } + groups["block"] = groups["block"] or PyuTestCore.BLOCK_BREAKABLE_NORMAL + local econf = extra_conf or {} local id_block = "pyutest_core:"..color.."_block" local id_carpet = "pyutest_core:"..color.."_carpet" @@ -52,7 +54,7 @@ PyuTestCore.make_building_blocks = function (color, dcolor, tex, colortint, cgro minetest.register_node(id_block, PyuTestCore.util.tableconcat({ description = Translate(dcolor.." Block"), - tiles = {tex}, + tiles = tex, color = colortint, groups = groups, sounds = PyuTestCore.make_node_sounds(), @@ -62,7 +64,7 @@ PyuTestCore.make_building_blocks = function (color, dcolor, tex, colortint, cgro minetest.register_node(id_carpet, PyuTestCore.util.tableconcat({ description = Translate(dcolor .. " Carpet"), - tiles = {tex}, + tiles = tex, groups = groups, color = colortint, drawtype = "nodebox", @@ -76,7 +78,7 @@ PyuTestCore.make_building_blocks = function (color, dcolor, tex, colortint, cgro minetest.register_node(id_slab, PyuTestCore.util.tableconcat({ description = Translate(dcolor.." Slab"), - tiles = {tex}, + tiles = tex, groups = groups, color = colortint, drawtype = "nodebox", @@ -90,7 +92,7 @@ PyuTestCore.make_building_blocks = function (color, dcolor, tex, colortint, cgro minetest.register_node(id_pillar, PyuTestCore.util.tableconcat({ description = Translate(dcolor.." Pillar"), - tiles = {tex}, + tiles = tex, groups = groups, color = colortint, drawtype = "nodebox", @@ -126,7 +128,7 @@ PyuTestCore.make_building_blocks = function (color, dcolor, tex, colortint, cgro }) end -PyuTestCore.make_liquid = function (nsname, sname, desc, groups, tiles) +PyuTestCore.make_liquid = function (nsname, sname, desc, groups, tiles, extra_conf) local function make_liquid_flags(liquidtype) local drawtype = "" @@ -136,7 +138,7 @@ PyuTestCore.make_liquid = function (nsname, sname, desc, groups, tiles) drawtype = "liquid" end - local t = { + local t = PyuTestCore.util.tableconcat({ drawtype = drawtype, waving = 3, walkable = false, @@ -151,53 +153,65 @@ PyuTestCore.make_liquid = function (nsname, sname, desc, groups, tiles) liquid_viscosity = 1, liquid_alternative_flowing = nsname.."_flowing", liquid_alternative_source = nsname.."_source" - } + }, extra_conf or {}) return t end + groups["liquid"] = 1 PyuTestCore.make_node(nsname.."_source", sname.."_source", desc .. " Source", groups, tiles, make_liquid_flags("source")) PyuTestCore.make_node(nsname.."_flowing", sname.."_flowing", "Flowing " .. desc, groups, tiles, make_liquid_flags("flowing")) end -PyuTestCore.make_building_blocks("grass", "Grass", "grass.png", nil, nil, {drop = "pyutest_core:dirt_block"}) -PyuTestCore.make_building_blocks("dirt", "Dirt", "dirt.png", nil) -PyuTestCore.make_building_blocks("stone", "Stone", "stone.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG}) -PyuTestCore.make_building_blocks("iron", "Iron", "iron.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG}) -PyuTestCore.make_building_blocks("wooden", "Wooden", "wood.png", nil) -PyuTestCore.make_building_blocks("snow", "Snow", "snow.png", nil) -PyuTestCore.make_building_blocks("sand", "Sand", "sand.png", nil) -PyuTestCore.make_building_blocks("sandstone", "Sandstone", "sandstone.png", nil) -PyuTestCore.make_building_blocks("ice", "Ice", "ice.png", nil) -PyuTestCore.make_building_blocks("leaves", "Leaves", "leaves.png", nil) -PyuTestCore.make_building_blocks("mushroom", "Mushroom", "mushroom.png", nil) -PyuTestCore.make_building_blocks("mushroom_stem", "Mushroom Stem", "mushroom-stem.png", nil) -PyuTestCore.make_building_blocks("mycelium", "Mycelium", "mycelium.png", nil) -PyuTestCore.make_building_blocks("hellstone", "Hellstone", "hellstone.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG}) -PyuTestCore.make_building_blocks("basalt", "Basalt", "basalt.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG}) -PyuTestCore.make_building_blocks("obsidian", "Obsidian", "obsidian.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_FOREVER}) -PyuTestCore.make_building_blocks("haybale", "Haybale", "haybale.png", nil) -PyuTestCore.make_building_blocks("crying_obsidian", "Crying Obsidian", "crying-obsidian.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_FOREVER}) +PyuTestCore.make_building_blocks("grass", "Grass", {"grass.png"}, nil, nil, {drop = "pyutest_core:dirt_block"}) +PyuTestCore.make_building_blocks("dirt", "Dirt", {"dirt.png"}, nil, nil, { + on_construct = function (pos) + local timer = minetest.get_node_timer(pos) + timer:start(8) + end, -PyuTestCore.make_building_blocks("color_white", "White", "wool.png", "white") -PyuTestCore.make_building_blocks("color_red", "Red", "wool.png", "red") -PyuTestCore.make_building_blocks("color_orange", "Orange", "wool.png", "orange") -PyuTestCore.make_building_blocks("color_yellow", "Yellow", "wool.png", "yellow") -PyuTestCore.make_building_blocks("color_green", "Green", "wool.png", "green") -PyuTestCore.make_building_blocks("color_blue", "Blue", "wool.png", "blue") -PyuTestCore.make_building_blocks("color_purple", "Purple", "wool.png", "purple") -PyuTestCore.make_building_blocks("color_black", "Black", "wool.png", "black") -PyuTestCore.make_building_blocks("color_pink", "Pink", "wool.png", "hotpink") -PyuTestCore.make_building_blocks("color_cherry", "Cherry", "wool.png", "lightpink") -PyuTestCore.make_building_blocks("color_brown", "Brown", "wool.png", "brown") -PyuTestCore.make_building_blocks("color_gray", "Gray", "wool.png", "gray") -PyuTestCore.make_building_blocks("color_teal", "Teal", "wool.png", "teal") -PyuTestCore.make_building_blocks("color_cyan", "Cyan", "wool.png", "cyan") -PyuTestCore.make_building_blocks("color_yellowgreen", "Yellow Green", "wool.png", "yellowgreen") -PyuTestCore.make_building_blocks("color_plum", "Plum", "wool.png", "plum") -PyuTestCore.make_building_blocks("color_gold", "Gold", "wool.png", "gold") -PyuTestCore.make_building_blocks("color_skyblue", "Sky Blue", "wool.png", "skyblue") -PyuTestCore.make_building_blocks("color_darkviolet", "Dark Violet", "wool.png", "darkviolet") -PyuTestCore.make_building_blocks("color_violet", "Violet", "wool.png", "violet") + on_timer = function (pos) + if minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name == "air" then + minetest.set_node(pos, {name = "pyutest_core:grass_block"}) + end + end +}) +PyuTestCore.make_building_blocks("coarse_dirt", "Coarse Dirt", {"dirt.png"}, nil) +PyuTestCore.make_building_blocks("stone", "Stone", {"stone.png"}, nil, {block = PyuTestCore.BLOCK_BREAKABLE_MIDDLE}) +PyuTestCore.make_building_blocks("wooden", "Wooden", {"wood.png"}, nil, {block = PyuTestCore.BLOCK_BREAKABLE_CHOPPY}) +PyuTestCore.make_building_blocks("snow", "Snow", {"snow.png"}, nil) +PyuTestCore.make_building_blocks("sand", "Sand", {"sand.png"}, nil) +PyuTestCore.make_building_blocks("sandstone", "Sandstone", {"sandstone.png"}, nil) +PyuTestCore.make_building_blocks("ice", "Ice", {"ice.png"}, nil) +PyuTestCore.make_building_blocks("leaves", "Leaves", {"leaves.png"}, nil) +PyuTestCore.make_building_blocks("mushroom", "Mushroom", {"mushroom.png"}, nil) +PyuTestCore.make_building_blocks("mushroom_stem", "Mushroom Stem", {"mushroom-stem.png"}, nil) +PyuTestCore.make_building_blocks("mycelium", "Mycelium", {"mycelium.png"}, nil) +PyuTestCore.make_building_blocks("hellstone", "Hellstone", {"hellstone.png"}, nil, {block = PyuTestCore.BLOCK_BREAKABLE_MIDDLE}) +PyuTestCore.make_building_blocks("basalt", "Basalt", {"basalt.png"}, nil, {block = PyuTestCore.BLOCK_BREAKABLE_MIDDLE}) +PyuTestCore.make_building_blocks("obsidian", "Obsidian", {"obsidian.png"}, nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG}) +PyuTestCore.make_building_blocks("haybale", "Haybale", {"haybale-top-bottom.png", "haybale-top-bottom.png", "haybale.png"}, nil) +PyuTestCore.make_building_blocks("crying_obsidian", "Crying Obsidian", {"crying-obsidian.png"}, nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG}) + +PyuTestCore.make_building_blocks("color_white", "White", {"wool.png"}, "white") +PyuTestCore.make_building_blocks("color_red", "Red", {"wool.png"}, "red") +PyuTestCore.make_building_blocks("color_orange", "Orange", {"wool.png"}, "orange") +PyuTestCore.make_building_blocks("color_yellow", "Yellow", {"wool.png"}, "yellow") +PyuTestCore.make_building_blocks("color_green", "Green", {"wool.png"}, "green") +PyuTestCore.make_building_blocks("color_blue", "Blue", {"wool.png"}, "blue") +PyuTestCore.make_building_blocks("color_purple", "Purple", {"wool.png"}, "purple") +PyuTestCore.make_building_blocks("color_black", "Black", {"wool.png"}, "black") +PyuTestCore.make_building_blocks("color_pink", "Pink", {"wool.png"}, "hotpink") +PyuTestCore.make_building_blocks("color_cherry", "Cherry", {"wool.png"}, "lightpink") +PyuTestCore.make_building_blocks("color_brown", "Brown", {"wool.png"}, "brown") +PyuTestCore.make_building_blocks("color_gray", "Gray", {"wool.png"}, "gray") +PyuTestCore.make_building_blocks("color_teal", "Teal", {"wool.png"}, "teal") +PyuTestCore.make_building_blocks("color_cyan", "Cyan", {"wool.png"}, "cyan") +PyuTestCore.make_building_blocks("color_yellowgreen", "Yellow Green", {"wool.png"}, "yellowgreen") +PyuTestCore.make_building_blocks("color_plum", "Plum", {"wool.png"}, "plum") +PyuTestCore.make_building_blocks("color_gold", "Gold", {"wool.png"}, "gold") +PyuTestCore.make_building_blocks("color_skyblue", "Sky Blue", {"wool.png"}, "skyblue") +PyuTestCore.make_building_blocks("color_darkviolet", "Dark Violet", {"wool.png"}, "darkviolet") +PyuTestCore.make_building_blocks("color_violet", "Violet", {"wool.png"}, "violet") PyuTestCore.make_node("pyutest_core:light", "light", "Light", { snappy = 1, @@ -361,7 +375,7 @@ PyuTestCore.make_node("pyutest_core:tree_sapling", "tree_sapling", "Tree Sapling PyuTestCore.make_node("pyutest_core:trapdoor", "trapdoor", "Trapdoor", { choppy = 1, - block = PyuTestCore.BLOCK_BREAKABLE_NORMAL + block = PyuTestCore.BLOCK_BREAKABLE_CHOPPY }, {"trapdoor.png"}, { drawtype = "nodebox", paramtype = "light", @@ -374,7 +388,7 @@ PyuTestCore.make_node("pyutest_core:trapdoor", "trapdoor", "Trapdoor", { PyuTestCore.make_node("pyutest_core:contagious_acid", "acid", "Contagious Acid", { fleshy = 1, - block = PyuTestCore.BLOCK_BREAKABLE_LONG, + block = PyuTestCore.BLOCK_BREAKABLE_MIDDLE, }, {"acid.png"}, {}) PyuTestCore.make_node("pyutest_core:barrier", "barrier", "Barrier", { @@ -396,7 +410,7 @@ PyuTestCore.make_node("pyutest_core:fire", "fire", "Fire", { buildable_to = true, paramtype = "light", sunlight_propagates = true, - -- inventory_image = "fire.png" + damage_per_second = 1 }) PyuTestCore.make_node("pyutest_core:tnt", "tnt", "TNT", { @@ -404,10 +418,7 @@ PyuTestCore.make_node("pyutest_core:tnt", "tnt", "TNT", { }, { "tnt-top-bottom.png", "tnt-top-bottom.png", - "tnt-side.png", - "tnt-side.png", - "tnt-side.png", - "tnt-side.png" + "tnt-side.png" -- Affects all other sides }, { on_rightclick = function (pos) local timer = minetest.get_node_timer(pos) @@ -415,27 +426,46 @@ PyuTestCore.make_node("pyutest_core:tnt", "tnt", "TNT", { end, on_timer = function (pos) - PyuTestCore.create_explosion(pos, 3, true) + PyuTestCore.create_explosion(pos, 3, true, 3) end }) PyuTestCore.make_node("pyutest_core:crate", "crate", "Crate", { - block = PyuTestCore.BLOCK_BREAKABLE_NORMAL + block = PyuTestCore.BLOCK_BREAKABLE_CHOPPY }, {"crate.png"}, { - on_rightclick = function (pos, node, clicker) - local barrel_name = string.format("crate_x%d_y%d_z%d", pos.x, pos.y, pos.z) - local inventory = minetest.get_inventory({type="detached", name = barrel_name}) - if inventory == nil then - inventory = minetest.create_detached_inventory(barrel_name) - inventory:set_size("main", 64) - inventory:set_width("main", 8) + on_construct = function (pos) + local meta = minetest.get_meta(pos) + local inventory = meta:get_inventory() + inventory:set_size("main", 8 * 4) + end, + can_dig = function (pos, player) + local meta = minetest.get_meta(pos) + local inventory = meta:get_inventory() + local empty = inventory:is_empty("main") + + if not empty then + minetest.chat_send_player(player:get_player_name(), "Cannot destroy crate, it's not empty!") end + return empty + end, + + on_rightclick = function (pos, node, clicker) + local spos = string.format("%d,%d,%d", pos.x, pos.y, pos.z) + local formspec = + "size[8,8]" .. + "list[nodemeta:"..spos..";main;0,0;8,4;]" .. + "list[current_player;main;0,5;8,3;]" .. + "listring[nodemeta:"..spos..";main]" .. + "listring[current_player;main]" + minetest.show_formspec(clicker:get_player_name(), string.format("pyutest_core:crate_%d_%d_%d", pos.x, pos.y, pos.z), formspec) end }) PyuTestCore.make_liquid("pyutest_core:water", "water", "Water", {}, {"water.png"}) -PyuTestCore.make_liquid("pyutest_core:lava", "lava", "Lava", {}, {"lava.png"}) +PyuTestCore.make_liquid("pyutest_core:lava", "lava", "Lava", {}, {"lava.png"}, { + damage_per_second = 2 +}) PyuTestCore.make_liquid("pyutest_core:oil", "oil", "Oil", {}, {"oil.png"}) PyuTestCore.make_liquid("pyutest_core:liquid_acid", "liquid_acid", "Acid", {}, {"acid.png"}) diff --git a/mods/pyutest_core/combat.lua b/mods/pyutest_core/combat.lua new file mode 100644 index 0000000..1e4f824 --- /dev/null +++ b/mods/pyutest_core/combat.lua @@ -0,0 +1,54 @@ +PyuTestCore.make_spellbook = function (nsname, sname, desc, color, action) + if action == nil then + action = function(_, _, _)end + end + + PyuTestCore.make_item(nsname, sname, desc, {}, "spellbook.png", { + color = color, + on_use = function (itemstack, user, pointed_thing) + local pos = user:get_pos() + minetest.sound_play({name = "spellbook_action", gain = 0.75}, {pos = pos}) + action(itemstack, user, pointed_thing) + end, + }) +end + +PyuTestCore.make_sword = function (nsname, sname, desc, texture, damage, durability) + PyuTestCore.make_tool(nsname, sname, desc, {}, texture, { + stack_max = 1, + tool_capabilities = { + groupcaps = { + block = { + uses = durability / 2 + } + }, + punch_attack_uses = durability, + damage_groups = {fleshy = damage} + } + }) +end + +PyuTestCore.make_sword("pyutest_core:iron_sword", "iron_sword", "Iron Sword", "iron-sword.png", 7, 400) +PyuTestCore.make_sword("pyutest_core:diamond_sword", "diamond_sword", "Diamond Sword", "diamond-sword.png", 12, 600) + +PyuTestCore.make_spellbook("pyutest_core:explosions_spellbook", "explosions_spellbook", "Spellbook of Explosions", "gray", function (itemstack, user) + PyuTestCore.create_explosion(user:get_pos(), 3, false, 4, user) +end) + +PyuTestCore.make_spellbook("pyutest_core:fire_spellbook", "fire_spellbook", "Spellbook of Fire", "orange", function (itemstack, user) + local range = 2 + + local function replace(pos) + local node = minetest.get_node_or_nil(pos) + if node == nil then return end + if node.name ~= "air" then return end + minetest.set_node(pos, {name = "pyutest_core:fire"}) + end + + for dx = -range, range do + for dz = -range, range do + local pos = user:get_pos() + replace({x = pos.x + dx, y = pos.y, z = pos.z + dz}) + end + end +end) diff --git a/mods/pyutest_core/crafts.lua b/mods/pyutest_core/crafts.lua index 6cfe019..6ae5149 100644 --- a/mods/pyutest_core/crafts.lua +++ b/mods/pyutest_core/crafts.lua @@ -19,9 +19,11 @@ minetest.register_craft({ minetest.register_craft({ output = "pyutest_core:contagious_acid 3", recipe = { - {"pyutest_core:mushroom_block", "pyutest_core:mushroom_stem_block"}, - {"pyutest_core:dirt_block"} - } + "pyutest_core:mushroom_block", + "pyutest_core:mushroom_stem_block", + "pyutest_core:dirt_block" + }, + type = "shapeless" }) minetest.register_craft({ @@ -48,25 +50,86 @@ minetest.register_craft({ } }) -minetest.register_craft({ - output = "pyutest_core:iron_block", - recipe = { - {"pyutest_core:iron_ingot", "pyutest_core:iron_ingot"}, - {"pyutest_core:iron_ingot", "pyutest_core:iron_ingot"} - } -}) - minetest.register_craft({ output = "pyutest_core:coin 4", recipe = { - {"pyutest_core:gold_ingot", "pyutest_core:gold_ingot"}, - {"pyutest_core:gold_ingot", "pyutest_core:gold_ingot"} + {"pyutest_core:gold_ingot", "pyutest_core:gold_ingot", "pyutest_core:gold_ingot"}, + {"pyutest_core:gold_ingot", "pyutest_core:gold_ingot", "pyutest_core:gold_ingot"}, + {"pyutest_core:gold_ingot", "pyutest_core:gold_ingot", "pyutest_core:gold_ingot"} } }) minetest.register_craft({ - output = "pyutest_core:gold_ingot 4", + output = "pyutest_core:gold_ingot 9", recipe = { {"pyutest_core:coin"} } }) + +minetest.register_craft({ + output = "pyutest_core:wheat 4", + recipe = { + "pyutest_core:haybale_block" + }, + type = "shapeless" +}) + +minetest.register_craft({ + output = "pyutest_core:haybale_block", + recipe = { + {"pyutest_core:wheat", "pyutest_core:wheat"}, + {"pyutest_core:wheat", "pyutest_core:wheat"} + } +}) + +minetest.register_craft({ + output = "pyutest_core:bread 3", + recipe = { + {"pyutest_core:wheat", "pyutest_core:wheat", "pyutest_core:wheat"} + } +}) + +minetest.register_craft({ + output = "pyutest_core:iron_pickaxe", + recipe = { + {"pyutest_core:iron_ingot", "pyutest_core:iron_ingot", "pyutest_core:iron_ingot"}, + {"", "pyutest_core:stick", ""}, + {"", "pyutest_core:stick", ""} + } +}) + +minetest.register_craft({ + output = "pyutest_core:sword", + recipe = { + {"pyutest_core:iron_ingot"}, + {"pyutest_core:iron_ingot"}, + {"pyutest_core:stick"} + } +}) + +minetest.register_craft({ + output = "pyutest_core:diamond_pickaxe", + recipe = { + {"pyutest_core:diamond_shard", "pyutest_core:diamond_shard", "pyutest_core:diamond_shard"}, + {"", "pyutest_core:stick", ""}, + {"", "pyutest_core:stick", ""} + } +}) + +minetest.register_craft({ + output = "pyutest_core:diamond_sword", + recipe = { + {"pyutest_core:diamond_shard"}, + {"pyutest_core:diamond_shard"}, + {"pyutest_core:stick"} + } +}) + +minetest.register_craft({ + output = "pyutest_core:crate 2", + recipe = { + {"pyutest_core:wooden_block", "pyutest_core:wooden_block", "pyutest_core:wooden_block"}, + {"pyutest_core:wooden_block", "", "pyutest_core:wooden_block"}, + {"pyutest_core:wooden_block", "pyutest_core:wooden_block", "pyutest_core:wooden_block"} + } +}) diff --git a/mods/pyutest_core/init.lua b/mods/pyutest_core/init.lua index 44000fd..393b110 100644 --- a/mods/pyutest_core/init.lua +++ b/mods/pyutest_core/init.lua @@ -1,14 +1,17 @@ Translate = minetest.get_translator("pyutest_core") PyuTestCore = { - BLOCK_BREAKABLE_INSTANT = 0, - BLOCK_BREAKABLE_NORMAL = 1, + BLOCK_BREAKABLE_INSTANT = 6, + BLOCK_BREAKABLE_NORMAL = 5, + BLOCK_BREAKABLE_CHOPPY = 4, + BLOCK_BREAKABLE_MIDDLE = 3, BLOCK_BREAKABLE_LONG = 2, - BLOCK_BREAKABLE_FOREVER = 3, + BLOCK_BREAKABLE_FOREVER = 1, util = { toint = function (float) return tonumber(string.format("%d", float)) end, + tableconcat = function (t1, t2) local nt = t1 for k, v in pairs(t2) do @@ -29,10 +32,12 @@ dofile(PyuTestCore_Path.."/utils.lua") -- Utilities -- Core Game Code dofile(PyuTestCore_Path.."/blocks.lua") dofile(PyuTestCore_Path.."/mapgen.lua") -dofile(PyuTestCore_Path.."/abms.lua") dofile(PyuTestCore_Path.."/tools.lua") dofile(PyuTestCore_Path.."/player.lua") dofile(PyuTestCore_Path.."/lootboxes.lua") dofile(PyuTestCore_Path.."/sfinv.lua") dofile(PyuTestCore_Path.."/ores.lua") dofile(PyuTestCore_Path.."/crafts.lua") +dofile(PyuTestCore_Path.."/abms.lua") +dofile(PyuTestCore_Path.."/mobs.lua") +dofile(PyuTestCore_Path.."/combat.lua") diff --git a/mods/pyutest_core/lootboxes.lua b/mods/pyutest_core/lootboxes.lua index 755779e..58a4f06 100644 --- a/mods/pyutest_core/lootboxes.lua +++ b/mods/pyutest_core/lootboxes.lua @@ -1,5 +1,5 @@ PyuTestCore.LOOTBOX_USEFULLNESS = { - USELESS = "white", + USELESS = "purple", AVERAGE = "lightblue", USEFUL = "coral", AMAZING = "cyan" @@ -9,7 +9,7 @@ PyuTestCore.make_lootbox = function (type, dtype, items, usefullness) local id = "pyutest_core:"..type.."_lootbox" minetest.register_node(id, { description = Translate(dtype .. " Lootbox"), - groups = {block = PyuTestCore.BLOCK_BREAKABLE_LONG}, + groups = {block = PyuTestCore.BLOCK_BREAKABLE_CHOPPY}, tiles = {"crate.png"}, color = usefullness, sounds = PyuTestCore.make_node_sounds(), @@ -38,7 +38,6 @@ PyuTestCore.make_lootbox("resource", "Resource", { ItemStack("pyutest_core:gunpowder 4"), ItemStack("pyutest_core:stick 6"), ItemStack("pyutest_core:sugar 3"), - ItemStack("pyutest_core:coin 4"), ItemStack("pyutest_core:tree_sapling 2"), ItemStack("pyutest_core:apple 5") }, PyuTestCore.LOOTBOX_USEFULLNESS.AVERAGE) diff --git a/mods/pyutest_core/mapgen.lua b/mods/pyutest_core/mapgen.lua index 123293d..3a48170 100644 --- a/mods/pyutest_core/mapgen.lua +++ b/mods/pyutest_core/mapgen.lua @@ -2,7 +2,7 @@ minetest.register_alias("mapgen_stone", "pyutest_core:stone_block") minetest.register_alias("mapgen_water_source", "pyutest_core:water_source") minetest.register_alias("mapgen_river_water_source", "pyutest_core:water_source") minetest.register_alias("mapgen_lava_source", "pyutest_core:water_source") -minetest.register_alias("mapgen_singlenode", "pyutest_core:stone_block") +minetest.register_alias("mapgen_singlenode", "air") -- Biomes @@ -136,10 +136,10 @@ minetest.register_biome({ minetest.register_biome({ name = "wasteland", - node_top = "pyutest_core:dirt_block", + node_top = "pyutest_core:coarse_dirt_block", depth_top = 1, - node_filler = "pyutest_core:dirt_block", + node_filler = "pyutest_core:coarse_dirt_block", depth_filler = 3, node_water_top = "pyutest_core:ice_block", diff --git a/mods/pyutest_core/mobs.lua b/mods/pyutest_core/mobs.lua new file mode 100644 index 0000000..dfa7a0c --- /dev/null +++ b/mods/pyutest_core/mobs.lua @@ -0,0 +1,22 @@ +local Dummy = { + initial_properties = { + hp_max = 20, + physical = true, + visual = "upright_sprite", + collide_with_objects = false, + textures = {"player.png", "player_back.png"}, + visual_size = {x = 1, y = 2}, + nametag = "Dummy\nThis is not a human", + automatic_rotate = 15, + } +} + +function Dummy:on_rightclick(clicker) + self.object:set_velocity({x = 0, y = 10, z = 0}) +end + +function Dummy:on_step(dtime) + self.object:add_velocity({x = 0, y = -1 * dtime, z = 0}) +end + +minetest.register_entity("pyutest_core:dummy", Dummy) diff --git a/mods/pyutest_core/ores.lua b/mods/pyutest_core/ores.lua index 67e2a75..96c6d01 100644 --- a/mods/pyutest_core/ores.lua +++ b/mods/pyutest_core/ores.lua @@ -1,13 +1,15 @@ -PyuTestCore.make_ore = function (id, desc, ifix, idfix, btxt, itxt, color, scarcity, count) +PyuTestCore.make_ore = function (id, desc, ifix, idfix, btxt, itxt, color, y_max, scarcity, count, btype) local oid = "pyutest_core:"..id.."_ore" local iid = "pyutest_core:"..id.."_"..ifix + local block_type = btype ~= nil and btype or PyuTestCore.BLOCK_BREAKABLE_MIDDLE minetest.register_node(oid, { description = Translate(desc .. " Ore"), - groups = {block = PyuTestCore.BLOCK_BREAKABLE_LONG}, + groups = {block = block_type}, tiles = {btxt}, drop = iid .. " " .. tostring(count or 1), - sounds = PyuTestCore.make_node_sounds() + sounds = PyuTestCore.make_node_sounds(), + light_source = 3.9, -- Make ores emit little light }) minetest.register_craftitem(iid, { @@ -24,12 +26,36 @@ PyuTestCore.make_ore = function (id, desc, ifix, idfix, btxt, itxt, color, scarc clust_scarcity = scarcity * scarcity * scarcity, -- I spent 1 hour debugging this just because I mispelled scarcity as scarity :sob: clust_num_ores = 5, clust_size = 3, - y_max = 32, + y_max = y_max, y_min = PyuTestCore_WorldBottom, biomes = PyuTestCore.BIOMES, }) + + PyuTestCore.make_building_blocks(id, desc, {"metal.png"}, color, { + block = block_type + }) + + local bid = "pyutest_core:"..id.."_block" + minetest.register_craft({ + output = bid, + recipe = { + {iid, iid}, + {iid, iid} + } + }) + + minetest.register_craft({ + output = iid .. " 4", + recipe = { + bid + }, + type = "shapeless" + }) end -PyuTestCore.make_ore("coal", "Coal", "lump", "Lump", "ore-coal.png", "lump.png", {r = 32, g = 32, b = 32}, 8, 5) -PyuTestCore.make_ore("iron", "Iron", "ingot", "Ingot", "ore-iron.png", "ingot.png", nil, 8, 4) -PyuTestCore.make_ore("gold", "Gold", "ingot", "Ingot", "ore-gold.png", "ingot.png", "gold", 13.5, 2) + +PyuTestCore.make_ore("coal", "Coal", "lump", "Lump", "ore-coal.png", "lump.png", {r = 32, g = 32, b = 32}, 48, 8, 5) +PyuTestCore.make_ore("iron", "Iron", "ingot", "Ingot", "ore-iron.png", "ingot.png", nil, 21, 12, 4) +PyuTestCore.make_ore("gold", "Gold", "ingot", "Ingot", "ore-gold.png", "ingot.png", "gold", -50, 14.5, 3, PyuTestCore.BLOCK_BREAKABLE_LONG) +PyuTestCore.make_ore("diamond", "Diamond", "shard", "Shard", "ore-diamond.png", "shard.png", "cyan", -60, 15.7, 3, PyuTestCore.BLOCK_BREAKABLE_LONG) +PyuTestCore.make_ore("emerald", "Emerald", "shard", "Shard", "ore-emerald.png", "shard.png", "seagreen", -110, 17.3, 1, PyuTestCore.BLOCK_BREAKABLE_LONG) diff --git a/mods/pyutest_core/player.lua b/mods/pyutest_core/player.lua index 7449f92..f447b52 100644 --- a/mods/pyutest_core/player.lua +++ b/mods/pyutest_core/player.lua @@ -1,3 +1,11 @@ +-- player setup +minetest.register_on_joinplayer(function (player) + if player == nil then return end + player:get_inventory():set_width("main", 8) + player:get_inventory():set_size("main", 8 * 4) + player:hud_set_hotbar_itemcount(9) +end) + -- player physics local function set_player_speed(player, speed) player:set_physics_override({ @@ -29,14 +37,17 @@ minetest.override_item("", { groupcaps = { block = { times = { - [PyuTestCore.BLOCK_BREAKABLE_INSTANT] = 0.25, - [PyuTestCore.BLOCK_BREAKABLE_NORMAL] = 0.4, - [PyuTestCore.BLOCK_BREAKABLE_LONG] = 4, + [PyuTestCore.BLOCK_BREAKABLE_INSTANT] = 0.35, + [PyuTestCore.BLOCK_BREAKABLE_NORMAL] = 0.85, + [PyuTestCore.BLOCK_BREAKABLE_CHOPPY] = 3, + [PyuTestCore.BLOCK_BREAKABLE_MIDDLE] = 5.5, + [PyuTestCore.BLOCK_BREAKABLE_LONG] = 8, [PyuTestCore.BLOCK_BREAKABLE_FOREVER] = 12 }, uses = 0 } }, - punch_attack_uses = 0 + punch_attack_uses = 0, + damage_groups = {fleshy = 1} } }) diff --git a/mods/pyutest_core/sounds/spellbook_action.ogg b/mods/pyutest_core/sounds/spellbook_action.ogg new file mode 100644 index 0000000..b503b46 Binary files /dev/null and b/mods/pyutest_core/sounds/spellbook_action.ogg differ diff --git a/mods/pyutest_core/textures/apple.png b/mods/pyutest_core/textures/apple.png index 0f2b26b..6149613 100644 Binary files a/mods/pyutest_core/textures/apple.png and b/mods/pyutest_core/textures/apple.png differ diff --git a/mods/pyutest_core/textures/bread.png b/mods/pyutest_core/textures/bread.png new file mode 100644 index 0000000..764d783 Binary files /dev/null and b/mods/pyutest_core/textures/bread.png differ diff --git a/mods/pyutest_core/textures/diamond-pickaxe.png b/mods/pyutest_core/textures/diamond-pickaxe.png new file mode 100644 index 0000000..6393351 Binary files /dev/null and b/mods/pyutest_core/textures/diamond-pickaxe.png differ diff --git a/mods/pyutest_core/textures/diamond-sword.png b/mods/pyutest_core/textures/diamond-sword.png new file mode 100644 index 0000000..c4e369e Binary files /dev/null and b/mods/pyutest_core/textures/diamond-sword.png differ diff --git a/mods/pyutest_core/textures/grass-plant.png b/mods/pyutest_core/textures/grass-plant.png index 0ac1d95..cd64154 100644 Binary files a/mods/pyutest_core/textures/grass-plant.png and b/mods/pyutest_core/textures/grass-plant.png differ diff --git a/mods/pyutest_core/textures/haybale-top-bottom.png b/mods/pyutest_core/textures/haybale-top-bottom.png new file mode 100644 index 0000000..ea6d1c3 Binary files /dev/null and b/mods/pyutest_core/textures/haybale-top-bottom.png differ diff --git a/mods/pyutest_core/textures/haybale.png b/mods/pyutest_core/textures/haybale.png new file mode 100644 index 0000000..9ca8885 Binary files /dev/null and b/mods/pyutest_core/textures/haybale.png differ diff --git a/mods/pyutest_core/textures/iron-pickaxe.png b/mods/pyutest_core/textures/iron-pickaxe.png new file mode 100644 index 0000000..c30021e Binary files /dev/null and b/mods/pyutest_core/textures/iron-pickaxe.png differ diff --git a/mods/pyutest_core/textures/iron-sword.png b/mods/pyutest_core/textures/iron-sword.png new file mode 100644 index 0000000..13c19e7 Binary files /dev/null and b/mods/pyutest_core/textures/iron-sword.png differ diff --git a/mods/pyutest_core/textures/iron.png b/mods/pyutest_core/textures/iron.png deleted file mode 100644 index ac76d88..0000000 Binary files a/mods/pyutest_core/textures/iron.png and /dev/null differ diff --git a/mods/pyutest_core/textures/metal.png b/mods/pyutest_core/textures/metal.png new file mode 100644 index 0000000..699c49a Binary files /dev/null and b/mods/pyutest_core/textures/metal.png differ diff --git a/mods/pyutest_core/textures/ore-diamond.png b/mods/pyutest_core/textures/ore-diamond.png new file mode 100644 index 0000000..740ec22 Binary files /dev/null and b/mods/pyutest_core/textures/ore-diamond.png differ diff --git a/mods/pyutest_core/textures/ore-emerald.png b/mods/pyutest_core/textures/ore-emerald.png new file mode 100644 index 0000000..a9e2cea Binary files /dev/null and b/mods/pyutest_core/textures/ore-emerald.png differ diff --git a/mods/pyutest_core/textures/shard.png b/mods/pyutest_core/textures/shard.png new file mode 100644 index 0000000..a12ef53 Binary files /dev/null and b/mods/pyutest_core/textures/shard.png differ diff --git a/mods/pyutest_core/textures/spellbook.png b/mods/pyutest_core/textures/spellbook.png new file mode 100644 index 0000000..5905977 Binary files /dev/null and b/mods/pyutest_core/textures/spellbook.png differ diff --git a/mods/pyutest_core/textures/sponge.png b/mods/pyutest_core/textures/sponge.png index cf5c354..06d8301 100644 Binary files a/mods/pyutest_core/textures/sponge.png and b/mods/pyutest_core/textures/sponge.png differ diff --git a/mods/pyutest_core/textures/wheat.png b/mods/pyutest_core/textures/wheat.png new file mode 100644 index 0000000..fcd660b Binary files /dev/null and b/mods/pyutest_core/textures/wheat.png differ diff --git a/mods/pyutest_core/textures/pickaxe.png b/mods/pyutest_core/textures/wooden-pickaxe.png similarity index 100% rename from mods/pyutest_core/textures/pickaxe.png rename to mods/pyutest_core/textures/wooden-pickaxe.png diff --git a/mods/pyutest_core/tools.lua b/mods/pyutest_core/tools.lua index f69918d..53118f1 100644 --- a/mods/pyutest_core/tools.lua +++ b/mods/pyutest_core/tools.lua @@ -34,20 +34,77 @@ PyuTestCore.make_item = function (nsname, sname, desc, groups, wield_image, extr minetest.register_alias(sname, nsname) end -PyuTestCore.make_tool("pyutest_core:pickaxe", "pickaxe", "Pickaxe", {}, "pickaxe.png", { +PyuTestCore.make_food = function (nsname, sname, desc, wield_image, health_fill, extra_code) + local code = extra_code or function()end + + PyuTestCore.make_item(nsname, sname, desc, {}, wield_image, { + on_use = function (itemstack, user, pt) + if user == nil then return end + minetest.sound_play({name = "eat", gain = 1}, {pos = user:get_pos(), start_time = 1.2}) + minetest.do_item_eat(health_fill, "", itemstack, user, pt) + code() + end + }) +end + +PyuTestCore.make_tool("pyutest_core:wooden_pickaxe", "wooden_pickaxe", "Wooden Pickaxe", {}, "wooden-pickaxe.png", { stack_max = 1, tool_capabilities = { groupcaps = { block = { times = { - [PyuTestCore.BLOCK_BREAKABLE_INSTANT] = 0.025, - [PyuTestCore.BLOCK_BREAKABLE_NORMAL] = 0.25, - [PyuTestCore.BLOCK_BREAKABLE_LONG] = 0.45, - [PyuTestCore.BLOCK_BREAKABLE_FOREVER] = 2 + [PyuTestCore.BLOCK_BREAKABLE_INSTANT] = 0.085, + [PyuTestCore.BLOCK_BREAKABLE_NORMAL] = 0.65, + [PyuTestCore.BLOCK_BREAKABLE_CHOPPY] = 1.2, + [PyuTestCore.BLOCK_BREAKABLE_MIDDLE] = 2, }, - uses = 600 + uses = 100, } - } + }, + punch_attack_uses = 50, + damage_groups = {fleshy = 2} + } +}) + +PyuTestCore.make_tool("pyutest_core:iron_pickaxe", "iron_pickaxe", "Iron Pickaxe", {}, "iron-pickaxe.png", { + stack_max = 1, + tool_capabilities = { + groupcaps = { + block = { + times = { + [PyuTestCore.BLOCK_BREAKABLE_INSTANT] = 0.035, + [PyuTestCore.BLOCK_BREAKABLE_NORMAL] = 0.35, + [PyuTestCore.BLOCK_BREAKABLE_CHOPPY] = 0.7, + [PyuTestCore.BLOCK_BREAKABLE_MIDDLE] = 1, + [PyuTestCore.BLOCK_BREAKABLE_LONG] = 2, + [PyuTestCore.BLOCK_BREAKABLE_FOREVER] = 4 + }, + uses = 400, + } + }, + punch_attack_uses = 200, + damage_groups = {fleshy = 4} + } +}) + +PyuTestCore.make_tool("pyutest_core:diamond_pickaxe", "diamond_pickaxe", "Diamond Pickaxe", {}, "diamond-pickaxe.png", { + stack_max = 1, + tool_capabilities = { + groupcaps = { + block = { + times = { + [PyuTestCore.BLOCK_BREAKABLE_INSTANT] = 0.015, + [PyuTestCore.BLOCK_BREAKABLE_NORMAL] = 0.15, + [PyuTestCore.BLOCK_BREAKABLE_CHOPPY] = 0.15, + [PyuTestCore.BLOCK_BREAKABLE_MIDDLE] = 0.35, + [PyuTestCore.BLOCK_BREAKABLE_LONG] = 0.85, + [PyuTestCore.BLOCK_BREAKABLE_FOREVER] = 1.7 + }, + uses = 600, + } + }, + punch_attack_uses = 300, + damage_groups = {fleshy = 4} } }) @@ -58,7 +115,7 @@ PyuTestCore.make_item("pyutest_core:bomb", "bomb", "Bomb", {}, "bomb.png", { return end local pos = user:get_pos() - PyuTestCore.create_explosion(pos, 2) + PyuTestCore.create_explosion(pos, 2, false, 3, user) local stack = user:get_wielded_item() stack:set_count(stack:get_count() - 1) @@ -91,11 +148,12 @@ PyuTestCore.make_item("pyutest_core:coin", "coin", "Coin", {}, "coin.png", { minetest.sound_play({name = "coin", gain = 1}, { pos = pos }) - return nil end }) +PyuTestCore.make_item("pyutest_core:wheat", "wheat", "Wheat", {}, "wheat.png") + PyuTestCore.make_item("pyutest_core:apple", "apple", "Apple", {}, "apple.png", { on_use = function (itemstack, user, pt) if user == nil then return end @@ -103,3 +161,6 @@ PyuTestCore.make_item("pyutest_core:apple", "apple", "Apple", {}, "apple.png", { minetest.do_item_eat(3, "", itemstack, user, pt) end }) + +PyuTestCore.make_food("pyutest_core:apple", "apple", "Apple", "apple.png", 5) +PyuTestCore.make_food("pyutest_core:bread", "bread", "Bread", "bread.png", 3) diff --git a/mods/pyutest_core/trees.lua b/mods/pyutest_core/trees.lua index 7573b6b..bbfe40b 100644 --- a/mods/pyutest_core/trees.lua +++ b/mods/pyutest_core/trees.lua @@ -20,6 +20,17 @@ minetest.register_decoration({ decoration = "pyutest_core:grass_plant" }) +minetest.register_decoration({ + deco_type = "simple", + place_on = {"pyutest_core:grass_block"}, + sidelen = 16, + fill_ratio = 0.0018, + biomes = {"grassland"}, + y_max = PyuTestCore_BiomeTops.grassland, + y_min = 1, + decoration = "pyutest_core:haybale_block" +}) + minetest.register_decoration({ deco_type = "simple", place_on = {"pyutest_core:dirt_block", "pyutest_core:sand_block"}, diff --git a/mods/pyutest_core/utils.lua b/mods/pyutest_core/utils.lua index 2b83439..e22af2d 100644 --- a/mods/pyutest_core/utils.lua +++ b/mods/pyutest_core/utils.lua @@ -1,8 +1,9 @@ -PyuTestCore.create_explosion = function (pos, range, rm_pos) +PyuTestCore.create_explosion = function (pos, range, rm_pos, dmg, creator) if rm_pos then minetest.remove_node(pos) end + for dx = -range, range do for dz = -range, range do for dy = -range, range do @@ -16,12 +17,20 @@ PyuTestCore.create_explosion = function (pos, range, rm_pos) end end + + for _, v in pairs(minetest.get_objects_inside_radius(pos, range)) do + if v ~= nil and v ~= creator then + v:set_hp(v:get_hp() - dmg) + end + end + local r = range local minpos = {x = pos.x - r, y = pos.y - r, z = pos.z - r} local maxpos = {x = pos.x + r, y = pos.y + r, z = pos.z + r} + minetest.add_particlespawner({ - amount = range * 3, + amount = range * 2, time = 1, minexptime = 1, maxexptime = 1,