1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-06-28 14:16:06 +02:00

Update minetestforfun_game, fix maptools

This commit is contained in:
LeMagnesium
2016-11-10 00:01:34 +01:00
parent 783cb0e3d9
commit d40a65244b
92 changed files with 3202 additions and 1803 deletions

View File

@ -1,23 +1,12 @@
Minetest Game mod: creative
===========================
See license.txt for license information.
Implements creative mode.
Switch on by using the "creative_mode" setting.
Registered items that
- have a description, and
- do not have the group not_in_creative_inventory
are added to the creative inventory.
License of source code and media files:
---------------------------------------
Copyright (C) 2012 Perttu Ahola (celeron55) <celeron55@gmail.com>
Copyright (C) 2016 Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com>
This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What The Fuck You Want
To Public License, Version 2, as published by Sam Hocevar. See
http://sam.zoy.org/wtfpl/COPYING for more details.
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)
--------------------------
Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> (CC BY-SA 3.0)

View File

@ -2,19 +2,21 @@
creative = {}
local player_inventory = {}
local creative_mode = minetest.setting_getbool("creative_mode")
-- Create detached creative inventory after loading all mods
creative.init_creative_inventory = function(player)
local player_name = player:get_player_name()
player_inventory[player_name] = {}
player_inventory[player_name].size = 0
player_inventory[player_name].filter = ""
player_inventory[player_name].start_i = 1
player_inventory[player_name].tab_id = 2
creative.init_creative_inventory = function(owner)
local owner_name = owner:get_player_name()
player_inventory[owner_name] = {
size = 0,
filter = "",
start_i = 1,
tab_id = 2,
}
minetest.create_detached_inventory("creative_" .. player_name, {
minetest.create_detached_inventory("creative_" .. owner_name, {
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
if minetest.setting_getbool("creative_mode") and not to_list == "main" then
if creative_mode and not to_list == "main" then
return count
else
return 0
@ -24,7 +26,7 @@ creative.init_creative_inventory = function(player)
return 0
end,
allow_take = function(inv, listname, index, stack, player)
if minetest.setting_getbool("creative_mode") then
if creative_mode then
return -1
else
return 0
@ -44,7 +46,7 @@ creative.init_creative_inventory = function(player)
end,
})
creative.update_creative_inventory(player_name)
creative.update_creative_inventory(owner_name)
--print("creative inventory size: " .. player_inventory[player_name].size)
end
@ -86,7 +88,7 @@ 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)
if minetest.setting_getbool("creative_mode") then
if creative_mode then
return stack:get_count()
else
return 0
@ -98,6 +100,8 @@ local trash = minetest.create_detached_inventory("creative_trash", {
})
trash:set_size("main", 1)
creative.formspec_add = ""
creative.set_creative_formspec = function(player, start_i)
local player_name = player:get_player_name()
local inv = player_inventory[player_name]
@ -121,13 +125,15 @@ creative.set_creative_formspec = function(player, start_i)
tooltip[creative_clear;Reset]
listring[current_player;main]
]] ..
"field[0.3,3.5;2.2,1;creative_filter;;" .. inv.filter .. "]" ..
"field[0.3,3.5;2.2,1;creative_filter;;" .. minetest.formspec_escape(inv.filter) .. "]" ..
"field_close_on_enter[creative_filter;false]" ..
"listring[detached:creative_" .. player_name .. ";main]" ..
"tabheader[0,0;creative_tabs;Crafting,All,Nodes,Tools,Items;" .. tostring(inv.tab_id) .. ";true;false]" ..
"list[detached:creative_" .. player_name .. ";main;0,0;8,3;" .. tostring(start_i) .. "]" ..
"table[6.05,3.35;1.15,0.5;pagenum;#FFFF00," .. tostring(pagenum) .. ",#FFFFFF,/ " .. tostring(pagemax) .. "]" ..
default.get_hotbar_bg(0,4.7) ..
default.gui_bg .. default.gui_bg_img .. default.gui_slots
.. creative.formspec_add
)
end
@ -152,7 +158,7 @@ end
minetest.register_on_joinplayer(function(player)
-- If in creative mode, modify player's inventory forms
if not minetest.setting_getbool("creative_mode") then
if not creative_mode then
return
end
creative.init_creative_inventory(player)
@ -160,13 +166,20 @@ minetest.register_on_joinplayer(function(player)
end)
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "" or not minetest.setting_getbool("creative_mode") then
if formname ~= "" or not creative_mode then
return
end
local player_name = player:get_player_name()
local inv = player_inventory[player_name]
-- If creative is turned on mid game
if not inv then
creative.init_creative_inventory(player)
creative.set_creative_formspec(player, 0)
return
end
if fields.quit then
if inv.tab_id == 1 then
creative.set_crafting_formspec(player)
@ -174,6 +187,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
elseif fields.creative_tabs then
local tab = tonumber(fields.creative_tabs)
inv.tab_id = tab
player_inventory[player_name].start_i = 1
if tab == 1 then
creative.set_crafting_formspec(player)
@ -182,17 +196,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
creative.set_creative_formspec(player, 0)
end
elseif fields.creative_clear then
player_inventory[player_name].start_i = 1
inv.filter = ""
creative.update_creative_inventory(player_name)
creative.set_creative_formspec(player, 0)
elseif fields.creative_search then
elseif fields.creative_search or
fields.key_enter_field == "creative_filter" then
player_inventory[player_name].start_i = 1
inv.filter = fields.creative_filter:lower()
creative.update_creative_inventory(player_name)
creative.set_creative_formspec(player, 0)
else
local formspec = player:get_inventory_formspec()
local start_i = formspec:match("list%[.-" .. player_name .. ";.-;(%d+)%]")
start_i = tonumber(start_i) or 0
local start_i = player_inventory[player_name].start_i or 0
if fields.creative_prev then
start_i = start_i - 3*8
@ -209,11 +224,12 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
end
player_inventory[player_name].start_i = start_i
creative.set_creative_formspec(player, start_i)
end
end)
if minetest.setting_getbool("creative_mode") then
if creative_mode then
local digtime = 0.5
local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 3}

View File

@ -0,0 +1,60 @@
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>
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/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 B

After

Width:  |  Height:  |  Size: 179 B