Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inventory_plus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
inventory_plus
Commits
a334ea74
Commit
a334ea74
authored
12 years ago
by
Brett O'Donnell
Browse files
Options
Downloads
Patches
Plain Diff
initial commit
parents
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.txt
+51
-0
51 additions, 0 deletions
README.txt
init.lua
+93
-0
93 additions, 0 deletions
init.lua
with
144 additions
and
0 deletions
README.txt
0 → 100644
+
51
−
0
View file @
a334ea74
----------------------------------
Inventory Plus for Minetest
----------------------------------
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
Source Code: https://github.com/cornernote/minetest-bags
License: GPLv3
----------------------------------
Description
----------------------------------
Allows additional formspec buttons to be added to the player inventory screen.
These are processed by your own mod, they can show other formspec screens, or perform in game functionality.
Supports creative mode with no code changes.
----------------------------------
License
----------------------------------
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
----------------------------------
Credits
----------------------------------
Thank you to the minetest community who has shared their code and knowledge with me.
This diff is collapsed.
Click to expand it.
init.lua
0 → 100644
+
93
−
0
View file @
a334ea74
--[[
Inventory Plus for Minetest
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
Source Code: https://github.com/cornernote/minetest-particles
License: GPLv3
]]
--
-- expose api
inventory_plus
=
{}
-- define pages
inventory_plus
.
pages
=
{}
if
minetest
.
setting_getbool
(
"creative_mode"
)
then
inventory_plus
.
pages
[
"creative_prev"
]
=
"Creative"
end
inventory_plus
.
pages
[
"craft"
]
=
"Craft"
-- set_inventory_formspec
inventory_plus
.
set_inventory_formspec
=
function
(
player
,
formspec
)
if
minetest
.
setting_getbool
(
"creative_mode"
)
then
-- if creative mode is on then wait a bit
minetest
.
after
(
0
.
01
,
function
()
player
:
set_inventory_formspec
(
formspec
)
end
)
else
player
:
set_inventory_formspec
(
formspec
)
end
end
-- get_formspec
inventory_plus
.
get_formspec
=
function
(
player
,
page
)
local
formspec
=
"size[8,7.5]"
-- player inventory
formspec
=
formspec
..
"list[current_player;main;0,3.5;8,4;]"
-- craft page
if
page
==
"craft"
then
formspec
=
formspec
..
"button[0,0;2,0.5;main;Back]"
..
"list[current_player;craft;3,0;3,3;]"
..
"list[current_player;craftpreview;7,1;1,1;]"
end
if
page
==
"main"
then
-- buttons
local
x
,
y
=
0
,
0
for
k
,
v
in
pairs
(
inventory_plus
.
pages
)
do
formspec
=
formspec
..
"button["
..
x
..
","
..
y
..
";2,0.5;"
..
k
..
";"
..
v
..
"]"
x
=
x
+
2
if
x
==
8
then
x
=
0
y
=
y
+
1
end
end
end
return
formspec
end
-- register_on_joinplayer
minetest
.
register_on_joinplayer
(
function
(
player
)
inventory_plus
.
set_inventory_formspec
(
player
,
inventory_plus
.
get_formspec
(
player
,
"main"
))
end
)
-- register_on_player_receive_fields
minetest
.
register_on_player_receive_fields
(
function
(
player
,
formname
,
fields
)
-- main
if
fields
.
main
then
inventory_plus
.
set_inventory_formspec
(
player
,
inventory_plus
.
get_formspec
(
player
,
"main"
))
return
end
-- craft
if
fields
.
craft
then
inventory_plus
.
set_inventory_formspec
(
player
,
inventory_plus
.
get_formspec
(
player
,
"craft"
))
return
end
-- creative
if
fields
.
creative_prev
or
fields
.
creative_next
then
minetest
.
after
(
0
.
01
,
function
()
inventory_plus
.
set_inventory_formspec
(
player
,
player
:
get_inventory_formspec
()
..
"button[5,0;2,0.5;main;Back]"
)
return
end
)
end
end
)
-- log that we started
minetest
.
log
(
"action"
,
"[MOD]"
..
minetest
.
get_current_modname
()
..
" -- loaded from "
..
minetest
.
get_modpath
(
minetest
.
get_current_modname
()))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment