Remove creative and sfinv mods. Rename lamp to light, give 64 to newplayer. Improve player model and wieldhand textures. Use new player sprite textures. Update to bobbing model. Avoid occasional crash in formspec prepend code
104
README.txt
@ -1,6 +1,7 @@
|
|||||||
minipeli 0.1.3 by paramat.
|
minipeli 0.2.0 by paramat.
|
||||||
A game for Minetest Engine 5.0.0 and later.
|
A game for Minetest Engine 5.0.0 and later.
|
||||||
|
|
||||||
|
|
||||||
Authors of media
|
Authors of media
|
||||||
----------------
|
----------------
|
||||||
paramat (CC BY-SA 3.0):
|
paramat (CC BY-SA 3.0):
|
||||||
@ -12,16 +13,16 @@ About Minipeli
|
|||||||
--------------
|
--------------
|
||||||
'Peli' is the Finnish word for 'game'.
|
'Peli' is the Finnish word for 'game'.
|
||||||
|
|
||||||
This game is intended to be an example of the minimal requirements for a Minetest game, to help others create their own games.
|
This game is intended to be an example of minimal requirements for a Minetest Engine game, to help others create their own games.
|
||||||
This also suggests a good mod structure, as opposed to the problematic structure of the game called 'Minetest Game', which has most content in one large mod called 'default'. It is better to split the content into many mods.
|
This also suggests a good mod structure, as opposed to the problematic structure of the game called 'Minetest Game', which has most content in one large mod called 'default'. It is better to split the content into many mods.
|
||||||
|
|
||||||
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.
|
Because creating animated meshes is difficult, the player model from Minetest Game is used, it seems suitable for many games.
|
||||||
|
|
||||||
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 very useful and quite fundamental.
|
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.
|
So, the 'player_api' mod from Minetest Game is included, but with new player textures.
|
||||||
|
|
||||||
|
The 'light' mod is only provided to illuminate caves and dungeons during testing.
|
||||||
|
|
||||||
|
if the 'creative' mod from Minetest Game is used with Minipeli, the dependencies in the 'creative' mod mod.conf file must be edited to: 'depends = hand, sfinv'.
|
||||||
|
|
||||||
|
|
||||||
Why Mapgen v6 is not supported
|
Why Mapgen v6 is not supported
|
||||||
@ -29,20 +30,14 @@ Why Mapgen v6 is not supported
|
|||||||
|
|
||||||
In the 'game.conf' file, mapgen v6 is set as a disallowed mapgen.
|
In the 'game.conf' file, mapgen v6 is set as a disallowed mapgen.
|
||||||
Mapgen v6 is very different to all the other mapgens, it has hardcoded biomes and does not use the Biome API. Due to this it makes game code more complex and more difficult to maintain, the mapgen also misses many features.
|
Mapgen v6 is very different to all the other mapgens, it has hardcoded biomes and does not use the Biome API. Due to this it makes game code more complex and more difficult to maintain, the mapgen also misses many features.
|
||||||
It is highly recommended that games do not support Mapgen v6 for these reasons.
|
I recommended that games do not support Mapgen v6 for these reasons.
|
||||||
|
|
||||||
|
|
||||||
The mods
|
The mods
|
||||||
--------
|
--------
|
||||||
|
|
||||||
'creative'
|
|
||||||
Unmodified mod from Minetest Game. Convenient for creative mode building.
|
|
||||||
|
|
||||||
'sfinv'
|
|
||||||
Unmodified mod from Minetest Game. Required by 'creative'.
|
|
||||||
|
|
||||||
'player_api'
|
'player_api'
|
||||||
Slightly simplified version of mod from Minetest Game.
|
A mod from Minetest Game, mostly unmodified, but new player textures are used.
|
||||||
Provides an API to support multiple registered player models and to set the player model, player textures or a particular player animation.
|
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.
|
Provides an animated player model and skin texture.
|
||||||
Sets suitable animations according to control inputs and player health.
|
Sets suitable animations according to control inputs and player health.
|
||||||
@ -50,80 +45,67 @@ Sets suitable animations according to control inputs and player health.
|
|||||||
'gui'
|
'gui'
|
||||||
Contains formspec and HUD related stuff:
|
Contains formspec and HUD related stuff:
|
||||||
Formspec background, hotbar background, bubble and heart textures.
|
Formspec background, hotbar background, bubble and heart textures.
|
||||||
Sets the formspec prepend, and can optionally set custom hotbar textures.
|
Sets the formspec prepend.
|
||||||
|
|
||||||
'hand'
|
'hand'
|
||||||
Contains the hand tool related stuff:
|
Contains the hand tool related stuff:
|
||||||
The wieldhand texture.
|
The wieldhand texture.
|
||||||
Registers the hand tool.
|
Registers the hand tool.
|
||||||
|
|
||||||
|
'media'
|
||||||
|
Contains textures and sounds that have no suitable location anywhere else:
|
||||||
|
The node-digging progress texture 'crack_anylength'.
|
||||||
|
The 'player_damage' sound.
|
||||||
|
|
||||||
'mapgen'
|
'mapgen'
|
||||||
Contains the mapgen related stuff:
|
Contains the mapgen related stuff:
|
||||||
Terrain, liquid and dungeon nodes, their textures and sounds.
|
Terrain, liquid and dungeon nodes, their textures and sounds.
|
||||||
Mapgen aliases to tell the C++ mapgens which nodes to use.
|
Mapgen aliases to tell the C++ mapgens which nodes to use.
|
||||||
Biome registrations.
|
Biome registrations.
|
||||||
|
|
||||||
'media'
|
'light'
|
||||||
Contains textures and sounds that have no suitable location anywhere else:
|
Only included to provide illumination for testing.
|
||||||
The node-digging progress texture 'crack_anylength'.
|
Gives 64 lights to a new player.
|
||||||
The 'player_damage' sound.
|
|
||||||
|
|
||||||
'lamp'
|
|
||||||
Unnecessary mod, only included to provide illumination for testing.
|
|
||||||
|
|
||||||
|
|
||||||
How this game was created
|
How this game was created
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
Minetest Game mods used unmodified or slightly modified:
|
Minetest Game mods used slightly modified:
|
||||||
|
|
||||||
'creative':
|
'player_api' mod:
|
||||||
Depend on 'hand' mod instead of 'default' mod.
|
Use new player textures, update credits and licence.
|
||||||
'sfinv'
|
Delete unnecessary mod.conf file.
|
||||||
|
|
||||||
|
|
||||||
Minetest Game mods used modified:
|
Minetest Game mods used heavily modified:
|
||||||
|
|
||||||
'default' (becomes 'hand', 'gui' and 'media' mods)
|
'default' mod:
|
||||||
'player_api'
|
Becomes 'gui', 'hand' and 'media' mods.
|
||||||
|
|
||||||
|
|
||||||
'default' mod changes:
|
'default' mod is split into 3 mods:
|
||||||
Split into 3 mods:
|
|
||||||
|
|
||||||
'hand', contains:
|
'gui' mod contains:
|
||||||
Textures:
|
Textures:
|
||||||
wieldhand.png
|
gui_formbg
|
||||||
|
gui_hb_bg
|
||||||
|
bubble
|
||||||
|
heart
|
||||||
|
init.lua:
|
||||||
|
minetest.register_on_joinplayer player:set_formspec_prepend with custom hotbar texture code removed.
|
||||||
|
Use 'if info and info.formspec_version > 1 then' to avoid error.
|
||||||
|
|
||||||
|
'hand' mod contains:
|
||||||
|
Textures:
|
||||||
|
wieldhand.png
|
||||||
init.lua:
|
init.lua:
|
||||||
minetest.register_item to register the hand tool.
|
minetest.register_item to register the hand tool.
|
||||||
|
|
||||||
'gui', contains:
|
'media' mod contains:
|
||||||
Textures:
|
|
||||||
gui_formbg
|
|
||||||
gui_hb_bg
|
|
||||||
bubble
|
|
||||||
heart
|
|
||||||
init.lua:
|
|
||||||
minetest.register_on_joinplayer player:set_formspec_prepend
|
|
||||||
|
|
||||||
'media', contains:
|
|
||||||
Code:
|
Code:
|
||||||
Required non-functional init.lua.
|
Required non-functional init.lua.
|
||||||
Textures:
|
Textures:
|
||||||
crack_anylength
|
crack_anylength
|
||||||
Sounds:
|
Sounds:
|
||||||
player_damage (from player_api)
|
player_damage
|
||||||
|
|
||||||
|
|
||||||
'player_api' mod changes:
|
|
||||||
Now only contains:
|
|
||||||
|
|
||||||
Models:
|
|
||||||
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")
|
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
Minetest Game mod: creative
|
|
||||||
===========================
|
|
||||||
See license.txt for license information.
|
|
||||||
|
|
||||||
Authors of source code
|
|
||||||
----------------------
|
|
||||||
Originally by Perttu Ahola (celeron55) <celeron55@gmail.com> (MIT)
|
|
||||||
Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> (MIT)
|
|
||||||
|
|
||||||
Author of media (textures)
|
|
||||||
--------------------------
|
|
||||||
paramat (CC BY-SA 3.0):
|
|
||||||
* creative_prev_icon.png
|
|
||||||
* creative_next_icon.png
|
|
||||||
* creative_search_icon.png
|
|
||||||
* creative_clear_icon.png
|
|
||||||
* creative_trash_icon.png derived from a texture by kilbith (CC BY-SA 3.0)
|
|
@ -1,86 +0,0 @@
|
|||||||
creative = {}
|
|
||||||
|
|
||||||
local function update_sfinv(name)
|
|
||||||
minetest.after(0, function()
|
|
||||||
local player = minetest.get_player_by_name(name)
|
|
||||||
if player then
|
|
||||||
if sfinv.get_page(player):sub(1, 9) == "creative:" then
|
|
||||||
sfinv.set_page(player, sfinv.get_homepage_name(player))
|
|
||||||
else
|
|
||||||
sfinv.set_player_inventory_formspec(player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_privilege("creative", {
|
|
||||||
description = "Allow player to use creative inventory",
|
|
||||||
give_to_singleplayer = false,
|
|
||||||
give_to_admin = false,
|
|
||||||
on_grant = update_sfinv,
|
|
||||||
on_revoke = update_sfinv,
|
|
||||||
})
|
|
||||||
|
|
||||||
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
|
||||||
|
|
||||||
function creative.is_enabled_for(name)
|
|
||||||
return creative_mode_cache or
|
|
||||||
minetest.check_player_privs(name, {creative = true})
|
|
||||||
end
|
|
||||||
|
|
||||||
dofile(minetest.get_modpath("creative") .. "/inventory.lua")
|
|
||||||
|
|
||||||
if creative_mode_cache then
|
|
||||||
-- Dig time is modified according to difference (leveldiff) between tool
|
|
||||||
-- 'maxlevel' and node 'level'. Digtime is divided by the larger of
|
|
||||||
-- leveldiff and 1.
|
|
||||||
-- To speed up digging in creative, hand 'maxlevel' and 'digtime' have been
|
|
||||||
-- increased such that nodes of differing levels have an insignificant
|
|
||||||
-- effect on digtime.
|
|
||||||
local digtime = 42
|
|
||||||
local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 256}
|
|
||||||
|
|
||||||
-- Override the hand tool
|
|
||||||
minetest.override_item("", {
|
|
||||||
range = 10,
|
|
||||||
tool_capabilities = {
|
|
||||||
full_punch_interval = 0.5,
|
|
||||||
max_drop_level = 3,
|
|
||||||
groupcaps = {
|
|
||||||
crumbly = caps,
|
|
||||||
cracky = caps,
|
|
||||||
snappy = caps,
|
|
||||||
choppy = caps,
|
|
||||||
oddly_breakable_by_hand = caps,
|
|
||||||
-- dig_immediate group doesn't use value 1. Value 3 is instant dig
|
|
||||||
dig_immediate =
|
|
||||||
{times = {[2] = digtime, [3] = 0}, uses = 0, maxlevel = 256},
|
|
||||||
},
|
|
||||||
damage_groups = {fleshy = 10},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Unlimited node placement
|
|
||||||
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
|
|
||||||
if placer and placer:is_player() then
|
|
||||||
return creative.is_enabled_for(placer:get_player_name())
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Don't pick up if the item is already in the inventory
|
|
||||||
local old_handle_node_drops = minetest.handle_node_drops
|
|
||||||
function minetest.handle_node_drops(pos, drops, digger)
|
|
||||||
if not digger or not digger:is_player() or
|
|
||||||
not creative.is_enabled_for(digger:get_player_name()) then
|
|
||||||
return old_handle_node_drops(pos, drops, digger)
|
|
||||||
end
|
|
||||||
local inv = digger:get_inventory()
|
|
||||||
if inv then
|
|
||||||
for _, item in ipairs(drops) do
|
|
||||||
if not inv:contains_item("main", item, true) then
|
|
||||||
inv:add_item("main", item)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,189 +0,0 @@
|
|||||||
local player_inventory = {}
|
|
||||||
local inventory_cache = {}
|
|
||||||
|
|
||||||
local function init_creative_cache(items)
|
|
||||||
inventory_cache[items] = {}
|
|
||||||
local i_cache = inventory_cache[items]
|
|
||||||
|
|
||||||
for name, def in pairs(items) do
|
|
||||||
if def.groups.not_in_creative_inventory ~= 1 and
|
|
||||||
def.description and def.description ~= "" then
|
|
||||||
i_cache[name] = def
|
|
||||||
end
|
|
||||||
end
|
|
||||||
table.sort(i_cache)
|
|
||||||
return i_cache
|
|
||||||
end
|
|
||||||
|
|
||||||
function creative.init_creative_inventory(player)
|
|
||||||
local player_name = player:get_player_name()
|
|
||||||
player_inventory[player_name] = {
|
|
||||||
size = 0,
|
|
||||||
filter = "",
|
|
||||||
start_i = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
minetest.create_detached_inventory("creative_" .. player_name, {
|
|
||||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
|
|
||||||
local name = player2 and player2:get_player_name() or ""
|
|
||||||
if not creative.is_enabled_for(name) or
|
|
||||||
to_list == "main" then
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
return count
|
|
||||||
end,
|
|
||||||
allow_put = function(inv, listname, index, stack, player2)
|
|
||||||
return 0
|
|
||||||
end,
|
|
||||||
allow_take = function(inv, listname, index, stack, player2)
|
|
||||||
local name = player2 and player2:get_player_name() or ""
|
|
||||||
if not creative.is_enabled_for(name) then
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
return -1
|
|
||||||
end,
|
|
||||||
on_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
|
|
||||||
end,
|
|
||||||
on_take = function(inv, listname, index, stack, player2)
|
|
||||||
if stack and stack:get_count() > 0 then
|
|
||||||
minetest.log("action", player_name .. " takes " .. stack:get_name().. " from creative inventory")
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
}, player_name)
|
|
||||||
|
|
||||||
return player_inventory[player_name]
|
|
||||||
end
|
|
||||||
|
|
||||||
function creative.update_creative_inventory(player_name, tab_content)
|
|
||||||
local creative_list = {}
|
|
||||||
local inv = player_inventory[player_name] or
|
|
||||||
creative.init_creative_inventory(minetest.get_player_by_name(player_name))
|
|
||||||
local player_inv = minetest.get_inventory({type = "detached", name = "creative_" .. player_name})
|
|
||||||
|
|
||||||
local items = inventory_cache[tab_content] or init_creative_cache(tab_content)
|
|
||||||
|
|
||||||
for name, def in pairs(items) do
|
|
||||||
if def.name:find(inv.filter, 1, true) or
|
|
||||||
def.description:lower():find(inv.filter, 1, true) then
|
|
||||||
creative_list[#creative_list+1] = name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
table.sort(creative_list)
|
|
||||||
player_inv:set_size("main", #creative_list)
|
|
||||||
player_inv:set_list("main", creative_list)
|
|
||||||
inv.size = #creative_list
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Create the trash field
|
|
||||||
local trash = minetest.create_detached_inventory("creative_trash", {
|
|
||||||
-- Allow the stack to be placed and remove it in on_put()
|
|
||||||
-- This allows the creative inventory to restore the stack
|
|
||||||
allow_put = function(inv, listname, index, stack, player)
|
|
||||||
return stack:get_count()
|
|
||||||
end,
|
|
||||||
on_put = function(inv, listname)
|
|
||||||
inv:set_list(listname, {})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
trash:set_size("main", 1)
|
|
||||||
|
|
||||||
creative.formspec_add = ""
|
|
||||||
|
|
||||||
function creative.register_tab(name, title, items)
|
|
||||||
sfinv.register_page("creative:" .. name, {
|
|
||||||
title = title,
|
|
||||||
is_in_nav = function(self, player, context)
|
|
||||||
return creative.is_enabled_for(player:get_player_name())
|
|
||||||
end,
|
|
||||||
get = function(self, player, context)
|
|
||||||
local player_name = player:get_player_name()
|
|
||||||
creative.update_creative_inventory(player_name, items)
|
|
||||||
local inv = player_inventory[player_name]
|
|
||||||
local start_i = inv.start_i or 0
|
|
||||||
local pagenum = math.floor(start_i / (3*8) + 1)
|
|
||||||
local pagemax = math.ceil(inv.size / (3*8))
|
|
||||||
return sfinv.make_formspec(player, context,
|
|
||||||
"label[6.2,3.35;" .. minetest.colorize("#FFFF00", tostring(pagenum)) .. " / " .. tostring(pagemax) .. "]" ..
|
|
||||||
[[
|
|
||||||
image[4.06,3.4;0.8,0.8;creative_trash_icon.png]
|
|
||||||
listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]
|
|
||||||
list[detached:creative_trash;main;4,3.3;1,1;]
|
|
||||||
listring[]
|
|
||||||
image_button[5.4,3.25;0.8,0.8;creative_prev_icon.png;creative_prev;]
|
|
||||||
image_button[7.2,3.25;0.8,0.8;creative_next_icon.png;creative_next;]
|
|
||||||
image_button[2.1,3.25;0.8,0.8;creative_search_icon.png;creative_search;]
|
|
||||||
image_button[2.75,3.25;0.8,0.8;creative_clear_icon.png;creative_clear;]
|
|
||||||
tooltip[creative_search;Search]
|
|
||||||
tooltip[creative_clear;Reset]
|
|
||||||
tooltip[creative_prev;Previous page]
|
|
||||||
tooltip[creative_next;Next page]
|
|
||||||
listring[current_player;main]
|
|
||||||
field_close_on_enter[creative_filter;false]
|
|
||||||
]] ..
|
|
||||||
"field[0.3,3.5;2.2,1;creative_filter;;" .. minetest.formspec_escape(inv.filter) .. "]" ..
|
|
||||||
"listring[detached:creative_" .. player_name .. ";main]" ..
|
|
||||||
"list[detached:creative_" .. player_name .. ";main;0,0;8,3;" .. tostring(start_i) .. "]" ..
|
|
||||||
creative.formspec_add, true)
|
|
||||||
end,
|
|
||||||
on_enter = function(self, player, context)
|
|
||||||
local player_name = player:get_player_name()
|
|
||||||
local inv = player_inventory[player_name]
|
|
||||||
if inv then
|
|
||||||
inv.start_i = 0
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_player_receive_fields = function(self, player, context, fields)
|
|
||||||
local player_name = player:get_player_name()
|
|
||||||
local inv = player_inventory[player_name]
|
|
||||||
assert(inv)
|
|
||||||
|
|
||||||
if fields.creative_clear then
|
|
||||||
inv.start_i = 0
|
|
||||||
inv.filter = ""
|
|
||||||
creative.update_creative_inventory(player_name, items)
|
|
||||||
sfinv.set_player_inventory_formspec(player, context)
|
|
||||||
elseif fields.creative_search or
|
|
||||||
fields.key_enter_field == "creative_filter" then
|
|
||||||
inv.start_i = 0
|
|
||||||
inv.filter = fields.creative_filter:lower()
|
|
||||||
creative.update_creative_inventory(player_name, items)
|
|
||||||
sfinv.set_player_inventory_formspec(player, context)
|
|
||||||
elseif not fields.quit then
|
|
||||||
local start_i = inv.start_i or 0
|
|
||||||
|
|
||||||
if fields.creative_prev then
|
|
||||||
start_i = start_i - 3*8
|
|
||||||
if start_i < 0 then
|
|
||||||
start_i = inv.size - (inv.size % (3*8))
|
|
||||||
if inv.size == start_i then
|
|
||||||
start_i = math.max(0, inv.size - (3*8))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif fields.creative_next then
|
|
||||||
start_i = start_i + 3*8
|
|
||||||
if start_i >= inv.size then
|
|
||||||
start_i = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
inv.start_i = start_i
|
|
||||||
sfinv.set_player_inventory_formspec(player, context)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
creative.register_tab("all", "All", minetest.registered_items)
|
|
||||||
creative.register_tab("nodes", "Nodes", minetest.registered_nodes)
|
|
||||||
creative.register_tab("tools", "Tools", minetest.registered_tools)
|
|
||||||
creative.register_tab("craftitems", "Items", minetest.registered_craftitems)
|
|
||||||
|
|
||||||
local old_homepage_name = sfinv.get_homepage_name
|
|
||||||
function sfinv.get_homepage_name(player)
|
|
||||||
if creative.is_enabled_for(player:get_player_name()) then
|
|
||||||
return "creative:all"
|
|
||||||
else
|
|
||||||
return old_homepage_name(player)
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,61 +0,0 @@
|
|||||||
License of source code
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
The MIT License (MIT)
|
|
||||||
Copyright (C) 2012-2016 Perttu Ahola (celeron55) <celeron55@gmail.com>
|
|
||||||
Copyright (C) 2015-2016 Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
||||||
software and associated documentation files (the "Software"), to deal in the Software
|
|
||||||
without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
||||||
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
||||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or
|
|
||||||
substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
||||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
For more details:
|
|
||||||
https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
|
|
||||||
Licenses of media (textures)
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
|
||||||
Copyright (C) 2016 Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com>
|
|
||||||
Copyright (C) 2018 paramat
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
ShareAlike — If you remix, transform, or build upon the material, you must distribute
|
|
||||||
your contributions under the same license as the original.
|
|
||||||
|
|
||||||
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-sa/3.0/
|
|
@ -1,3 +0,0 @@
|
|||||||
name = creative
|
|
||||||
description = Minetest Game mod: creative
|
|
||||||
depends = hand, sfinv
|
|
Before Width: | Height: | Size: 708 B |
Before Width: | Height: | Size: 727 B |
Before Width: | Height: | Size: 728 B |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 712 B |
@ -1,9 +1,15 @@
|
|||||||
-- Formspec prepend
|
-- Formspec prepend
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
player:set_formspec_prepend([[
|
local formspec = [[
|
||||||
bgcolor[#080808BB;true]
|
bgcolor[#080808BB;true]
|
||||||
background[5,5;1,1;gui_formbg.png;true]
|
listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF] ]]
|
||||||
background[5,5;1,1;gui_formbg.png;true;10]
|
local name = player:get_player_name()
|
||||||
listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF] ]])
|
local info = minetest.get_player_information(name)
|
||||||
|
if info and info.formspec_version > 1 then
|
||||||
|
formspec = formspec .. "background9[5,5;1,1;gui_formbg.png;true;10]"
|
||||||
|
else
|
||||||
|
formspec = formspec .. "background[5,5;1,1;gui_formbg.png;true]"
|
||||||
|
end
|
||||||
|
player:set_formspec_prepend(formspec)
|
||||||
end)
|
end)
|
||||||
|
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 109 B |
@ -1,10 +0,0 @@
|
|||||||
-- Lamp
|
|
||||||
|
|
||||||
minetest.register_node("lamp:lamp", {
|
|
||||||
description = "Lamp",
|
|
||||||
tiles = {"lamp_lamp.png"},
|
|
||||||
paramtype = "light",
|
|
||||||
light_source = 14,
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 2},
|
|
||||||
})
|
|
17
mods/light/init.lua
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
-- Light
|
||||||
|
|
||||||
|
minetest.register_node("light:light", {
|
||||||
|
description = "Light",
|
||||||
|
tiles = {"light_light.png"},
|
||||||
|
paramtype = "light",
|
||||||
|
light_source = 14,
|
||||||
|
is_ground_content = false,
|
||||||
|
groups = {dig_immediate = 2},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Give to new player
|
||||||
|
|
||||||
|
minetest.register_on_newplayer(function(player)
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
inv:add_item("main", "light:light 64")
|
||||||
|
end)
|
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 96 B |
@ -3,15 +3,26 @@ Minipeli mod: player_api
|
|||||||
See license.txt for license information.
|
See license.txt for license information.
|
||||||
Derived by paramat from Minetest Game 'player_api' mod.
|
Derived by paramat from Minetest Game 'player_api' mod.
|
||||||
|
|
||||||
|
Provides an API to allow multiple mods to set player models and textures.
|
||||||
|
Also sets the default model, texture, and player flags.
|
||||||
|
This mod is only for content related to the Player API and the player object.
|
||||||
|
|
||||||
Authors of source code
|
Authors of source code
|
||||||
----------------------
|
----------------------
|
||||||
Originally by celeron55, Perttu Ahola <celeron55@gmail.com> (LGPL 2.1)
|
Originally by celeron55, Perttu Ahola <celeron55@gmail.com> (LGPLv2.1+)
|
||||||
Various Minetest developers and contributors (LGPL 2.1)
|
Various Minetest developers and contributors (LGPLv2.1+)
|
||||||
|
|
||||||
Authors of media
|
Authors of media (textures, models and sounds)
|
||||||
----------------
|
----------------------------------------------
|
||||||
stujones11 (CC BY-SA 3.0):
|
stujones11 (CC BY-SA 3.0):
|
||||||
character.* -- Derived from a model by MirceaKitsune (CC BY-SA 3.0)
|
character.b3d
|
||||||
|
character.blend -- Both derived from a model by MirceaKitsune (CC BY-SA 3.0)
|
||||||
|
|
||||||
|
An0n3m0us (CC BY-SA 3.0):
|
||||||
|
character.b3d
|
||||||
|
character.blend -- Player animation improvement
|
||||||
|
|
||||||
paramat (CC BY-SA 3.0):
|
paramat (CC BY-SA 3.0):
|
||||||
character.png
|
character.png
|
||||||
|
player.png
|
||||||
|
player_back.png
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
-- Global table for use by other mods
|
-- Minetest 0.4 mod: player
|
||||||
|
-- See README.txt for licensing and other information.
|
||||||
|
|
||||||
player_api = {}
|
player_api = {}
|
||||||
|
|
||||||
-- Player animation blending
|
-- Player animation blending
|
||||||
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
|
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
|
||||||
local animation_blend = 0
|
local animation_blend = 0
|
||||||
|
|
||||||
|
player_api.registered_models = { }
|
||||||
|
|
||||||
-- Tables
|
-- Local for speed.
|
||||||
---------
|
|
||||||
|
|
||||||
-- Registered models
|
|
||||||
player_api.registered_models = {}
|
|
||||||
-- Localize for better performance
|
|
||||||
local models = player_api.registered_models
|
local models = player_api.registered_models
|
||||||
|
|
||||||
|
function player_api.register_model(name, def)
|
||||||
|
models[name] = def
|
||||||
|
end
|
||||||
|
|
||||||
-- Player stats and animations
|
-- Player stats and animations
|
||||||
local player_model = {}
|
local player_model = {}
|
||||||
local player_textures = {}
|
local player_textures = {}
|
||||||
@ -21,15 +23,6 @@ local player_anim = {}
|
|||||||
local player_sneak = {}
|
local player_sneak = {}
|
||||||
player_api.player_attached = {}
|
player_api.player_attached = {}
|
||||||
|
|
||||||
|
|
||||||
-- Functions
|
|
||||||
------------
|
|
||||||
|
|
||||||
function player_api.register_model(model_name, def)
|
|
||||||
models[model_name] = def
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function player_api.get_animation(player)
|
function player_api.get_animation(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
return {
|
return {
|
||||||
@ -39,28 +32,37 @@ function player_api.get_animation(player)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Called when a player's appearance needs to be updated
|
-- Called when a player's appearance needs to be updated
|
||||||
function player_api.set_model(player, model_name)
|
function player_api.set_model(player, model_name)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local model = models[model_name]
|
local model = models[model_name]
|
||||||
if player_model[name] == model_name then
|
if model then
|
||||||
return
|
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")
|
||||||
|
else
|
||||||
|
player:set_properties({
|
||||||
|
textures = {"player.png", "player_back.png"},
|
||||||
|
visual = "upright_sprite",
|
||||||
|
visual_size = {x = 1, y = 2},
|
||||||
|
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.75, 0.3},
|
||||||
|
stepheight = 0.6,
|
||||||
|
eye_height = 1.625,
|
||||||
|
})
|
||||||
end
|
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
|
player_model[name] = model_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function player_api.set_textures(player, textures)
|
function player_api.set_textures(player, textures)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local model = models[player_model[name]]
|
local model = models[player_model[name]]
|
||||||
@ -69,7 +71,6 @@ function player_api.set_textures(player, textures)
|
|||||||
player:set_properties({textures = textures or model_textures,})
|
player:set_properties({textures = textures or model_textures,})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function player_api.set_animation(player, anim_name, speed)
|
function player_api.set_animation(player, anim_name, speed)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if player_anim[name] == anim_name then
|
if player_anim[name] == anim_name then
|
||||||
@ -84,7 +85,6 @@ function player_api.set_animation(player, anim_name, speed)
|
|||||||
player:set_animation(anim, speed or model.animation_speed, animation_blend)
|
player:set_animation(anim, speed or model.animation_speed, animation_blend)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
player_model[name] = nil
|
player_model[name] = nil
|
||||||
@ -92,8 +92,7 @@ minetest.register_on_leaveplayer(function(player)
|
|||||||
player_textures[name] = nil
|
player_textures[name] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- Localize for better performance.
|
||||||
-- Localize for better performance in globalstep function
|
|
||||||
local player_set_animation = player_api.set_animation
|
local player_set_animation = player_api.set_animation
|
||||||
local player_attached = player_api.player_attached
|
local player_attached = player_api.player_attached
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
-- player/init.lua
|
||||||
|
|
||||||
dofile(minetest.get_modpath("player_api") .. "/api.lua")
|
dofile(minetest.get_modpath("player_api") .. "/api.lua")
|
||||||
|
|
||||||
-- Default player appearance
|
-- Default player appearance
|
||||||
player_api.register_model("character.b3d", {
|
player_api.register_model("character.b3d", {
|
||||||
animation_speed = 30,
|
animation_speed = 30,
|
||||||
textures = {"character.png"},
|
textures = {"character.png", },
|
||||||
animations = {
|
animations = {
|
||||||
-- Standard animations.
|
-- Standard animations.
|
||||||
stand = {x = 0, y = 79},
|
stand = {x = 0, y = 79},
|
||||||
|
@ -2,8 +2,8 @@ License of source code
|
|||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
GNU Lesser General Public License, version 2.1
|
GNU Lesser General Public License, version 2.1
|
||||||
Copyright (C) 2019 celeron55, Perttu Ahola <celeron55@gmail.com>
|
Copyright (C) 2011-2018 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||||
Copyright (C) 2019 Various Minetest developers and contributors
|
Copyright (C) 2011-2018 Various Minetest developers and contributors
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under the terms
|
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;
|
of the GNU Lesser General Public License as published by the Free Software Foundation;
|
||||||
@ -19,7 +19,8 @@ Licenses of media (textures, models and sounds)
|
|||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
|
|
||||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||||
Copyright (C) 2019 stujones11
|
Copyright (C) 2018 stujones11
|
||||||
|
Copyright (C) 2019 An0n3m0us
|
||||||
Copyright (C) 2019 paramat
|
Copyright (C) 2019 paramat
|
||||||
|
|
||||||
You are free to:
|
You are free to:
|
||||||
|
Before Width: | Height: | Size: 202 B After Width: | Height: | Size: 223 B |
BIN
mods/player_api/textures/player.png
Normal file
After Width: | Height: | Size: 163 B |
BIN
mods/player_api/textures/player_back.png
Normal file
After Width: | Height: | Size: 125 B |
@ -1,18 +0,0 @@
|
|||||||
Minetest Game mod: sfinv
|
|
||||||
========================
|
|
||||||
See license.txt for license information.
|
|
||||||
|
|
||||||
Simple Fast Inventory.
|
|
||||||
A cleaner, simpler, solution to having an advanced inventory in Minetest.
|
|
||||||
See game_api.txt for this mod's API.
|
|
||||||
Available for use outside of MTG here:
|
|
||||||
https://forum.minetest.net/viewtopic.php?t=19765
|
|
||||||
|
|
||||||
Authors of source code
|
|
||||||
----------------------
|
|
||||||
rubenwardy (MIT)
|
|
||||||
|
|
||||||
Authors of media
|
|
||||||
----------------
|
|
||||||
paramat (CC BY-SA 3.0):
|
|
||||||
sfinv_crafting_arrow.png - derived from a texture by BlockMen (CC BY-SA 3.0)
|
|
@ -1,189 +0,0 @@
|
|||||||
sfinv = {
|
|
||||||
pages = {},
|
|
||||||
pages_unordered = {},
|
|
||||||
contexts = {},
|
|
||||||
enabled = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function sfinv.register_page(name, def)
|
|
||||||
assert(name, "Invalid sfinv page. Requires a name")
|
|
||||||
assert(def, "Invalid sfinv page. Requires a def[inition] table")
|
|
||||||
assert(def.get, "Invalid sfinv page. Def requires a get function.")
|
|
||||||
assert(not sfinv.pages[name], "Attempt to register already registered sfinv page " .. dump(name))
|
|
||||||
|
|
||||||
sfinv.pages[name] = def
|
|
||||||
def.name = name
|
|
||||||
table.insert(sfinv.pages_unordered, def)
|
|
||||||
end
|
|
||||||
|
|
||||||
function sfinv.override_page(name, def)
|
|
||||||
assert(name, "Invalid sfinv page override. Requires a name")
|
|
||||||
assert(def, "Invalid sfinv page override. Requires a def[inition] table")
|
|
||||||
local page = sfinv.pages[name]
|
|
||||||
assert(page, "Attempt to override sfinv page " .. dump(name) .. " which does not exist.")
|
|
||||||
for key, value in pairs(def) do
|
|
||||||
page[key] = value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function sfinv.get_nav_fs(player, context, nav, current_idx)
|
|
||||||
-- Only show tabs if there is more than one page
|
|
||||||
if #nav > 1 then
|
|
||||||
return "tabheader[0,0;sfinv_nav_tabs;" .. table.concat(nav, ",") ..
|
|
||||||
";" .. current_idx .. ";true;false]"
|
|
||||||
else
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local theme_inv = [[
|
|
||||||
image[0,4.7;1,1;gui_hb_bg.png]
|
|
||||||
image[1,4.7;1,1;gui_hb_bg.png]
|
|
||||||
image[2,4.7;1,1;gui_hb_bg.png]
|
|
||||||
image[3,4.7;1,1;gui_hb_bg.png]
|
|
||||||
image[4,4.7;1,1;gui_hb_bg.png]
|
|
||||||
image[5,4.7;1,1;gui_hb_bg.png]
|
|
||||||
image[6,4.7;1,1;gui_hb_bg.png]
|
|
||||||
image[7,4.7;1,1;gui_hb_bg.png]
|
|
||||||
list[current_player;main;0,4.7;8,1;]
|
|
||||||
list[current_player;main;0,5.85;8,3;8]
|
|
||||||
]]
|
|
||||||
|
|
||||||
function sfinv.make_formspec(player, context, content, show_inv, size)
|
|
||||||
local tmp = {
|
|
||||||
size or "size[8,8.6]",
|
|
||||||
sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx),
|
|
||||||
show_inv and theme_inv or "",
|
|
||||||
content
|
|
||||||
}
|
|
||||||
return table.concat(tmp, "")
|
|
||||||
end
|
|
||||||
|
|
||||||
function sfinv.get_homepage_name(player)
|
|
||||||
return "sfinv:crafting"
|
|
||||||
end
|
|
||||||
|
|
||||||
function sfinv.get_formspec(player, context)
|
|
||||||
-- Generate navigation tabs
|
|
||||||
local nav = {}
|
|
||||||
local nav_ids = {}
|
|
||||||
local current_idx = 1
|
|
||||||
for i, pdef in pairs(sfinv.pages_unordered) do
|
|
||||||
if not pdef.is_in_nav or pdef:is_in_nav(player, context) then
|
|
||||||
nav[#nav + 1] = pdef.title
|
|
||||||
nav_ids[#nav_ids + 1] = pdef.name
|
|
||||||
if pdef.name == context.page then
|
|
||||||
current_idx = #nav_ids
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
context.nav = nav_ids
|
|
||||||
context.nav_titles = nav
|
|
||||||
context.nav_idx = current_idx
|
|
||||||
|
|
||||||
-- Generate formspec
|
|
||||||
local page = sfinv.pages[context.page] or sfinv.pages["404"]
|
|
||||||
if page then
|
|
||||||
return page:get(player, context)
|
|
||||||
else
|
|
||||||
local old_page = context.page
|
|
||||||
local home_page = sfinv.get_homepage_name(player)
|
|
||||||
|
|
||||||
if old_page == home_page then
|
|
||||||
minetest.log("error", "[sfinv] Couldn't find " .. dump(old_page) ..
|
|
||||||
", which is also the old page")
|
|
||||||
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
|
|
||||||
context.page = home_page
|
|
||||||
assert(sfinv.pages[context.page], "[sfinv] Invalid homepage")
|
|
||||||
minetest.log("warning", "[sfinv] Couldn't find " .. dump(old_page) ..
|
|
||||||
" so switching to homepage")
|
|
||||||
|
|
||||||
return sfinv.get_formspec(player, context)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function sfinv.get_or_create_context(player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
local context = sfinv.contexts[name]
|
|
||||||
if not context then
|
|
||||||
context = {
|
|
||||||
page = sfinv.get_homepage_name(player)
|
|
||||||
}
|
|
||||||
sfinv.contexts[name] = context
|
|
||||||
end
|
|
||||||
return context
|
|
||||||
end
|
|
||||||
|
|
||||||
function sfinv.set_context(player, context)
|
|
||||||
sfinv.contexts[player:get_player_name()] = context
|
|
||||||
end
|
|
||||||
|
|
||||||
function sfinv.set_player_inventory_formspec(player, context)
|
|
||||||
local fs = sfinv.get_formspec(player,
|
|
||||||
context or sfinv.get_or_create_context(player))
|
|
||||||
player:set_inventory_formspec(fs)
|
|
||||||
end
|
|
||||||
|
|
||||||
function sfinv.set_page(player, pagename)
|
|
||||||
local context = sfinv.get_or_create_context(player)
|
|
||||||
local oldpage = sfinv.pages[context.page]
|
|
||||||
if oldpage and oldpage.on_leave then
|
|
||||||
oldpage:on_leave(player, context)
|
|
||||||
end
|
|
||||||
context.page = pagename
|
|
||||||
local page = sfinv.pages[pagename]
|
|
||||||
if page.on_enter then
|
|
||||||
page:on_enter(player, context)
|
|
||||||
end
|
|
||||||
sfinv.set_player_inventory_formspec(player, context)
|
|
||||||
end
|
|
||||||
|
|
||||||
function sfinv.get_page(player)
|
|
||||||
local context = sfinv.contexts[player:get_player_name()]
|
|
||||||
return context and context.page or sfinv.get_homepage_name(player)
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
if sfinv.enabled then
|
|
||||||
sfinv.set_player_inventory_formspec(player)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
|
||||||
sfinv.contexts[player:get_player_name()] = nil
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|
||||||
if formname ~= "" or not sfinv.enabled then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Get Context
|
|
||||||
local name = player:get_player_name()
|
|
||||||
local context = sfinv.contexts[name]
|
|
||||||
if not context then
|
|
||||||
sfinv.set_player_inventory_formspec(player)
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Was a tab selected?
|
|
||||||
if fields.sfinv_nav_tabs and context.nav then
|
|
||||||
local tid = tonumber(fields.sfinv_nav_tabs)
|
|
||||||
if tid and tid > 0 then
|
|
||||||
local id = context.nav[tid]
|
|
||||||
local page = sfinv.pages[id]
|
|
||||||
if id and page then
|
|
||||||
sfinv.set_page(player, id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- Pass event to page
|
|
||||||
local page = sfinv.pages[context.page]
|
|
||||||
if page and page.on_player_receive_fields then
|
|
||||||
return page:on_player_receive_fields(player, context, fields)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
@ -1,14 +0,0 @@
|
|||||||
dofile(minetest.get_modpath("sfinv") .. "/api.lua")
|
|
||||||
|
|
||||||
sfinv.register_page("sfinv:crafting", {
|
|
||||||
title = "Crafting",
|
|
||||||
get = function(self, player, context)
|
|
||||||
return sfinv.make_formspec(player, context, [[
|
|
||||||
list[current_player;craft;1.75,0.5;3,3;]
|
|
||||||
list[current_player;craftpreview;5.75,1.5;1,1;]
|
|
||||||
image[4.75,1.5;1,1;sfinv_crafting_arrow.png]
|
|
||||||
listring[current_player;main]
|
|
||||||
listring[current_player;craft]
|
|
||||||
]], true)
|
|
||||||
end
|
|
||||||
})
|
|
@ -1,59 +0,0 @@
|
|||||||
License of source code
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
The MIT License (MIT)
|
|
||||||
Copyright (C) 2016-2018 rubenwardy <rubenwardy@gmail.com>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
||||||
software and associated documentation files (the "Software"), to deal in the Software
|
|
||||||
without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
||||||
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
||||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or
|
|
||||||
substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
||||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
For more details:
|
|
||||||
https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
|
|
||||||
License of media
|
|
||||||
----------------
|
|
||||||
|
|
||||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
|
||||||
Copyright (C) 2019 paramat
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
ShareAlike — If you remix, transform, or build upon the material, you must distribute
|
|
||||||
your contributions under the same license as the original.
|
|
||||||
|
|
||||||
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-sa/3.0/
|
|
@ -1,2 +0,0 @@
|
|||||||
name = sfinv
|
|
||||||
description = Minetest Game mod: sfinv
|
|
Before Width: | Height: | Size: 469 B |