creatuve - updated upgraded simplified and provide privilegie feature
* register privilegie of creative for older or newer engines * enhanced the formspec of the creative player to 4 rows * try to upgrade most close to track upstream original * return back text button, remove extra media check https://notabug.org/TenPlus1/creative/issues/2 * update readme information to diference features
This commit is contained in:
parent
f621a7660c
commit
d5fb7ea978
@ -1,13 +1,14 @@
|
|||||||
Minetest Game mod: creative
|
Minetest Game mod: creative
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
Simplified creative with faster loading
|
Simplified creative for more accurate on mobile or small screens
|
||||||
|
|
||||||
Information
|
Information
|
||||||
------------
|
------------
|
||||||
|
|
||||||
This mod is named `creative` and is a replacement for default "creative" mod
|
This mod is named `creative` and is a replacement for default "creative" mod
|
||||||
of orginal game, with reduced tabs, also it uses a cached memory to faster lodaing.
|
of orginal game, with reduced tabs, also minenux fork it uses a cached memory and no images
|
||||||
|
to faster lodaing respect settings.
|
||||||
|
|
||||||
![screenshot.png](screenshot.png)
|
![screenshot.png](screenshot.png)
|
||||||
|
|
||||||
@ -19,9 +20,19 @@ for backguard compatibility with 5.2 and 0.4.16, with minimal backports, you
|
|||||||
can download from https://codeberg.org/minenux/minetest-mod-creative and after
|
can download from https://codeberg.org/minenux/minetest-mod-creative and after
|
||||||
clone or downloaded renamed to `creative` (obviously replace the current one if any)
|
clone or downloaded renamed to `creative` (obviously replace the current one if any)
|
||||||
|
|
||||||
Modified by TenPlus1 (added creative privelage, reduced tab count, tweaked code),
|
Modified by TenPlus1 (added creative privilege, reduced tab count, tweaked code),
|
||||||
original work is at https://notabug.org/TenPlus1/creative
|
original work is at https://notabug.org/TenPlus1/creative
|
||||||
|
|
||||||
|
The minenux fork cut down images to use only text so media download is not a hit!
|
||||||
|
|
||||||
|
#### Api
|
||||||
|
|
||||||
|
You can use `creative.is_creative(playername)` (older) or `creative.is_enabled_for(playername)`.
|
||||||
|
|
||||||
|
#### Dependencies
|
||||||
|
|
||||||
|
* sfinv
|
||||||
|
|
||||||
### Authors of source code
|
### Authors of source code
|
||||||
|
|
||||||
Originally by Perttu Ahola (celeron55) <celeron55@gmail.com> (MIT)
|
Originally by Perttu Ahola (celeron55) <celeron55@gmail.com> (MIT)
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
Minetest Game mod: creative
|
Minetest Game mod: creative
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
Simplified creative with faster loading
|
Simplified creative for more accurate on mobile or small screens
|
||||||
|
|
||||||
Information
|
Information
|
||||||
------------
|
------------
|
||||||
|
|
||||||
This mod is named `creative` and is a replacement for default "creative" mod
|
This mod is named `creative` and is a replacement for default "creative" mod
|
||||||
of orginal game, with reduced tabs, also it uses a cached memory to faster lodaing.
|
of orginal game, with reduced tabs, also minenux fork it uses a cached memory
|
||||||
|
to faster lodaing respect settings.
|
||||||
|
|
||||||
![screenshot.png](screenshot.png)
|
![screenshot.png](screenshot.png)
|
||||||
|
|
||||||
@ -19,9 +20,11 @@ for backguard compatibility with 5.2 and 0.4.16, with minimal backports, you
|
|||||||
can download from https://codeberg.org/minenux/minetest-mod-creative and after
|
can download from https://codeberg.org/minenux/minetest-mod-creative and after
|
||||||
clone or downloaded renamed to `creative` (obviously replace the current one if any)
|
clone or downloaded renamed to `creative` (obviously replace the current one if any)
|
||||||
|
|
||||||
Modified by TenPlus1 (added creative privelage, reduced tab count, tweaked code),
|
Modified by TenPlus1 (added creative privilege, reduced tab count, tweaked code),
|
||||||
original work is at https://notabug.org/TenPlus1/creative
|
original work is at https://notabug.org/TenPlus1/creative
|
||||||
|
|
||||||
|
The minenux fork cut down images to use only text so media download is not a hit!
|
||||||
|
|
||||||
### Authors of source code
|
### Authors of source code
|
||||||
|
|
||||||
Originally by Perttu Ahola (celeron55) <celeron55@gmail.com> (MIT)
|
Originally by Perttu Ahola (celeron55) <celeron55@gmail.com> (MIT)
|
||||||
@ -29,7 +32,7 @@ Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> (MIT)
|
|||||||
|
|
||||||
### Author of media (textures)
|
### Author of media (textures)
|
||||||
|
|
||||||
Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> (CC BY-SA 3.0)
|
Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> (CC-BY-SA 3.0)
|
||||||
|
|
||||||
LICENSE
|
LICENSE
|
||||||
-------
|
-------
|
||||||
|
@ -1 +1 @@
|
|||||||
Simplified creative with faster loading
|
Simplified creative for more accurate on mobile or small screens
|
||||||
|
@ -23,14 +23,19 @@ else
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local is_50 = minetest.has_feature("object_use_texture_alpha")
|
||||||
local is_53 = minetest.has_feature("object_step_has_moveresult")
|
local is_53 = minetest.has_feature("object_step_has_moveresult")
|
||||||
local is_54 = minetest.has_feature("direct_velocity_on_players")
|
local is_54 = minetest.has_feature("direct_velocity_on_players")
|
||||||
|
|
||||||
creative = {}
|
creative = {}
|
||||||
creative.get_translator = S
|
creative.get_translator = S
|
||||||
|
creative.is_50 = is_50
|
||||||
creative.is_53 = is_53
|
creative.is_53 = is_53
|
||||||
creative.is_54 = is_54
|
creative.is_54 = is_54
|
||||||
|
|
||||||
|
local privs_description = "Allow player to use creative inventory"
|
||||||
|
local privs_definition = {}
|
||||||
|
|
||||||
local function update_sfinv(name)
|
local function update_sfinv(name)
|
||||||
minetest.after(0, function()
|
minetest.after(0, function()
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
@ -44,23 +49,36 @@ local function update_sfinv(name)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_privilege("creative", {
|
if is_50 then
|
||||||
description = S("Allow player to use creative inventory"),
|
privs_definition = {
|
||||||
|
description = privs_description,
|
||||||
give_to_singleplayer = false,
|
give_to_singleplayer = false,
|
||||||
give_to_admin = false,
|
give_to_admin = false,
|
||||||
on_grant = update_sfinv,
|
on_grant = update_sfinv,
|
||||||
on_revoke = update_sfinv,
|
on_revoke = update_sfinv
|
||||||
})
|
}
|
||||||
|
else
|
||||||
|
privs_definition = {
|
||||||
|
description = privs_description,
|
||||||
|
give_to_singleplayer = false
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_privilege("creative", privs_definition)
|
||||||
|
|
||||||
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
||||||
|
|
||||||
-- backguard compatibility
|
-- backguard compatibility
|
||||||
function creative.is_creative(name)
|
function creative.is_creative(name)
|
||||||
if is_53 then
|
if creative.is_53 then
|
||||||
|
if name == "" then
|
||||||
return minetest.is_creative_enabled(name)
|
return minetest.is_creative_enabled(name)
|
||||||
else
|
else
|
||||||
return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache
|
return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Override the engine's creative mode function
|
-- Override the engine's creative mode function
|
||||||
@ -74,7 +92,7 @@ end
|
|||||||
|
|
||||||
-- For backwards compatibility:
|
-- For backwards compatibility:
|
||||||
function creative.is_enabled_for(name)
|
function creative.is_enabled_for(name)
|
||||||
return minetest.is_creative_enabled(name)
|
return creative.is_creative(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
dofile(minetest.get_modpath("creative") .. "/inventory.lua")
|
dofile(minetest.get_modpath("creative") .. "/inventory.lua")
|
||||||
@ -90,8 +108,10 @@ if minetest.is_creative_enabled("") then
|
|||||||
local digtime = 42
|
local digtime = 42
|
||||||
local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 256}
|
local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 256}
|
||||||
|
|
||||||
-- Override the hand tool
|
minetest.register_item(":", {
|
||||||
minetest.override_item("", {
|
type = "none",
|
||||||
|
wield_image = "wieldhand.png",
|
||||||
|
wield_scale = {x = 1, y = 1, z = 2.5},
|
||||||
range = 10,
|
range = 10,
|
||||||
tool_capabilities = {
|
tool_capabilities = {
|
||||||
full_punch_interval = 0.5,
|
full_punch_interval = 0.5,
|
||||||
@ -103,8 +123,7 @@ if minetest.is_creative_enabled("") then
|
|||||||
choppy = caps,
|
choppy = caps,
|
||||||
oddly_breakable_by_hand = caps,
|
oddly_breakable_by_hand = caps,
|
||||||
-- dig_immediate group doesn't use value 1. Value 3 is instant dig
|
-- dig_immediate group doesn't use value 1. Value 3 is instant dig
|
||||||
dig_immediate =
|
dig_immediate = {times = {[2] = digtime, [3] = 0}, uses = 0, maxlevel = 256},
|
||||||
{times = {[2] = digtime, [3] = 0}, uses = 0, maxlevel = 256},
|
|
||||||
},
|
},
|
||||||
damage_groups = {fleshy = 10},
|
damage_groups = {fleshy = 10},
|
||||||
}
|
}
|
||||||
@ -113,24 +132,30 @@ if minetest.is_creative_enabled("") then
|
|||||||
if minetest.register_on_mods_loaded then
|
if minetest.register_on_mods_loaded then
|
||||||
minetest.register_on_mods_loaded(hand_hack)
|
minetest.register_on_mods_loaded(hand_hack)
|
||||||
else
|
else
|
||||||
minetest.after(0, hand_hack)
|
minetest.after(0.2, hand_hack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Unlimited node placement
|
-- Unlimited node placement
|
||||||
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
|
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
|
||||||
if placer and placer:is_player() then
|
if placer then
|
||||||
return minetest.is_creative_enabled(placer:get_player_name())
|
if placer:is_player() then
|
||||||
|
return creative.is_creative(placer:get_player_name())
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--[[ Don't pick up if the item is already in the inventory
|
-- Don't pick up if the item is already in the inventory only in hard creative single
|
||||||
local old_handle_node_drops = minetest.handle_node_drops
|
if creative_mode_cache then
|
||||||
function minetest.handle_node_drops(pos, drops, digger)
|
local old_handle_node_drops = minetest.handle_node_drops
|
||||||
if not digger or not digger:is_player() or
|
function minetest.handle_node_drops(pos, drops, digger)
|
||||||
not minetest.is_creative_enabled(digger:get_player_name()) then
|
if not digger then
|
||||||
|
if not digger:is_player() then
|
||||||
|
if not creative.is_creative(digger:get_player_name()) then
|
||||||
return old_handle_node_drops(pos, drops, digger)
|
return old_handle_node_drops(pos, drops, digger)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
local inv = digger:get_inventory()
|
local inv = digger:get_inventory()
|
||||||
if inv then
|
if inv then
|
||||||
for _, item in ipairs(drops) do
|
for _, item in ipairs(drops) do
|
||||||
@ -139,5 +164,8 @@ function minetest.handle_node_drops(pos, drops, digger)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
]]
|
|
||||||
|
print("[creative] mod loaded")
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
-- creative/inventory.lua
|
-- creative/inventory.lua
|
||||||
|
|
||||||
-- support for MT game translation.
|
-- Load support for MT game translation.
|
||||||
local S = creative.get_translator
|
local S = creative.get_translator
|
||||||
|
|
||||||
local player_inventory = {}
|
local player_inventory = {}
|
||||||
@ -33,7 +33,7 @@ function creative.init_creative_inventory(player)
|
|||||||
minetest.create_detached_inventory("creative_" .. player_name, {
|
minetest.create_detached_inventory("creative_" .. player_name, {
|
||||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
|
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
|
||||||
local name = player2 and player2:get_player_name() or ""
|
local name = player2 and player2:get_player_name() or ""
|
||||||
if not minetest.is_creative_enabled(name) or
|
if not creative.is_enabled_for(name) or
|
||||||
to_list == "main" then
|
to_list == "main" then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
@ -44,7 +44,7 @@ function creative.init_creative_inventory(player)
|
|||||||
end,
|
end,
|
||||||
allow_take = function(inv, listname, index, stack, player2)
|
allow_take = function(inv, listname, index, stack, player2)
|
||||||
local name = player2 and player2:get_player_name() or ""
|
local name = player2 and player2:get_player_name() or ""
|
||||||
if not minetest.is_creative_enabled(name) then
|
if not creative.is_enabled_for(name) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
return -1
|
return -1
|
||||||
@ -74,9 +74,11 @@ end
|
|||||||
|
|
||||||
local function description(def, lang_code)
|
local function description(def, lang_code)
|
||||||
local s = def.description
|
local s = def.description
|
||||||
|
if creative.is_53 then
|
||||||
if lang_code then
|
if lang_code then
|
||||||
s = minetest.get_translated_string(lang_code, s)
|
s = minetest.get_translated_string(lang_code, s)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return s:gsub("\n.*", "") -- First line only
|
return s:gsub("\n.*", "") -- First line only
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -93,11 +95,14 @@ function creative.update_creative_inventory(player_name, tab_content)
|
|||||||
|
|
||||||
local items = inventory_cache[tab_content] or init_creative_cache(tab_content)
|
local items = inventory_cache[tab_content] or init_creative_cache(tab_content)
|
||||||
|
|
||||||
local lang
|
local lang = minetest.settings:get("language") or "en"
|
||||||
local player_info = minetest.get_player_information(player_name)
|
local player_info = minetest.get_player_information(player_name)
|
||||||
|
|
||||||
|
if is_53 then
|
||||||
if player_info and player_info.lang_code ~= "" then
|
if player_info and player_info.lang_code ~= "" then
|
||||||
lang = player_info.lang_code
|
lang = player_info.lang_code
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local creative_list = {}
|
local creative_list = {}
|
||||||
local order = {}
|
local order = {}
|
||||||
@ -143,12 +148,13 @@ function creative.register_tab(name, title, items)
|
|||||||
sfinv.register_page("creative:" .. name, {
|
sfinv.register_page("creative:" .. name, {
|
||||||
title = title,
|
title = title,
|
||||||
is_in_nav = function(self, player, context)
|
is_in_nav = function(self, player, context)
|
||||||
return minetest.is_creative_enabled(player:get_player_name())
|
return creative.is_enabled_for(player:get_player_name())
|
||||||
end,
|
end,
|
||||||
get = function(self, player, context)
|
get = function(self, player, context)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
creative.update_creative_inventory(player_name, items)
|
creative.update_creative_inventory(player_name, items)
|
||||||
local inv = player_inventory[player_name]
|
local inv = player_inventory[player_name]
|
||||||
|
local start_i = inv.start_i or 0
|
||||||
local pagenum = math.floor(inv.start_i / (4*8) + 1)
|
local pagenum = math.floor(inv.start_i / (4*8) + 1)
|
||||||
local pagemax = math.max(math.ceil(inv.size / (4*8)), 1)
|
local pagemax = math.max(math.ceil(inv.size / (4*8)), 1)
|
||||||
local esc = minetest.formspec_escape
|
local esc = minetest.formspec_escape
|
||||||
@ -156,14 +162,14 @@ function creative.register_tab(name, title, items)
|
|||||||
(inv.size == 0 and ("label[3,2;"..esc(S("No items to show.")).."]") or "") ..
|
(inv.size == 0 and ("label[3,2;"..esc(S("No items to show.")).."]") or "") ..
|
||||||
"label[5.8,4.15;" .. minetest.colorize("#FFFF00", tostring(pagenum)) .. " / " .. tostring(pagemax) .. "]" ..
|
"label[5.8,4.15;" .. minetest.colorize("#FFFF00", tostring(pagenum)) .. " / " .. tostring(pagemax) .. "]" ..
|
||||||
[[
|
[[
|
||||||
image[4.08,4.2;0.8,0.8;creative_trash_icon.png]
|
image[4,4;0.8,0.8;creative_trash_icon.png]
|
||||||
listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]
|
listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]
|
||||||
list[detached:trash;main;4.02,4.1;1,1;]
|
list[detached:trash;main;4,4;1,1;]
|
||||||
listring[]
|
listring[]
|
||||||
image_button[5,4.05;0.8,0.8;creative_prev_icon.png;creative_prev;]
|
button[5,4.05;0.8,0.8;creative_prev;<]
|
||||||
image_button[7.25,4.05;0.8,0.8;creative_next_icon.png;creative_next;]
|
button[7.25,4.05;0.8,0.8;creative_next;>]
|
||||||
image_button[2.63,4.05;0.8,0.8;creative_search_icon.png;creative_search;]
|
button[2.63,4.05;0.8,0.8;creative_search;?]
|
||||||
image_button[3.25,4.05;0.8,0.8;creative_clear_icon.png;creative_clear;]
|
button[3.25,4.05;0.8,0.8;creative_clear;X]
|
||||||
]] ..
|
]] ..
|
||||||
"tooltip[creative_search;" .. esc(S("Search")) .. "]" ..
|
"tooltip[creative_search;" .. esc(S("Search")) .. "]" ..
|
||||||
"tooltip[creative_clear;" .. esc(S("Reset")) .. "]" ..
|
"tooltip[creative_clear;" .. esc(S("Reset")) .. "]" ..
|
||||||
@ -248,18 +254,17 @@ end
|
|||||||
if minetest.register_on_mods_loaded then
|
if minetest.register_on_mods_loaded then
|
||||||
minetest.register_on_mods_loaded(tab_items)
|
minetest.register_on_mods_loaded(tab_items)
|
||||||
else
|
else
|
||||||
minetest.after(0, tab_items)
|
minetest.after(0.1, tab_items)
|
||||||
end
|
end
|
||||||
|
|
||||||
--creative.register_tab("all", S("Creative"), minetest.registered_items)
|
creative.register_tab("all", S("Creative"), minetest.registered_items)
|
||||||
creative.register_tab("all", S("All"), minetest.registered_items)
|
--creative.register_tab("nodes", S("Nodes"), minetest.registered_nodes)
|
||||||
creative.register_tab("nodes", S("Nodes"), registered_nodes)
|
--creative.register_tab("tools", S("Tools"), minetest.registered_tools)
|
||||||
creative.register_tab("tools", S("Tools"), registered_tools)
|
--creative.register_tab("craftitems", S("Items"), minetest.registered_craftitems)
|
||||||
creative.register_tab("craftitems", S("Items"), registered_craftitems)
|
|
||||||
|
|
||||||
local old_homepage_name = sfinv.get_homepage_name
|
local old_homepage_name = sfinv.get_homepage_name
|
||||||
function sfinv.get_homepage_name(player)
|
function sfinv.get_homepage_name(player)
|
||||||
if minetest.is_creative_enabled(player:get_player_name()) then
|
if creative.is_enabled_for(player:get_player_name()) then
|
||||||
return "creative:all"
|
return "creative:all"
|
||||||
else
|
else
|
||||||
return old_homepage_name(player)
|
return old_homepage_name(player)
|
||||||
|
@ -30,7 +30,6 @@ Licenses of media (textures)
|
|||||||
|
|
||||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||||
Copyright (C) 2016 Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com>
|
Copyright (C) 2016 Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com>
|
||||||
Copyright (C) 2018 paramat
|
|
||||||
|
|
||||||
You are free to:
|
You are free to:
|
||||||
Share — copy and redistribute the material in any medium or format.
|
Share — copy and redistribute the material in any medium or format.
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
name = creative
|
name = creative
|
||||||
depends = sfinv
|
depends = sfinv
|
||||||
description = Simplified creative with faster loading
|
description = Simplified creative for more accurate on mobiles or small screens
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 605 B |
Binary file not shown.
Before Width: | Height: | Size: 578 B |
Binary file not shown.
Before Width: | Height: | Size: 593 B |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Loading…
x
Reference in New Issue
Block a user