diff --git a/README.txt b/README.txt index 1e7a850..20066a8 100644 --- a/README.txt +++ b/README.txt @@ -1,12 +1,13 @@ -minipeli 0.1.2 by paramat. +minipeli 0.1.3 by paramat. A game for Minetest Engine 5.0.0 and later. -Authors of media (textures) ---------------------------- +Authors of media +---------------- paramat (CC BY-SA 3.0): header.png icon.png + About Minipeli -------------- 'Peli' is the Finnish word for 'game'. @@ -16,9 +17,12 @@ This also suggests a good mod structure, as opposed to the problematic structure This game is not as minimal as it could be, the 'creative' mod is not necessary. However, i consider it desirable for most games as freely building without it is very awkward. So the 'creative' mod from Minetest Game has been included, and therefore also the 'sfinv' mod on which it depends, they are almost completely unmodified. +The 'lamp' mod is not necessary, it is only provided to illuminate caves and dungeons during testing. + Because creating animated meshes is difficult the player model from Minetest Game is used, it seems suitable for many games. -The player API of Minetest Game is quite fundamental. -So, the 'player_api' mod from Minetest Game is included in a simplified form. +The player API of Minetest Game is very useful and quite fundamental. +So, the 'player_api' mod from Minetest Game is included in a slightly simplified form. + Why Mapgen v6 is not supported ------------------------------ @@ -28,10 +32,44 @@ Mapgen v6 is very different to all the other mapgens, it has hardcoded biomes an It is highly recommended that games do not support Mapgen v6 for these reasons. -Note about 'lamp' mod ---------------------- +The mods +-------- -This is not a necessary part of the game, it is only provided in creative mode to illuminate caves and dungeons during testing. +'creative' +Unmodified mod from Minetest Game. Convenient for creative mode building. + +'sfinv' +Unmodified mod from Minetest Game. Required by 'creative'. + +'player_api' +Slightly simplified version of mod from Minetest Game. +Provides an API to support multiple registered player models and to set the player model, player textures or a particular player animation. +Provides an animated player model and skin texture. +Sets suitable animations according to control inputs and player health. + +'gui' +Contains formspec and HUD related stuff: +Formspec background, hotbar background, bubble and heart textures. +Sets the formspec prepend, and can optionally set custom hotbar textures. + +'hand' +Contains the hand tool related stuff: +The wieldhand texture. +Registers the hand tool. + +'mapgen' +Contains the mapgen related stuff: +Terrain, liquid and dungeon nodes, their textures and sounds. +Mapgen aliases to tell the C++ mapgens which nodes to use. +Biome registrations. + +'media' +Contains textures and sounds that have no suitable location anywhere else: +The node-digging progress texture 'crack_anylength'. +The 'player_damage' sound. + +'lamp' +Unnecessary mod, only included to provide illumination for testing. How this game was created @@ -40,52 +78,52 @@ How this game was created Minetest Game mods used unmodified or slightly modified: 'creative': -Optional-depend on 'hand' mod instead of 'default' mod. +Depend on 'hand' mod instead of 'default' mod. 'sfinv' Minetest Game mods used modified: -'default' (becomes 'hand', 'gui' and 'textures' mods) +'default' (becomes 'hand', 'gui' and 'media' mods) 'player_api' 'default' mod changes: - Split into 3 mods: 'hand', contains: Textures: wieldhand.png -Code: -minetest.register_item +init.lua: +minetest.register_item to register the hand tool. 'gui', contains: Textures: gui_formbg gui_hb_bg -Code: +bubble +heart +init.lua: minetest.register_on_joinplayer player:set_formspec_prepend -'textures', contains: +'media', contains: Code: Required non-functional init.lua. Textures: -bubble crack_anylength -heart +Sounds: +player_damage (from player_api) 'player_api' mod changes: - Now only contains: Models: -Player model b3d, blend, skin texture -Sounds: -player_damage -Files: -api.lua: Remove 2D sprite player code. -init.lua: From register_on_joinplayer remove: +Player model .b3d, .blend, skin texture +api.lua: +Reorder code for clarity, use 'model_name' in 'player_api.register_model'. +From 'player_api.set_model()' remove sprite code and 'if model then ... end'. +init.lua: +From register_on_joinplayer remove: player:hud_set_hotbar_image("gui_hotbar.png") player:hud_set_hotbar_selected_image("gui_hotbar_selected.png") diff --git a/mods/creative/init.lua b/mods/creative/init.lua index d1878f6..7b7903d 100644 --- a/mods/creative/init.lua +++ b/mods/creative/init.lua @@ -40,10 +40,8 @@ if creative_mode_cache then local digtime = 42 local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 256} - minetest.register_item(":", { - type = "none", - wield_image = "wieldhand.png", - wield_scale = {x = 1, y = 1, z = 2.5}, + -- Override the hand tool + minetest.override_item("", { range = 10, tool_capabilities = { full_punch_interval = 0.5, diff --git a/mods/creative/mod.conf b/mods/creative/mod.conf index 2b98d29..4581054 100644 --- a/mods/creative/mod.conf +++ b/mods/creative/mod.conf @@ -1,4 +1,3 @@ name = creative description = Minetest Game mod: creative -depends = sfinv -optional_depends = hand +depends = hand, sfinv diff --git a/mods/gui/README.txt b/mods/gui/README.txt index 19b5405..5351d06 100644 --- a/mods/gui/README.txt +++ b/mods/gui/README.txt @@ -13,3 +13,7 @@ Authors of media BlockMen (CC BY-SA 3.0): gui_formbg.png gui_hb_bg.png + +Paramat (CC BY-SA 3.0): + bubble.png + heart.png diff --git a/mods/gui/license.txt b/mods/gui/license.txt index e732662..5a53060 100644 --- a/mods/gui/license.txt +++ b/mods/gui/license.txt @@ -21,6 +21,7 @@ License of media ---------------- Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) +Copyright (C) 2019 paramat Copyright (C) 2019 BlockMen You are free to: diff --git a/mods/textures/textures/bubble.png b/mods/gui/textures/bubble.png similarity index 100% rename from mods/textures/textures/bubble.png rename to mods/gui/textures/bubble.png diff --git a/mods/textures/textures/heart.png b/mods/gui/textures/heart.png similarity index 100% rename from mods/textures/textures/heart.png rename to mods/gui/textures/heart.png diff --git a/mods/hand/init.lua b/mods/hand/init.lua index 81e85ee..12a0ab3 100644 --- a/mods/hand/init.lua +++ b/mods/hand/init.lua @@ -3,7 +3,7 @@ minetest.register_item(":", { type = "none", wield_image = "wieldhand.png", - wield_scale = {x = 1, y = 1, z = 2.5}, + wield_scale = {x = 1, y = 1, z = 4}, tool_capabilities = { full_punch_interval = 0.9, max_drop_level = 0, diff --git a/mods/hand/textures/wieldhand.png b/mods/hand/textures/wieldhand.png index 1722a65..441cfff 100644 Binary files a/mods/hand/textures/wieldhand.png and b/mods/hand/textures/wieldhand.png differ diff --git a/mods/textures/README.txt b/mods/media/README.txt similarity index 52% rename from mods/textures/README.txt rename to mods/media/README.txt index f4f68db..4141a97 100644 --- a/mods/textures/README.txt +++ b/mods/media/README.txt @@ -1,8 +1,12 @@ -Minipeli mod: textures -====================== +Minipeli mod: media +=================== See license.txt for license information. Derived by paramat from Minetest Game 'default' mod. Authors of media ---------------- All textures by paramat (CC BY-SA 3.0). + +sonictechtonic (CC BY 3.0): +https://www.freesound.org/people/sonictechtonic/sounds/241872/ + player_damage.ogg diff --git a/mods/textures/init.lua b/mods/media/init.lua similarity index 100% rename from mods/textures/init.lua rename to mods/media/init.lua diff --git a/mods/textures/license.txt b/mods/media/license.txt similarity index 53% rename from mods/textures/license.txt rename to mods/media/license.txt index 21dde67..7de4636 100644 --- a/mods/textures/license.txt +++ b/mods/media/license.txt @@ -35,3 +35,33 @@ privacy, or moral rights may limit how you use the material. For more details: http://creativecommons.org/licenses/by-sa/3.0/ + +----------------------- + +Attribution 3.0 Unported (CC BY 3.0) +Copyright (C) 2014 sonictechtonic + +You are free to: +Share — copy and redistribute the material in any medium or format. +Adapt — remix, transform, and build upon the material for any purpose, even commercially. +The licensor cannot revoke these freedoms as long as you follow the license terms. + +Under the following terms: + +Attribution — You must give appropriate credit, provide a link to the license, and +indicate if changes were made. You may do so in any reasonable manner, but not in any way +that suggests the licensor endorses you or your use. + +No additional restrictions — You may not apply legal terms or technological measures that +legally restrict others from doing anything the license permits. + +Notices: + +You do not have to comply with the license for elements of the material in the public +domain or where your use is permitted by an applicable exception or limitation. +No warranties are given. The license may not give you all of the permissions necessary +for your intended use. For example, other rights such as publicity, privacy, or moral +rights may limit how you use the material. + +For more details: +http://creativecommons.org/licenses/by/3.0/ diff --git a/mods/player_api/sounds/player_damage.ogg b/mods/media/sounds/player_damage.ogg similarity index 100% rename from mods/player_api/sounds/player_damage.ogg rename to mods/media/sounds/player_damage.ogg diff --git a/mods/textures/textures/crack_anylength.png b/mods/media/textures/crack_anylength.png similarity index 100% rename from mods/textures/textures/crack_anylength.png rename to mods/media/textures/crack_anylength.png diff --git a/mods/player_api/api.lua b/mods/player_api/api.lua index 7d5a36d..753cd3c 100644 --- a/mods/player_api/api.lua +++ b/mods/player_api/api.lua @@ -1,18 +1,19 @@ +-- Global table for use by other mods player_api = {} -- Player animation blending -- Note: This is currently broken due to a bug in Irrlicht, leave at 0 local animation_blend = 0 -player_api.registered_models = { } --- Local for speed. +-- Tables +--------- + +-- Registered models +player_api.registered_models = {} +-- Localize for better performance local models = player_api.registered_models -function player_api.register_model(name, def) - models[name] = def -end - -- Player stats and animations local player_model = {} local player_textures = {} @@ -20,6 +21,15 @@ local player_anim = {} local player_sneak = {} player_api.player_attached = {} + +-- Functions +------------ + +function player_api.register_model(model_name, def) + models[model_name] = def +end + + function player_api.get_animation(player) local name = player:get_player_name() return { @@ -29,28 +39,28 @@ function player_api.get_animation(player) } end + -- Called when a player's appearance needs to be updated function player_api.set_model(player, model_name) local name = player:get_player_name() local model = models[model_name] - if model then - if player_model[name] == model_name then - return - end - player:set_properties({ - mesh = model_name, - textures = player_textures[name] or model.textures, - visual = "mesh", - visual_size = model.visual_size or {x = 1, y = 1}, - collisionbox = model.collisionbox or {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}, - stepheight = model.stepheight or 0.6, - eye_height = model.eye_height or 1.47, - }) - player_api.set_animation(player, "stand") + if player_model[name] == model_name then + return end + player:set_properties({ + mesh = model_name, + textures = player_textures[name] or model.textures, + visual = "mesh", + visual_size = model.visual_size or {x = 1, y = 1}, + collisionbox = model.collisionbox or {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}, + stepheight = model.stepheight or 0.6, + eye_height = model.eye_height or 1.47, + }) + player_api.set_animation(player, "stand") player_model[name] = model_name end + function player_api.set_textures(player, textures) local name = player:get_player_name() local model = models[player_model[name]] @@ -59,6 +69,7 @@ function player_api.set_textures(player, textures) player:set_properties({textures = textures or model_textures,}) end + function player_api.set_animation(player, anim_name, speed) local name = player:get_player_name() if player_anim[name] == anim_name then @@ -73,6 +84,7 @@ function player_api.set_animation(player, anim_name, speed) player:set_animation(anim, speed or model.animation_speed, animation_blend) end + minetest.register_on_leaveplayer(function(player) local name = player:get_player_name() player_model[name] = nil @@ -80,7 +92,8 @@ minetest.register_on_leaveplayer(function(player) player_textures[name] = nil end) --- Localize for better performance. + +-- Localize for better performance in globalstep function local player_set_animation = player_api.set_animation local player_attached = player_api.player_attached diff --git a/mods/player_api/init.lua b/mods/player_api/init.lua index 86699a2..c021302 100644 --- a/mods/player_api/init.lua +++ b/mods/player_api/init.lua @@ -3,7 +3,7 @@ dofile(minetest.get_modpath("player_api") .. "/api.lua") -- Default player appearance player_api.register_model("character.b3d", { animation_speed = 30, - textures = {"character.png", }, + textures = {"character.png"}, animations = { -- Standard animations. stand = {x = 0, y = 79}, diff --git a/mods/player_api/models/character.png b/mods/player_api/models/character.png index b6ff311..7d12605 100644 Binary files a/mods/player_api/models/character.png and b/mods/player_api/models/character.png differ