Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
minetest_game
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
minetest_game
Commits
dfa0f096
Commit
dfa0f096
authored
12 years ago
by
PilzAdam
Browse files
Options
Downloads
Patches
Plain Diff
Use full stacks in the creative inventory and add a trash field
parent
e9ad8d06
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mods/creative/init.lua
+23
-8
23 additions, 8 deletions
mods/creative/init.lua
with
23 additions
and
8 deletions
mods/creative/init.lua
+
23
−
8
View file @
dfa0f096
...
...
@@ -14,11 +14,7 @@ minetest.after(0, function()
end
end
,
allow_put
=
function
(
inv
,
listname
,
index
,
stack
,
player
)
if
minetest
.
setting_getbool
(
"creative_mode"
)
then
return
-
1
else
return
0
end
return
0
end
,
allow_take
=
function
(
inv
,
listname
,
index
,
stack
,
player
)
if
minetest
.
setting_getbool
(
"creative_mode"
)
then
...
...
@@ -54,8 +50,7 @@ minetest.after(0, function()
if
stack
:
get_stack_max
()
==
1
then
stack2
=
ItemStack
(
stack
:
get_name
())
else
-- Insert half full so that a taken stack can be put back
stack2
=
ItemStack
(
stack
:
get_name
()
..
" "
..
(
stack
:
get_stack_max
()
/
2
))
stack2
=
ItemStack
(
stack
:
get_name
()
..
" "
..
stack
:
get_stack_max
())
end
inv
:
add_item
(
"main"
,
stack2
)
end
...
...
@@ -63,6 +58,24 @@ minetest.after(0, function()
print
(
"creative inventory size: "
..
dump
(
creative_inventory
.
creative_inventory_size
))
end
)
-- Create the trash field
local
trash
=
minetest
.
create_detached_inventory
(
"creative_trash"
,
{
-- Allow the stack to be placed and remove it in on_put()
-- This allows the creative inventory to restore the stack
allow_put
=
function
(
inv
,
listname
,
index
,
stack
,
player
)
if
minetest
.
setting_getbool
(
"creative_mode"
)
then
return
stack
:
get_count
()
else
return
0
end
end
,
on_put
=
function
(
inv
,
listname
,
index
,
stack
,
player
)
inv
:
set_stack
(
listname
,
index
,
""
)
end
,
})
trash
:
set_size
(
"main"
,
1
)
creative_inventory
.
set_creative_formspec
=
function
(
player
,
start_i
,
pagenum
)
pagenum
=
math.floor
(
pagenum
)
local
pagemax
=
math.floor
((
creative_inventory
.
creative_inventory_size
-
1
)
/
(
6
*
4
)
+
1
)
...
...
@@ -74,7 +87,9 @@ creative_inventory.set_creative_formspec = function(player, start_i, pagenum)
"list[detached:creative;main;0.3,0.5;4,6;"
..
tostring
(
start_i
)
..
"]"
..
"label[2.0,6.55;"
..
tostring
(
pagenum
)
..
"/"
..
tostring
(
pagemax
)
..
"]"
..
"button[0.3,6.5;1.6,1;creative_prev;<<]"
..
"button[2.7,6.5;1.6,1;creative_next;>>]"
)
"button[2.7,6.5;1.6,1;creative_next;>>]"
..
"label[5,1.5;Trash:]"
..
"list[detached:creative_trash;main;5,2;1,1;]"
)
end
minetest
.
register_on_joinplayer
(
function
(
player
)
-- If in creative mode, modify player's inventory forms
...
...
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