install wiki mod temporarily to allow users to understand what is going on, update item drop
parent
f6f1725c3d
commit
1be0c3454d
|
@ -695,6 +695,7 @@ minetest.register_node("core:cactus", {
|
|||
groups = {choppy=3, flammable=2},
|
||||
sounds = mcore.sound_wood,
|
||||
damage_per_second = 1,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_node("core:grass_1", {
|
||||
|
|
Binary file not shown.
|
@ -210,23 +210,3 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_node(":newhand:hand", {
|
||||
description = "",
|
||||
tiles = {"player_singleplayer.png"},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local stack = ItemStack(":")
|
||||
local ret = minetest.item_place(stack, placer, pointed_thing)
|
||||
return ItemStack("newhand:hand "..itemstack:get_count())
|
||||
end,
|
||||
visual_scale = 1,
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
paramtype = "light",
|
||||
drawtype = "mesh",
|
||||
mesh = "hand.b3d",
|
||||
node_placement_prediction = "",
|
||||
})
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
--player:get_inventory():set_stack("hand", 1, "newhand:hand")
|
||||
end)
|
|
@ -175,7 +175,7 @@ register_mese_toolsets()
|
|||
minetest.register_item(":", {
|
||||
type = "none",
|
||||
wield_image = "wieldhand.png",
|
||||
wield_scale = {x=1,y=3,z=4},
|
||||
--wield_scale = {x=1,y=3,z=4},
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.25,
|
||||
max_drop_level = 0,
|
||||
|
@ -186,7 +186,9 @@ minetest.register_item(":", {
|
|||
choppy = {times={[3]=6.00}, uses=0}
|
||||
},
|
||||
damage_groups = {fleshy=1},
|
||||
}
|
||||
},
|
||||
|
||||
range = 6,
|
||||
|
||||
})
|
||||
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
|
|
@ -1 +0,0 @@
|
|||
Install this by putting it in your .minetest/mods folder.
|
|
@ -1,98 +0,0 @@
|
|||
local age = 1 --how old an item has to be before collecting
|
||||
local radius_magnet = 3.5 --radius of item magnet
|
||||
local player_collect_height = 1.75 --added to their pos y value
|
||||
local adjuster_collect = 0.01 --Delay before collecting to visualize moveme
|
||||
|
||||
--Item collection
|
||||
minetest.register_globalstep(function(dtime)
|
||||
--collection
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
--don't magnetize to dead players
|
||||
if player:get_hp() > 0 then
|
||||
local pos = player:getpos()
|
||||
local inv = player:get_inventory()
|
||||
--radial detection
|
||||
for _,object in ipairs(minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y + player_collect_height,z=pos.z}, radius_magnet)) do
|
||||
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
||||
if object:get_luaentity().age > age then
|
||||
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||
--collect
|
||||
if object:get_luaentity().collectioner == true and object:get_luaentity().age > age and object:get_luaentity().age > object:get_luaentity().age_stamp + adjuster_collect then
|
||||
if object:get_luaentity().itemstring ~= "" then
|
||||
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
||||
minetest.sound_play("item_drop_pickup", {
|
||||
pos = pos,
|
||||
max_hear_distance = 6,
|
||||
gain = 0.1,
|
||||
})
|
||||
object:get_luaentity().itemstring = ""
|
||||
object:remove()
|
||||
end
|
||||
|
||||
--magnet
|
||||
else
|
||||
--moveto for extreme speed boost
|
||||
local pos1 = pos
|
||||
pos1.y = pos1.y + player_collect_height
|
||||
object:moveto(pos1)
|
||||
object:get_luaentity().collectioner = true
|
||||
object:get_luaentity().age_stamp = object:get_luaentity().age
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
--Drop items on dig
|
||||
function minetest.handle_node_drops(pos, drops, digger)
|
||||
for _,item in ipairs(drops) do
|
||||
local count, name
|
||||
if type(item) == "string" then
|
||||
count = 1
|
||||
name = item
|
||||
else
|
||||
count = item:get_count()
|
||||
name = item:get_name()
|
||||
end
|
||||
if not inv or not inv:contains_item("main", ItemStack(name)) then
|
||||
for i=1,count do
|
||||
local obj = minetest.add_item(pos, name)
|
||||
if obj ~= nil then
|
||||
obj:get_luaentity().collect = true
|
||||
obj:get_luaentity().age = age
|
||||
obj:setvelocity({x=math.random(-3,3), y=math.random(2,5), z=math.random(-3,3)})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--Throw items using player's velocity
|
||||
function minetest.item_drop(itemstack, dropper, pos)
|
||||
|
||||
--if player then do modified item drop
|
||||
if dropper and minetest.get_player_information(dropper:get_player_name()) then
|
||||
local v = dropper:get_look_dir()
|
||||
local vel = dropper:get_player_velocity()
|
||||
local p = {x=pos.x, y=pos.y+1.3, z=pos.z}
|
||||
local item = itemstack:to_string()
|
||||
local obj = core.add_item(p, item)
|
||||
if obj then
|
||||
v.x = (v.x*5)+vel.x
|
||||
v.y = ((v.y*5)+2)+vel.y
|
||||
v.z = (v.z*5)+vel.z
|
||||
obj:setvelocity(v)
|
||||
obj:get_luaentity().dropped_by = dropper:get_player_name()
|
||||
itemstack:clear()
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
end
|
||||
if minetest.setting_get("log_mods") then
|
||||
minetest.log("action", "Drops loaded")
|
||||
end
|
|
@ -1 +0,0 @@
|
|||
name = drops
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 933 B |
|
@ -0,0 +1,504 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
(This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.)
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{description}
|
||||
Copyright (C) {year} {fullname}
|
||||
|
||||
This library 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; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random
|
||||
Hacker.
|
||||
|
||||
{signature of Ty Coon}, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
|
@ -0,0 +1,33 @@
|
|||
# item_drop
|
||||
By [PilzAdam](https://github.com/PilzAdam), [texmex](https://github.com/tacotexmex/).
|
||||
|
||||
## Description
|
||||
This mod adds Minecraft like drop/pick up of items to Minetest.
|
||||
|
||||
## Licensing
|
||||
LGPLv2.1/CC BY-SA 3.0.
|
||||
|
||||
## Notes
|
||||
item_drop can be played with Minetest 0.4.16 or above. It was originally developed by [PilzAdam](https://github.com/PilzAdam/item_drop).
|
||||
|
||||
## List of features
|
||||
- All settings may be configured from within the game itself (Settings tab > Advanced settings > Mods > item_drop)
|
||||
- Drops nodes as in-world items on dig if `enable_item_drop` is `true`. (true by default)
|
||||
- Pulls items to the player's inventory if `enable_item_pickup` is `true`. (true by default) It uses a node radius set in `pickup_radius` (default 0.75)
|
||||
- Plays a sound the items are picked up, with the gain level set it `pickup_gain` (default 0.4)
|
||||
- Requires a key to be pressed in order to pull items if `enable_item_pickup_key` is `true`. (true by default). The keytypes to choose from by setting `item_pickup_keytype` are:
|
||||
- Use key (`Use`)
|
||||
- Sneak key (`Sneak`)
|
||||
- Left and Right keys combined (`LeftAndRight`)
|
||||
- Right mouse button (`RMB`)
|
||||
- Sneak key and right mouse button combined (`SneakAndRMB`)
|
||||
|
||||
## Known issues
|
||||
|
||||
## Bug reports and suggestions
|
||||
You can report bugs or suggest ideas by [filing an issue](http://github.com/tacotexmex/item_drop/issues/new).
|
||||
|
||||
## Links
|
||||
* [Download ZIP](https://github.com/tacotexmex/item_drop/archive/master.zip)
|
||||
* [Source](https://github.com/tacotexmex/item_drop/)
|
||||
* [Forum thread](https://forum.minetest.net/viewtopic.php?t=16913)
|
|
@ -0,0 +1 @@
|
|||
This mod adds Minecraft like drop/pick up of items to Minetest.
|
|
@ -0,0 +1,155 @@
|
|||
local pickup = true
|
||||
local drop = false
|
||||
local key = false
|
||||
local keytype = "Use"
|
||||
local pickup_gain = 0.4
|
||||
local pickup_radius = 0.75
|
||||
|
||||
local damage_enabled = minetest.settings:get_bool("enable_damage")
|
||||
|
||||
local timer = 0
|
||||
|
||||
if pickup then
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
||||
timer = timer + dtime
|
||||
if timer < 0.2 then return end
|
||||
timer = 0
|
||||
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local keys_pressed = false
|
||||
|
||||
local control = player:get_player_control()
|
||||
|
||||
if keytype == "Use" then
|
||||
keys_pressed = control.aux1
|
||||
elseif keytype == "Sneak" then
|
||||
keys_pressed = control.sneak
|
||||
elseif keytype == "LeftAndRight" then -- LeftAndRight combination
|
||||
keys_pressed = control.left and control.right
|
||||
elseif keytype == "RMB" then
|
||||
keys_pressed = control.RMB
|
||||
elseif keytype == "SneakAndRMB" then -- SneakAndRMB combination
|
||||
keys_pressed = control.sneak and control.RMB
|
||||
end
|
||||
|
||||
if not keys_pressed and key
|
||||
or (damage_enabled and player:get_hp() <= 0) then
|
||||
return
|
||||
end
|
||||
|
||||
local pos = player:getpos()
|
||||
pos.y = pos.y+0.5
|
||||
local inv = player:get_inventory()
|
||||
|
||||
local objectlist = minetest.get_objects_inside_radius(pos, pickup_radius)
|
||||
for _,object in ipairs(objectlist) do
|
||||
if not object:is_player()
|
||||
and object:get_luaentity()
|
||||
and object:get_luaentity().name == "__builtin:item" then
|
||||
local pos2 = object:getpos()
|
||||
local distance = math.sqrt(((pos2.x - pos.x) * (pos2.x - pos.x)) + ((pos2.y - pos.y) * (pos2.y - pos.y))
|
||||
+ ((pos2.z - pos.z) * (pos2.z - pos.z)))
|
||||
if distance <= 1 then
|
||||
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
||||
if object:get_luaentity().itemstring ~= "" then
|
||||
minetest.sound_play("item_drop_pickup", {
|
||||
to_player = player:get_player_name(),
|
||||
gain = pickup_gain,
|
||||
})
|
||||
end
|
||||
object:get_luaentity().itemstring = ""
|
||||
object:remove()
|
||||
end
|
||||
else
|
||||
if object:get_luaentity().collect then
|
||||
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||
local pos1 = pos
|
||||
pos1.y = pos1.y+0.2
|
||||
local vec = {x=pos1.x-pos2.x, y=pos1.y-pos2.y, z=pos1.z-pos2.z}
|
||||
vec.x = vec.x*3
|
||||
vec.y = vec.y*3
|
||||
vec.z = vec.z*3
|
||||
object:setvelocity(vec)
|
||||
object:get_luaentity().physical_state = false
|
||||
object:get_luaentity().object:set_properties({
|
||||
physical = false
|
||||
})
|
||||
|
||||
minetest.after(1, function()
|
||||
local lua = object:get_luaentity()
|
||||
if not lua or not lua.itemstring then
|
||||
return
|
||||
end
|
||||
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
||||
if object:get_luaentity().itemstring ~= "" then
|
||||
minetest.sound_play("item_drop_pickup", {
|
||||
to_player = player:get_player_name(),
|
||||
gain = pickup_gain,
|
||||
})
|
||||
end
|
||||
object:get_luaentity().itemstring = ""
|
||||
object:remove()
|
||||
else
|
||||
object:setvelocity({x=0,y=0,z=0})
|
||||
object:get_luaentity().physical_state = true
|
||||
object:get_luaentity().object:set_properties({
|
||||
physical = true
|
||||
})
|
||||
end
|
||||
end, {player, object})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
if drop then
|
||||
function minetest.handle_node_drops(pos, drops, digger)
|
||||
|
||||
local inv
|
||||
local diggerPos = pos
|
||||
|
||||
if minetest.settings:get_bool("creative_mode") and digger and digger:is_player() then
|
||||
inv = digger:get_inventory()
|
||||
diggerPos = digger:getpos()
|
||||
end
|
||||
|
||||
for _,item in ipairs(drops) do
|
||||
local count, name
|
||||
if type(item) == "string" then
|
||||
count = 1
|
||||
name = item
|
||||
else
|
||||
count = item:get_count()
|
||||
name = item:get_name()
|
||||
end
|
||||
|
||||
if not inv or not inv:contains_item("main", ItemStack(name)) then
|
||||
for i=1,count do
|
||||
|
||||
local adjustedPos = {x=diggerPos.x, y=diggerPos.y, z=diggerPos.z}
|
||||
local obj = minetest.add_item(adjustedPos, name)
|
||||
|
||||
if obj ~= nil then
|
||||
obj:get_luaentity().collect = true
|
||||
local x = math.random(1, 5)
|
||||
if math.random(1,2) == 1 then x = -x end
|
||||
|
||||
local z = math.random(1, 5)
|
||||
if math.random(1,2) == 1 then z = -z end
|
||||
|
||||
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.settings:get("log_mods") then minetest.log("action", "[Mod] item_drop loaded") end
|
|
@ -0,0 +1 @@
|
|||
name = item_drop
|
|
@ -0,0 +1,17 @@
|
|||
#Pick up items automatically
|
||||
enable_item_pickup (Enable item pickups) bool true
|
||||
|
||||
#Drop items in-world on dig
|
||||
enable_item_drop (Enable item drops) bool true
|
||||
|
||||
#Use a key to pick up items
|
||||
enable_item_pickup_key (Use pickup key) bool true
|
||||
|
||||
#What keytype to use as pickup key
|
||||
item_pickup_keytype (Pickup keytype) enum Use Use,Sneak,LeftAndRight,RMB,SneakAndRMB
|
||||
|
||||
#The volume of the pickup sound
|
||||
item_pickup_gain (Pickup sound gain) float 0.4
|
||||
|
||||
#Player pickup radius
|
||||
item_pickup_radius (Pickup radius) float 0.75
|
|
@ -0,0 +1,114 @@
|
|||
-- wardrobehands, addon to wardrobe;
|
||||
|
||||
local player_names = {}
|
||||
|
||||
local p_choice = {}
|
||||
|
||||
local p_rgb = {}
|
||||
|
||||
p_choice = minetest.deserialize(wardrobe.hand_textures:get_string("c"))
|
||||
|
||||
p_rgb = minetest.deserialize(wardrobe.hand_textures:get_string("rgb"))
|
||||
|
||||
local count = 1
|
||||
|
||||
if wardrobe.hand_textures:get_string("c") == "" then
|
||||
|
||||
else
|
||||
|
||||
for k, v in pairs(p_choice) do
|
||||
|
||||
player_names[count] = k
|
||||
|
||||
--print("[Wardrobe] Hands Addon Loaded, name: " .. k)
|
||||
|
||||
count = count + 1
|
||||
|
||||
end
|
||||
|
||||
for k, v in pairs(player_names) do
|
||||
|
||||
minetest.register_node(":newhand:" .. v, {
|
||||
description = "",
|
||||
|
||||
tiles = {
|
||||
|
||||
"(wardrobe_skin.png^[multiply:#".. p_rgb[v][1].. ")^"..
|
||||
"(wardrobe_under_shirt_" .. p_choice[v][5] .. ".png^[multiply:#".. p_rgb[v][5].. ")^"..
|
||||
"(wardrobe_under_shirt_" .. p_choice[v][6] .. ".png^[multiply:#".. p_rgb[v][6].. ")^"..
|
||||
"(wardrobe_shirt_" .. p_choice[v][11] .. ".png^[multiply:#".. p_rgb[v][11].. ")^"..
|
||||
"(wardrobe_shirt_" .. p_choice[v][12] .. ".png^[multiply:#".. p_rgb[v][12]..")",
|
||||
|
||||
},
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local stack = ItemStack(":")
|
||||
local ret = minetest.item_place(stack, placer, pointed_thing)
|
||||
return ItemStack("newhand:hand "..itemstack:get_count())
|
||||
end,
|
||||
|
||||
--sunlight_propagates = true,
|
||||
--visual_scale = 1,
|
||||
--wield_scale = {x=1,y=1,z=1},
|
||||
--paramtype = "light",
|
||||
drawtype = "mesh",
|
||||
mesh = "hand.b3d",
|
||||
node_placement_prediction = "",
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
minetest.register_node(":newhand:_default_", {
|
||||
description = "",
|
||||
|
||||
tiles = {
|
||||
|
||||
"(wardrobe_skin.png^[multiply:#e3c0a3)^"..
|
||||
"(wardrobe_under_shirt_2.png^[multiply:#dddddd)^"..
|
||||
"(wardrobe_under_shirt_1.png^[multiply:#ffffff)^"..
|
||||
"(wardrobe_shirt_2.png^[multiply:#39881c)^"..
|
||||
"(wardrobe_shirt_1.png^[multiply:#ffffff)",
|
||||
|
||||
},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local stack = ItemStack(":")
|
||||
local ret = minetest.item_place(stack, placer, pointed_thing)
|
||||
return ItemStack("newhand:hand "..itemstack:get_count())
|
||||
end,
|
||||
--visual_scale = 1,
|
||||
--wield_scale = {x=1,y=1,z=1},
|
||||
--paramtype = "light",
|
||||
drawtype = "mesh",
|
||||
mesh = "hand.b3d",
|
||||
node_placement_prediction = "",
|
||||
})
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
|
||||
--local has_hand = false
|
||||
|
||||
if wardrobe.hand_textures:get_string("c") == "" then
|
||||
|
||||
player:get_inventory():set_stack("hand", 1, "newhand:_default_")
|
||||
|
||||
else
|
||||
|
||||
for k, v in pairs(player_names) do
|
||||
|
||||
if v == player:get_player_name() then
|
||||
|
||||
player:get_inventory():set_stack("hand", 1, "newhand:" .. v)
|
||||
|
||||
else
|
||||
|
||||
player:get_inventory():set_stack("hand", 1, "newhand:_default_")
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
|
@ -30,6 +30,8 @@ wardrobe_acc_[number].png
|
|||
|
||||
wardrobe = {}
|
||||
|
||||
wardrobe.hand_textures = minetest.get_mod_storage()
|
||||
|
||||
wardrobe.texture_path = minetest.get_modpath("wardrobe").."/textures/"
|
||||
|
||||
wardrobe.player_materials = {}
|
||||
|
@ -37,6 +39,10 @@ wardrobe.player_materials = {}
|
|||
wardrobe.formspec_selections = {}
|
||||
wardrobe.formspec_selections_rgb = {}
|
||||
|
||||
-- initalize the external hands module.
|
||||
|
||||
dofile(minetest.get_modpath("wardrobe").."/hands.lua")
|
||||
|
||||
--clothing
|
||||
|
||||
wardrobe.undershirts = 1
|
||||
|
@ -920,7 +926,7 @@ function wardrobe.apply_to_player(player)
|
|||
"ptextures_transparent.png"
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
wardrobe.save_user_data(player)
|
||||
end
|
||||
|
||||
|
@ -996,8 +1002,10 @@ function wardrobe.load_user_data(player)
|
|||
if player:get_attribute("wardrobe_choices") == nil then
|
||||
wardrobe.formspec_selections[pname] = {2,2,2,1,2,1,2,1,2,1,2,1,1,1,2,1,1,1,1,1,1,1}
|
||||
print ("[Wardrobe] Failed Loading Texture Data for Player: " .. pname)
|
||||
player:set_attribute("wardrobe_choices", minetest.serialize(wardrobe.formspec_selections[pname]))
|
||||
|
||||
player:set_attribute("wardrobe_choices", minetest.serialize(wardrobe.formspec_selections))
|
||||
|
||||
wardrobe.hand_textures:set_string("c", minetest.serialize(wardrobe.formspec_selections[pname]))
|
||||
else
|
||||
wardrobe.formspec_selections[pname] = minetest.deserialize(player:get_attribute("wardrobe_choices"))
|
||||
print ("[Wardrobe] Loaded Texture Data for Player: " .. pname)
|
||||
|
@ -1034,7 +1042,9 @@ function wardrobe.load_user_data(player)
|
|||
|
||||
print ("[Wardrobe] Failed Loading RGB Data for Player: " .. pname)
|
||||
player:set_attribute("wardrobe_rgb", minetest.serialize(wardrobe.formspec_selections_rgb[pname]))
|
||||
|
||||
|
||||
wardrobe.hand_textures:set_string("rgb", minetest.serialize(wardrobe.formspec_selections_rgb))
|
||||
|
||||
else
|
||||
wardrobe.formspec_selections_rgb[pname] = minetest.deserialize(player:get_attribute("wardrobe_rgb"))
|
||||
print ("[Wardrobe] Loaded RGB Data for Player: " .. pname)
|
||||
|
@ -1046,15 +1056,16 @@ end
|
|||
function wardrobe.save_user_data(player)
|
||||
local pname = player:get_player_name()
|
||||
|
||||
wardrobe.hand_textures:set_string("c", minetest.serialize(wardrobe.formspec_selections))
|
||||
wardrobe.hand_textures:set_string("rgb", minetest.serialize(wardrobe.formspec_selections_rgb))
|
||||
|
||||
player:set_attribute("wardrobe_choices", minetest.serialize(wardrobe.formspec_selections[pname]))
|
||||
player:set_attribute("wardrobe_rgb", minetest.serialize(wardrobe.formspec_selections_rgb[pname]))
|
||||
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local pname = player:get_player_name()
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
wardrobe.load_user_data(player)
|
||||
|
||||
wardrobe.apply_to_player(player)
|
||||
end)
|
||||
end)
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,191 @@
|
|||
xof 0303txt 0032
|
||||
|
||||
Frame Root {
|
||||
FrameTransformMatrix {
|
||||
1.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 1.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 1.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 1.000000;;
|
||||
}
|
||||
Frame Player {
|
||||
FrameTransformMatrix {
|
||||
1.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 1.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 1.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 1.000000;;
|
||||
}
|
||||
Mesh { // Player mesh
|
||||
48;
|
||||
-0.947815; 1.449432; 0.619691;,
|
||||
-1.915444; 1.386065; 0.375399;,
|
||||
-1.902906; 0.407224; 0.579638;,
|
||||
-0.935277; 0.470591; 0.823930;,
|
||||
-1.064723; 0.729409;-2.823929;,
|
||||
-0.097094; 0.792776;-2.579638;,
|
||||
-0.084556;-0.186065;-2.375399;,
|
||||
-1.052185;-0.249432;-2.619691;,
|
||||
-1.052185;-0.249432;-2.619691;,
|
||||
-1.902906; 0.407224; 0.579638;,
|
||||
-1.915444; 1.386065; 0.375399;,
|
||||
-1.064723; 0.729409;-2.823929;,
|
||||
-1.064723; 0.729409;-2.823929;,
|
||||
-1.915444; 1.386065; 0.375399;,
|
||||
-0.947815; 1.449432; 0.619691;,
|
||||
-0.097094; 0.792776;-2.579638;,
|
||||
-0.097094; 0.792776;-2.579638;,
|
||||
-0.947815; 1.449432; 0.619691;,
|
||||
-0.935277; 0.470591; 0.823930;,
|
||||
-0.084556;-0.186065;-2.375399;,
|
||||
-0.084556;-0.186065;-2.375399;,
|
||||
-0.935277; 0.470591; 0.823930;,
|
||||
-1.902906; 0.407224; 0.579638;,
|
||||
-1.052185;-0.249432;-2.619691;,
|
||||
-0.942596; 1.534375; 0.781660;,
|
||||
-2.006988; 1.464672; 0.512939;,
|
||||
-1.993197; 0.387946; 0.737602;,
|
||||
-0.928805; 0.457650; 1.006323;,
|
||||
-1.071195; 0.742350;-3.006322;,
|
||||
-0.006803; 0.812053;-2.737602;,
|
||||
0.006988;-0.264671;-2.512938;,
|
||||
-1.057404;-0.334375;-2.781660;,
|
||||
-1.057404;-0.334375;-2.781660;,
|
||||
-1.993197; 0.387946; 0.737602;,
|
||||
-2.006988; 1.464672; 0.512939;,
|
||||
-1.071195; 0.742350;-3.006322;,
|
||||
-1.071195; 0.742350;-3.006322;,
|
||||
-2.006988; 1.464672; 0.512939;,
|
||||
-0.942596; 1.534375; 0.781660;,
|
||||
-0.006803; 0.812053;-2.737602;,
|
||||
-0.006803; 0.812053;-2.737602;,
|
||||
-0.942596; 1.534375; 0.781660;,
|
||||
-0.928805; 0.457650; 1.006323;,
|
||||
0.006988;-0.264671;-2.512938;,
|
||||
0.006988;-0.264671;-2.512938;,
|
||||
-0.928805; 0.457650; 1.006323;,
|
||||
-1.993197; 0.387946; 0.737602;,
|
||||
-1.057404;-0.334375;-2.781660;;
|
||||
12;
|
||||
4;0,1,2,3;,
|
||||
4;4,5,6,7;,
|
||||
4;8,9,10,11;,
|
||||
4;12,13,14,15;,
|
||||
4;16,17,18,19;,
|
||||
4;20,21,22,23;,
|
||||
4;24,25,26,27;,
|
||||
4;28,29,30,31;,
|
||||
4;32,33,34,35;,
|
||||
4;36,37,38,39;,
|
||||
4;40,41,42,43;,
|
||||
4;44,45,46,47;;
|
||||
MeshNormals { // Player normals
|
||||
12;
|
||||
-0.252065; 0.194565; 0.947949;,
|
||||
0.252065;-0.194565;-0.947949;,
|
||||
-0.967629;-0.063367;-0.244293;,
|
||||
-0.012538; 0.978841;-0.204239;,
|
||||
0.967629; 0.063367; 0.244293;,
|
||||
0.012538;-0.978841; 0.204239;,
|
||||
-0.252065; 0.194565; 0.947949;,
|
||||
0.252065;-0.194565;-0.947949;,
|
||||
-0.967629;-0.063367;-0.244292;,
|
||||
-0.012538; 0.978841;-0.204239;,
|
||||
0.967629; 0.063367; 0.244293;,
|
||||
0.012538;-0.978841; 0.204239;;
|
||||
12;
|
||||
4;0,0,0,0;,
|
||||
4;1,1,1,1;,
|
||||
4;2,2,2,2;,
|
||||
4;3,3,3,3;,
|
||||
4;4,4,4,4;,
|
||||
4;5,5,5,5;,
|
||||
4;6,6,6,6;,
|
||||
4;7,7,7,7;,
|
||||
4;8,8,8,8;,
|
||||
4;9,9,9,9;,
|
||||
4;10,10,10,10;,
|
||||
4;11,11,11,11;;
|
||||
} // End of Player normals
|
||||
MeshTextureCoords { // Player UV coordinates
|
||||
48;
|
||||
0.750000; 0.312500;,
|
||||
0.812500; 0.312500;,
|
||||
0.812500; 0.250000;,
|
||||
0.750000; 0.250000;,
|
||||
0.687500; 0.312500;,
|
||||
0.750000; 0.312500;,
|
||||
0.750000; 0.250000;,
|
||||
0.687500; 0.250000;,
|
||||
0.625000; 0.312500;,
|
||||
0.625000; 0.500000;,
|
||||
0.687500; 0.500000;,
|
||||
0.687500; 0.312500;,
|
||||
0.687500; 0.312500;,
|
||||
0.687500; 0.500000;,
|
||||
0.750000; 0.500000;,
|
||||
0.750000; 0.312500;,
|
||||
0.750000; 0.312500;,
|
||||
0.750000; 0.500000;,
|
||||
0.812500; 0.500000;,
|
||||
0.812500; 0.312500;,
|
||||
0.812500; 0.312500;,
|
||||
0.812500; 0.500000;,
|
||||
0.875000; 0.500000;,
|
||||
0.875000; 0.312500;,
|
||||
0.750000; 0.562500;,
|
||||
0.812500; 0.562500;,
|
||||
0.812500; 0.500000;,
|
||||
0.750000; 0.500000;,
|
||||
0.687500; 0.562500;,
|
||||
0.750000; 0.562500;,
|
||||
0.750000; 0.500000;,
|
||||
0.687500; 0.500000;,
|
||||
0.625000; 0.562500;,
|
||||
0.625000; 0.750000;,
|
||||
0.687500; 0.750000;,
|
||||
0.687500; 0.562500;,
|
||||
0.687500; 0.562500;,
|
||||
0.687500; 0.750000;,
|
||||
0.750000; 0.750000;,
|
||||
0.750000; 0.562500;,
|
||||
0.750000; 0.562500;,
|
||||
0.750000; 0.750000;,
|
||||
0.812500; 0.750000;,
|
||||
0.812500; 0.562500;,
|
||||
0.812500; 0.562500;,
|
||||
0.812500; 0.750000;,
|
||||
0.875000; 0.750000;,
|
||||
0.875000; 0.562500;;
|
||||
} // End of Player UV coordinates
|
||||
MeshMaterialList { // Player material list
|
||||
2;
|
||||
12;
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1;
|
||||
Material LowerArm {
|
||||
0.640000; 0.640000; 0.640000; 0.000000;;
|
||||
96.078431;
|
||||
0.000000; 0.000000; 0.000000;;
|
||||
0.000000; 0.000000; 0.000000;;
|
||||
TextureFilename {"wardrobe_under_shirt_2.png";}
|
||||
}
|
||||
Material UpperArm {
|
||||
0.640000; 0.640000; 0.640000; 0.000000;;
|
||||
96.078431;
|
||||
0.000000; 0.000000; 0.000000;;
|
||||
0.000000; 0.000000; 0.000000;;
|
||||
TextureFilename {"wardrobe_shirt_2.png";}
|
||||
}
|
||||
} // End of Player material list
|
||||
} // End of Player mesh
|
||||
} // End of Player
|
||||
} // End of Root
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
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 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 information, please refer to <http://unlicense.org/>
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
Wiki Mod
|
||||
========
|
||||
|
||||
Another random mod by me.
|
||||
|
||||
This mod provides a "Wiki" block. You can create and edit wiki pages with it.
|
||||
|
||||
The pages are saved as `<worldpath>/wiki/<pagename>`. All spaces in the page
|
||||
name are converted to underscores, and all other characters not in
|
||||
`[A-Za-z0-9-]` are converted to hex notation `%XX`.
|
||||
|
||||
The text can contain hyperlinks in the form of `[link text]` to other pages.
|
||||
Such links are added at the right of the form.
|
||||
|
||||
You can craft a "Wiki block" by putting 9 bookshelves in the crafting grid.
|
||||
|
||||
Only players with the `wiki` priv can create/edit pages.
|
||||
|
||||
|
||||
## Installing
|
||||
|
||||
Install by following the instructions in the [Installing mods][install]
|
||||
article on the Minetest wiki, then add `wiki` to the `secure.trusted_mods`
|
||||
setting in `minetest.conf`.
|
||||
|
||||
[install]: https://wiki.minetest.net/Installing_mods
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "wiki",
|
||||
"description": "Online collaborative documentation browser.",
|
||||
"keywords": [
|
||||
"wiki",
|
||||
"doc",
|
||||
"documentation",
|
||||
"browser"
|
||||
],
|
||||
"homepage": "https://github.com/kaeza/minetest-wiki.git",
|
||||
"screenshots": [
|
||||
"https://dl.dropboxusercontent.com/u/100008207/minetest/mods/Kaeza-minetest-wiki.jpg"
|
||||
],
|
||||
"authors": [
|
||||
"Diego Martínez <lkaezadl3@yahoo.com>"
|
||||
],
|
||||
"license": "BSD 2-Clause"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1 @@
|
|||
This mod provides a "Wiki" block. You can create and edit wiki pages with it.
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
local MODPATH = minetest.get_modpath("wiki")
|
||||
|
||||
wikilib = { }
|
||||
|
||||
local ie = minetest.request_insecure_environment()
|
||||
assert(ie, "you must allow `wiki` in `secure.trusted_mods`")
|
||||
|
||||
local private = { }
|
||||
|
||||
private.open = ie.io.open
|
||||
private.mkdir = ie.core.mkdir
|
||||
|
||||
loadfile(MODPATH.."/strfile.lua")(private)
|
||||
loadfile(MODPATH.."/wikilib.lua")(private)
|
||||
loadfile(MODPATH.."/internal.lua")(private)
|
||||
loadfile(MODPATH.."/plugins.lua")(private)
|
||||
|
||||
loadfile(MODPATH.."/plugin_forum.lua")(private)
|
|
@ -0,0 +1,164 @@
|
|||
|
||||
wikilib.internal_pages = {
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
[".Intro"] = [[
|
||||
Thank you for using the Wiki Mod.
|
||||
|
||||
This is a mod that allows one to edit pages via a block. You
|
||||
can use it to document interesting places in a server, to provide
|
||||
a place to post griefing reports, or any kind of text you want.
|
||||
|
||||
To create a new page, enter the name in the field at the top of the
|
||||
form, then click "Go". If the page already exists, it's contents will
|
||||
be displayed. Edit the page as you see fit, then click on "Save" to
|
||||
write the changes to disk.
|
||||
|
||||
Please note that page names starting with a dot ('.') are reserved
|
||||
for internal topics such as this one. Users cannot edit/create such
|
||||
pages from the mod interface.
|
||||
|
||||
See also:
|
||||
* [.Tags]
|
||||
* [.License]
|
||||
* [.Help Index]
|
||||
]],
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
[".Tags"] = [[
|
||||
The wiki supports some special tags.
|
||||
|
||||
You can place hyperlinks to other pages in the Wiki, by surrounding
|
||||
text in square brackets (for example, [.Intro]). Such links will
|
||||
appear at the bottom of the form.
|
||||
|
||||
See also:
|
||||
* [.Intro]
|
||||
]],
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
[".License"] = [[
|
||||
|
||||
Copyright (c) 2013, Diego Martínez
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
* Go to [.Intro].
|
||||
]],
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
[".NotFound_Internal"] = [[
|
||||
The specified internal page cannot be found. You may want to:
|
||||
|
||||
* Back to [Main].
|
||||
* Go to [.Intro].
|
||||
]],
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
[".NotFound"] = [[
|
||||
This page does not exist yet.
|
||||
|
||||
* Back to [Main].
|
||||
* Go to [.Help Index].
|
||||
]],
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
[".BadPageName"] = [[
|
||||
The page name you entered is wrong. See [.Page Names] for more info.
|
||||
|
||||
* Back to [Main].
|
||||
* Go to [.Help Index].
|
||||
]],
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
[".Forbidden"] = [[
|
||||
You have not enough privileges to view this page.
|
||||
|
||||
* Back to [Main].
|
||||
* Go to [.Help Index].
|
||||
]],
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
[".Help Index"] = [[
|
||||
* [.Intro]
|
||||
* [.Plugins]
|
||||
* [.Page Names]
|
||||
* [.User Pages]
|
||||
|
||||
* Back to [Main].
|
||||
]],
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
[".Page Names"] = [[
|
||||
Page names must be in any of the following formats:
|
||||
<pagename>
|
||||
Display global page <pagename>.
|
||||
:<n>
|
||||
Display page <n> from your user space. <n> must be a number between
|
||||
0 and 9. See [.User Pages] for more info.
|
||||
:
|
||||
This is equivalent to ":0" (shows your private page).
|
||||
:<user>:<n>
|
||||
Display page "Page Name" from the specified user's space. Note that page
|
||||
number 0 is never accessible this way, even if you specify yourself as
|
||||
<user>.
|
||||
|
||||
* Back to [.Help Index].
|
||||
* Back to [Main].
|
||||
]],
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
[".User Pages"] = [[
|
||||
Users can have up to 10 pages in their "user space", numbered 0-9. These pages
|
||||
are accessed through the special page names ":<n>", and ":<user>:<n>". Page 0
|
||||
is your private page. This page is not accessible to anyone but you. You can
|
||||
use it to write down secret locations, etc.
|
||||
|
||||
* Back to [.Help Index].
|
||||
* Back to [Main].
|
||||
]],
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
[".My Pages"] = [[
|
||||
* Profile: [:profile]
|
||||
* Private page: [:0]
|
||||
* Pages: [:1] [:2] [:3] [:4] [:5] [:6] [:7] [:8] [:9]
|
||||
]],
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
[".Plugins"] = function()
|
||||
local page = "Installed Plugins:\n\n"
|
||||
for _,plugin in ipairs(wikilib.registered_plugins) do
|
||||
page = page.." * "..plugin.description.."\n"
|
||||
end
|
||||
page = (page
|
||||
.. "\n"
|
||||
.. " * Back to [.Help Index].\n"
|
||||
.. " * Back to [Main].\n"
|
||||
)
|
||||
return page
|
||||
end,
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
name = wiki
|
|
@ -0,0 +1,147 @@
|
|||
|
||||
local private = ...
|
||||
|
||||
local BASEPATH = wikilib.paths.plugins.."/ml"
|
||||
|
||||
private.mkdir(BASEPATH)
|
||||
|
||||
local ML_DB_FILE = BASEPATH.."/posts.dat"
|
||||
|
||||
local posts = { }
|
||||
|
||||
local function load_posts()
|
||||
local f = private.open(ML_DB_FILE, "r")
|
||||
if not f then return false end
|
||||
local list = { }
|
||||
local post = { text="" }
|
||||
for line in f:lines() do
|
||||
if line:len() == 0 then
|
||||
if post.who and post.date then
|
||||
table.insert(list, post)
|
||||
post = { text="" }
|
||||
end
|
||||
elseif line:sub(1, 5) == "From:" then
|
||||
post.who = line:sub(6):trim()
|
||||
elseif line:sub(1, 5) == "Date:" then
|
||||
post.date = line:sub(6):trim()
|
||||
else
|
||||
post.text = post.text..line.."\n"
|
||||
end
|
||||
end
|
||||
if post.who and post.date then
|
||||
table.insert(list, post)
|
||||
post = { text="" }
|
||||
end
|
||||
f:close()
|
||||
posts = list
|
||||
return true
|
||||
end
|
||||
|
||||
local function save_posts()
|
||||
local f = private.open(ML_DB_FILE, "w")
|
||||
if not f then return false end
|
||||
for _, post in ipairs(posts) do
|
||||
f:write("From: "..post.who.."\n")
|
||||
f:write("Date: "..post.date.."\n")
|
||||
for _, line in ipairs(post.text:split("\n")) do
|
||||
if line:len() == 0 then
|
||||
f:write(" \n")
|
||||
elseif (line:sub(1, 5) == "From:")
|
||||
or (line:sub(1, 5) == "Date:") then
|
||||
f:write(" "..line.."\n")
|
||||
else
|
||||
f:write(line.."\n")
|
||||
end
|
||||
end
|
||||
f:write("\n")
|
||||
end
|
||||
f:close()
|
||||
return true
|
||||
end
|
||||
|
||||
local player_states = { }
|
||||
|
||||
local BACKLOG = 5
|
||||
|
||||
local function get_player_state(name)
|
||||
if not player_states[name] then
|
||||
player_states[name] = { }
|
||||
end
|
||||
return player_states[name]
|
||||
end
|
||||
|
||||
local SEP = ("-"):rep(64)
|
||||
|
||||
wikilib.register_plugin({
|
||||
regex = "^/ml/.*",
|
||||
description = "Mailing List [/ml/recent]",
|
||||
load_page = function(entry, player) --> text, allow_save
|
||||
local state = get_player_state(player)
|
||||
local what = entry:match("^/ml/(.*)")
|
||||
if not what then
|
||||
what = "recent"
|
||||
end
|
||||
what = what:lower()
|
||||
if what == "recent" then
|
||||
local text = "Recent Posts:\n\n"..SEP.."\n"
|
||||
for i = #posts - BACKLOG, #posts do
|
||||
local p = posts[i]
|
||||
if p then
|
||||
local nl = ((p.text:sub(-1) == "\n") and "" or "\n")
|
||||
text = (text
|
||||
.. "[/ml/"..i.."] \n"
|
||||
.. "From: "..p.who.."\n"
|
||||
.. "Date: "..p.date.."\n"
|
||||
.. p.text..nl
|
||||
.. SEP.."\n"
|
||||
)
|
||||
end
|
||||
end
|
||||
text = text.."\n * [/ml/Post] a new message"
|
||||
text = text.."\n * Back to [Main]"
|
||||
return text, false
|
||||
elseif what:match("[0-9]+") then
|
||||
local n = tonumber(what)
|
||||
local text
|
||||
if posts[n] then
|
||||
local nl = ((posts[n].text:sub(-1) == "\n") and "" or "\n")
|
||||
text = ("Post #"..n.."\n"
|
||||
.. "From: "..posts[n].who.." [:"..posts[n].who..":profile]\n"
|
||||
.. "Date: "..posts[n].date.."\n"
|
||||
.. posts[n].text..nl
|
||||
.. "\n"
|
||||
)
|
||||
else
|
||||
text = "No such post.\n\n"
|
||||
end
|
||||
text = text.."\n * [/ml/Post] a new message"
|
||||
text = text.."\n * View [/ml/Recent] messages"
|
||||
text = text.."\n * Back to [Main]"
|
||||
return text, false
|
||||
elseif what == "post" then
|
||||
return "Subject:\n\n<Edit this message and save to post>", true
|
||||
end
|
||||
return "Wrong request.", false
|
||||
end,
|
||||
save_page = function(entry, player, text) --> bool
|
||||
local state = get_player_state(player)
|
||||
local what = entry:match("^/ml/(.*)")
|
||||
if not what then
|
||||
what = "post"
|
||||
end
|
||||
what = what:lower()
|
||||
if what == "post" then
|
||||
posts[#posts + 1] = {
|
||||
who = player,
|
||||
date = os.date("%Y-%m-%d %H:%M:%S"),
|
||||
text = text,
|
||||
}
|
||||
save_posts()
|
||||
return "/ml/recent"
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
load_posts()
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
--[[
|
||||
plugindef = {
|
||||
regex = "^/foo/bar/.*",
|
||||
description = "My Awesome Plugin",
|
||||
^ Can contain links
|
||||
load_page = func(entry, player),
|
||||
^ Must return text, allow_save
|
||||
save_page = func(entry, player),
|
||||
^ Must return bool
|
||||
}
|
||||
]]
|
||||
|
||||
local plugin_defs = { }
|
||||
|
||||
function wikilib.register_plugin(def)
|
||||
plugin_defs[#plugin_defs + 1] = def
|
||||
end
|
||||
|
||||
local function do_handle(what, entry, player, text)
|
||||
for _,pi in ipairs(plugin_defs) do
|
||||
if entry:match(pi.regex) then
|
||||
return pi[what](entry, player, text)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function wikilib.plugin_handle_load(entry, player)
|
||||
return do_handle("load_page", entry, player)
|
||||
end
|
||||
|
||||
function wikilib.plugin_handle_save(entry, player, text)
|
||||
return do_handle("save_page", entry, player, text)
|
||||
end
|
||||
|
||||
wikilib.registered_plugins = plugin_defs
|
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
|
@ -0,0 +1,28 @@
|
|||
|
||||
strfile = { }
|
||||
|
||||
function strfile.open(s)
|
||||
return {
|
||||
_buf = s,
|
||||
_pos = 1,
|
||||
_readline = function(self)
|
||||
if self._pos == nil then
|
||||
return nil
|
||||
end
|
||||
local nl = self._buf:find("\n", self._pos, true)
|
||||
local line
|
||||
if nl then
|
||||
line = self._buf:sub(self._pos, nl - 1)
|
||||
nl = nl + 1
|
||||
else
|
||||
line = self._buf:sub(self._pos)
|
||||
end
|
||||
self._pos = nl
|
||||
return line
|
||||
end,
|
||||
lines = function(self)
|
||||
return self._readline, self, true
|
||||
end,
|
||||
close = function(self) end,
|
||||
}
|
||||
end
|
Binary file not shown.
After Width: | Height: | Size: 532 B |
|
@ -0,0 +1,249 @@
|
|||
|
||||
local private = ...
|
||||
|
||||
local WP = minetest.get_worldpath().."/wiki"
|
||||
|
||||
wikilib.paths = { }
|
||||
wikilib.paths.root = WP
|
||||
wikilib.paths.pages = WP.."/pages"
|
||||
wikilib.paths.plugins = WP.."/plugins"
|
||||
wikilib.paths.users = WP.."/users"
|
||||
|
||||
local WIKI_FORMNAME = "wiki:wiki"
|
||||
|
||||
private.mkdir(WP)
|
||||
private.mkdir(wikilib.paths.pages)
|
||||
private.mkdir(wikilib.paths.plugins)
|
||||
private.mkdir(wikilib.paths.users)
|
||||
|
||||
local function name_to_filename(name)
|
||||
|
||||
name = name:gsub("[^A-Za-z0-9-]", function(c)
|
||||
if c == " " then
|
||||
return "_"
|
||||
else
|
||||
return ("%%%02X"):format(c:byte(1))
|
||||
end
|
||||
end)
|
||||
return name:lower()
|
||||
|
||||
end
|
||||
wikilib.name_to_filename = name_to_filename
|
||||
|
||||
local function get_page_path(name, player) --> path, is_file, allow_save
|
||||
|
||||
local allow_save = minetest.check_player_privs(player, {wiki=true})
|
||||
|
||||
if name:sub(1, 1) == "." then
|
||||
local text = wikilib.internal_pages[name] or wikilib.internal_pages[".NotFound_Internal"]
|
||||
if type(text) == "function" then
|
||||
text = text(player)
|
||||
end
|
||||
return text, false, false
|
||||
elseif name:sub(1, 1) == ":" then
|
||||
if name:match("^:[0-9]?$") then
|
||||
local n = tonumber(name:sub(2,2)) or 0
|
||||
path = "users/"..player.."/page"..n
|
||||
private.mkdir(wikilib.paths.users.."/"..player)
|
||||
elseif name == ":profile" then
|
||||
path = "users/"..player.."/profile"
|
||||
private.mkdir(wikilib.paths.users.."/"..player)
|
||||
elseif name:match("^:.-:[0-9]$") then
|
||||
local user, n = name:match("^:(.-):([0-9])$")
|
||||
if user:find("..[/\\]") then
|
||||
return wikilib.internal_pages[".BadPageName"], false, false
|
||||
end
|
||||
if (n == "0") and (not minetest.check_player_privs(player, {wiki_admin=true})) then
|
||||
return wikilib.internal_pages[".Forbidden"], false, false
|
||||
end
|
||||
path = "users/"..user.."/page"..n
|
||||
private.mkdir(WP.."/users/"..user)
|
||||
allow_save = false
|
||||
elseif name:match("^:.-:profile$") then
|
||||
local user = name:match("^:(.-):.*$")
|
||||
if user:find("..[/\\]") then
|
||||
return wikilib.internal_pages[".BadPageName"], false, false
|
||||
end
|
||||
path = "users/"..user.."/profile"
|
||||
private.mkdir(WP.."/users/"..user)
|
||||
allow_save = false
|
||||
else
|
||||
return wikilib.internal_pages[".BadPageName"], false, false
|
||||
end
|
||||
else
|
||||
path = "pages/"..name_to_filename(name)
|
||||
end
|
||||
|
||||
return WP.."/"..path, true, allow_save
|
||||
|
||||
end
|
||||
|
||||
local function find_links(lines) --> links
|
||||
local links = { }
|
||||
local links_n = 0
|
||||
for _,line in ipairs(lines) do
|
||||
for link in line:gmatch("%[(.-)%]") do
|
||||
links_n = links_n + 1
|
||||
links[links_n] = link
|
||||
end
|
||||
end
|
||||
return links
|
||||
end
|
||||
|
||||
local function load_page(name, player) --> text, links, allow_save
|
||||
local text, allow_save = wikilib.plugin_handle_load(name, player)
|
||||
if text then
|
||||
return text, find_links(text:split("\n")), allow_save
|
||||
end
|
||||
local path, is_file, allow_save = get_page_path(name, player)
|
||||
local f
|
||||
if is_file then
|
||||
f = private.open(path)
|
||||
if not f then
|
||||
f = strfile.open(wikilib.internal_pages[".NotFound"])
|
||||
end
|
||||
else
|
||||
f = strfile.open(path)
|
||||
end
|
||||
local lines = { }
|
||||
local lines_n = 0
|
||||
for line in f:lines() do
|
||||
lines_n = lines_n + 1
|
||||
lines[lines_n] = line
|
||||
end
|
||||
f:close()
|
||||
local text = table.concat(lines, "\n")
|
||||
local links = find_links(lines)
|
||||
return text, links, allow_save
|
||||
end
|
||||
|
||||
local function save_page(name, player, text)
|
||||
|
||||
local ok = wikilib.plugin_handle_save(name, player, text)
|
||||
if ok then return ok end
|
||||
|
||||
local path, is_file, allow_save = get_page_path(name, player)
|
||||
|
||||
if (not is_file) or (not allow_save) then return end
|
||||
|
||||
local f = private.open(path, "w")
|
||||
if not f then return end
|
||||
|
||||
f:write(text)
|
||||
|
||||
f:close()
|
||||
|
||||
end
|
||||
|
||||
local esc = minetest.formspec_escape
|
||||
|
||||
function wikilib.get_wiki_page_formspec(player, name)
|
||||
|
||||
if name == "" then name = "Main" end
|
||||
|
||||
local text, links, allow_save = load_page(name, player)
|
||||
|
||||
local buttons, nbuttons = { }, 0
|
||||
local bx, by = 12, 1.1
|
||||
|
||||
for i, link in ipairs(links) do
|
||||
if i%15 == 0 then
|
||||
bx = bx + 2
|
||||
by = 1.1
|
||||
end
|
||||
link = esc(link)
|
||||
nbuttons = nbuttons + 1
|
||||
buttons[nbuttons] = (("button[%f,%f;2.1,0.5;page_%s;%s]")
|
||||
:format(bx, by, link, link))
|
||||
by = by + 0.65
|
||||
end
|
||||
buttons = table.concat(buttons)
|
||||
|
||||
local toolbar = (allow_save
|
||||
and "button[-.1,9.2;2.4,1;save;Save]"
|
||||
or "label[0,9;You are not authorized to edit this page.]")
|
||||
|
||||
return ("size[16,10]"
|
||||
.. "label[-0.1,0;Page]"
|
||||
.. "field[1.5,0.1;13,1;page;;"..esc(name).."]"
|
||||
.. "button[14,0;1,0.5;go;Go]"
|
||||
.. "button_exit[15,0;1,0.5;close;X]"
|
||||
.. "textarea[0.2,1.1;12,9;text;"..esc(name)..";"..esc(text).."]"
|
||||
.. buttons
|
||||
.. toolbar
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
function wikilib.show_wiki_page(player, name)
|
||||
local fs = wikilib.get_wiki_page_formspec(player, name)
|
||||
minetest.show_formspec(player, WIKI_FORMNAME, fs)
|
||||
end
|
||||
|
||||
minetest.register_node("wiki:wiki", {
|
||||
description = "Wiki",
|
||||
tiles = {
|
||||
"default_wood.png", "default_wood.png",
|
||||
"[combine:16x16:0,0=default_bookshelf.png:0,0=wiki_wiki_front.png"
|
||||
},
|
||||
groups = { choppy=3, oddly_breakable_by_hand=2, flammable=3 },
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", "Wiki")
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
if clicker then
|
||||
wikilib.show_wiki_page(clicker:get_player_name(), "Main")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_privilege("wiki", {
|
||||
description = "Allow editing wiki pages in the global space",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
|
||||
minetest.register_privilege("wiki_admin", {
|
||||
description = "Allow editing wiki pages in any space",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
|
||||
local BS = "default:bookshelf"
|
||||
local BSL = { BS, BS, BS }
|
||||
minetest.register_craft({
|
||||
output = "wiki:wiki",
|
||||
recipe = { BSL, BSL, BSL },
|
||||
})
|
||||
|
||||
function wikilib.handle_formspec(player, formname, fields)
|
||||
if (not formname) or (formname ~= WIKI_FORMNAME) then return end
|
||||
if fields.quit or fields.close then return end
|
||||
local plname = player:get_player_name()
|
||||
if fields.save then
|
||||
local r = save_page(fields.page, plname, fields.text)
|
||||
if type(r) == "string" then
|
||||
wikilib.show_wiki_page(plname, r)
|
||||
else
|
||||
wikilib.show_wiki_page(plname, fields.page)
|
||||
end
|
||||
return true
|
||||
elseif fields.go then
|
||||
wikilib.show_wiki_page(plname, fields.page)
|
||||
return true
|
||||
else
|
||||
for k in pairs(fields) do
|
||||
if type(k) == "string" then
|
||||
local name = k:match("^page_(.*)")
|
||||
if name then
|
||||
wikilib.show_wiki_page(plname, name)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
wikilib.handle_formspec(player, formname, fields)
|
||||
end)
|
Loading…
Reference in New Issue