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
e5189760
Commit
e5189760
authored
7 years ago
by
SmallJoker
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Default: Expose the formspec getter functions (#1783)
parent
1d5bc15f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
game_api.txt
+42
-0
42 additions, 0 deletions
game_api.txt
mods/default/furnace.lua
+28
-28
28 additions, 28 deletions
mods/default/furnace.lua
mods/default/nodes.lua
+4
-4
4 additions, 4 deletions
mods/default/nodes.lua
with
74 additions
and
32 deletions
game_api.txt
+
42
−
0
View file @
e5189760
...
...
@@ -592,6 +592,48 @@ Default constants
`default.LIGHT_MAX` The maximum light level (see [Node definition] light_source)
GUI and formspecs
-----------------
`default.get_hotbar_bg(x, y)`
* Get the hotbar background as string, containing the formspec elements
* x: Horizontal position in the formspec
* y: Vertical position in the formspec
`default.gui_bg`
* Background color formspec element
`default.gui_bg_img`
* Image overlay formspec element for the background to use in formspecs
`default.gui_slots`
* `listcolors` formspec element that is used to format the slots in formspecs
`default.gui_survival_form`
* Entire formspec for the survival inventory
`default.get_chest_formspec(pos)`
* Get the chest formspec using the defined GUI elements
* pos: Location of the node
`default.get_furnace_active_formspec(fuel_percent, item_percent)`
* Get the active furnace formspec using the defined GUI elements
* fuel_percent: Percent of how much the fuel is used
* item_percent: Percent of how much the item is cooked
`default.get_furnace_inactive_formspec()`
* Get the inactive furnace formspec using the defined GUI elements
Player API
----------
...
...
This diff is collapsed.
Click to expand it.
mods/default/furnace.lua
+
28
−
28
View file @
e5189760
...
...
@@ -3,9 +3,8 @@
-- Formspecs
--
local
function
active_formspec
(
fuel_percent
,
item_percent
)
local
formspec
=
"size[8,8.5]"
..
function
default
.
get_furnace_active_formspec
(
fuel_percent
,
item_percent
)
return
"size[8,8.5]"
..
default
.
gui_bg
..
default
.
gui_bg_img
..
default
.
gui_slots
..
...
...
@@ -25,28 +24,28 @@ local function active_formspec(fuel_percent, item_percent)
"listring[context;fuel]"
..
"listring[current_player;main]"
..
default
.
get_hotbar_bg
(
0
,
4
.
25
)
return
formspec
end
local
inactive_formspec
=
"size[8,8.5]"
..
default
.
gui_bg
..
default
.
gui_bg_img
..
default
.
gui_slots
..
"list[context;src;2.75,0.5;1,1;]"
..
"list[context;fuel;2.75,2.5;1,1;]"
..
"image[2.75,1.5;1,1;default_furnace_fire_bg.png]"
..
"image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"
..
"list[context;dst;4.75,0.96;2,2;]"
..
"list[current_player;main;0,4.25;8,1;]"
..
"list[current_player;main;0,5.5;8,3;8]"
..
"listring[context;dst]"
..
"listring[current_player;main]"
..
"listring[context;src]"
..
"listring[current_player;main]"
..
"listring[context;fuel]"
..
"listring[current_player;main]"
..
default
.
get_hotbar_bg
(
0
,
4
.
25
)
function
default
.
get_furnace_inactive_formspec
()
return
"size[8,8.5]"
..
default
.
gui_bg
..
default
.
gui_bg_img
..
default
.
gui_slots
..
"list[context;src;2.75,0.5;1,1;]"
..
"list[context;fuel;2.75,2.5;1,1;]"
..
"image[2.75,1.5;1,1;default_furnace_fire_bg.png]"
..
"image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"
..
"list[context;dst;4.75,0.96;2,2;]"
..
"list[current_player;main;0,4.25;8,1;]"
..
"list[current_player;main;0,5.5;8,3;8]"
..
"listring[context;dst]"
..
"listring[current_player;main]"
..
"listring[context;src]"
..
"listring[current_player;main]"
..
"listring[context;fuel]"
..
"listring[current_player;main]"
..
default
.
get_hotbar_bg
(
0
,
4
.
25
)
end
--
-- Node callback functions that are the same for active and inactive furnace
...
...
@@ -190,7 +189,7 @@ local function furnace_node_timer(pos, elapsed)
--
-- Update formspec, infotext and node
--
local
formspec
=
inactive_formspec
local
formspec
local
item_state
local
item_percent
=
0
if
cookable
then
...
...
@@ -216,7 +215,7 @@ local function furnace_node_timer(pos, elapsed)
active
=
"active "
local
fuel_percent
=
math.floor
(
fuel_time
/
fuel_totaltime
*
100
)
fuel_state
=
fuel_percent
..
"%"
formspec
=
active_formspec
(
fuel_percent
,
item_percent
)
formspec
=
default
.
get_furnace_
active_formspec
(
fuel_percent
,
item_percent
)
swap_node
(
pos
,
"default:furnace_active"
)
-- make sure timer restarts automatically
result
=
true
...
...
@@ -224,12 +223,14 @@ local function furnace_node_timer(pos, elapsed)
if
not
fuellist
[
1
]:
is_empty
()
then
fuel_state
=
"0%"
end
formspec
=
default
.
get_furnace_inactive_formspec
()
swap_node
(
pos
,
"default:furnace"
)
-- stop timer on the inactive furnace
minetest
.
get_node_timer
(
pos
):
stop
()
end
local
infotext
=
"Furnace "
..
active
..
"(Item: "
..
item_state
..
"; Fuel: "
..
fuel_state
..
")"
local
infotext
=
"Furnace "
..
active
..
"(Item: "
..
item_state
..
"; Fuel: "
..
fuel_state
..
")"
--
-- Set meta values
...
...
@@ -266,7 +267,7 @@ minetest.register_node("default:furnace", {
on_construct
=
function
(
pos
)
local
meta
=
minetest
.
get_meta
(
pos
)
meta
:
set_string
(
"formspec"
,
inactive_formspec
)
meta
:
set_string
(
"formspec"
,
default
.
get_furnace_
inactive_formspec
()
)
local
inv
=
meta
:
get_inventory
()
inv
:
set_size
(
'src'
,
1
)
inv
:
set_size
(
'fuel'
,
1
)
...
...
@@ -327,4 +328,3 @@ minetest.register_node("default:furnace_active", {
allow_metadata_inventory_move
=
allow_metadata_inventory_move
,
allow_metadata_inventory_take
=
allow_metadata_inventory_take
,
})
This diff is collapsed.
Click to expand it.
mods/default/nodes.lua
+
4
−
4
View file @
e5189760
...
...
@@ -1766,7 +1766,7 @@ minetest.register_node("default:lava_flowing", {
-- Tools / "Advanced" crafting / Non-"natural"
--
local
function
get_chest_formspec
(
pos
)
function
default
.
get_chest_formspec
(
pos
)
local
spos
=
pos
.
x
..
","
..
pos
.
y
..
","
..
pos
.
z
local
formspec
=
"size[8,9]"
..
...
...
@@ -1890,7 +1890,7 @@ function default.register_chest(name, d)
end
minetest
.
after
(
0
.
2
,
minetest
.
show_formspec
,
clicker
:
get_player_name
(),
"default:chest"
,
get_chest_formspec
(
pos
))
"default:chest"
,
default
.
get_chest_formspec
(
pos
))
open_chests
[
clicker
:
get_player_name
()]
=
{
pos
=
pos
,
sound
=
def
.
sound_close
,
swap
=
name
}
end
...
...
@@ -1912,7 +1912,7 @@ function default.register_chest(name, d)
minetest
.
show_formspec
(
player
:
get_player_name
(),
"default:chest_locked"
,
get_chest_formspec
(
pos
)
default
.
get_chest_formspec
(
pos
)
)
end
def
.
on_skeleton_key_use
=
function
(
pos
,
player
,
newsecret
)
...
...
@@ -1957,7 +1957,7 @@ function default.register_chest(name, d)
end
minetest
.
after
(
0
.
2
,
minetest
.
show_formspec
,
clicker
:
get_player_name
(),
"default:chest"
,
get_chest_formspec
(
pos
))
"default:chest"
,
default
.
get_chest_formspec
(
pos
))
open_chests
[
clicker
:
get_player_name
()]
=
{
pos
=
pos
,
sound
=
def
.
sound_close
,
swap
=
name
}
end
...
...
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