Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xdecor
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
xdecor
Commits
02e86e7c
Commit
02e86e7c
authored
9 years ago
by
jp
Browse files
Options
Downloads
Patches
Plain Diff
Craft guide : add support for alternative recipes
parent
e03937e0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
enchanting.lua
+0
-1
0 additions, 1 deletion
enchanting.lua
textures/xdecor_cauldron_top_empty.png
+0
-0
0 additions, 0 deletions
textures/xdecor_cauldron_top_empty.png
worktable.lua
+66
-20
66 additions, 20 deletions
worktable.lua
with
66 additions
and
21 deletions
enchanting.lua
+
0
−
1
View file @
02e86e7c
...
...
@@ -82,7 +82,6 @@ local function allowed(tool)
if
t
then
return
true
end
end
end
return
false
end
...
...
This diff is collapsed.
Click to expand it.
textures/xdecor_cauldron_top_empty.png
+
0
−
0
View replaced file @
e03937e0
View file @
02e86e7c
271 B
|
W:
|
H:
291 B
|
W:
|
H:
2-up
Swipe
Onion skin
This diff is collapsed.
Click to expand it.
worktable.lua
+
66
−
20
View file @
02e86e7c
...
...
@@ -39,8 +39,9 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname)
local
inv
=
meta
:
get_inventory
()
pagenum
=
math.floor
(
pagenum
)
local
inventory_size
=
meta
:
get_int
(
"inventory_size"
)
local
recipe_num
=
meta
:
get_int
(
"recipe_num"
)
local
pagemax
=
math.floor
((
inventory_size
-
1
)
/
(
8
*
4
)
+
1
)
or
0
local
craft
,
dye_color
=
{},
""
local
craft
,
dye_color
,
flower_color
=
{},
""
,
""
local
formspec
=
"size[8,8;]"
..
xbg
..
"list[context;inv_items_list;0,1;8,4;"
..
tostring
(
start_i
)
..
"]"
..
...
...
@@ -59,18 +60,27 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname)
"field[1.8,0.32;2.6,1;filter;;]"
if
stackname
then
local
stack_width
=
minetest
.
get_craft_recipe
(
stackname
)
.
width
local
stack_items
=
minetest
.
get_craft_recipe
(
stackname
)
.
items
local
stack_type
=
minetest
.
get_craft_recipe
(
stackname
)
.
type
local
stack_output
=
minetest
.
get_craft_recipe
(
stackname
)
.
output
local
stack_width
=
minetest
.
get_
all_
craft_recipe
s
(
stackname
)
[
recipe_num
][
"
width
"
]
local
stack_items
=
minetest
.
get_
all_
craft_recipe
s
(
stackname
)
[
recipe_num
][
"
items
"
]
local
stack_type
=
minetest
.
get_
all_
craft_recipe
s
(
stackname
)
[
recipe_num
][
"
type
"
]
local
stack_output
=
minetest
.
get_
all_
craft_recipe
s
(
stackname
)
[
recipe_num
][
"
output
"
]
local
stack_count
=
stack_output
:
match
(
"%s(%d+)"
)
if
stack_count
and
inv
:
is_empty
(
"item_craft_input"
)
then
inv
:
add_item
(
"item_craft_input"
,
stackname
..
" "
..
stack_count
-
1
)
if
#
minetest
.
get_all_craft_recipes
(
stackname
)
>
1
then
formspec
=
formspec
..
"button[1.2,5.5;1.6,1;alternate;Alternate]"
end
if
stack_count
then
inv
:
set_stack
(
"item_craft_input"
,
1
,
stackname
..
" "
..
stack_count
)
else
inv
:
set_stack
(
"item_craft_input"
,
1
,
stackname
)
end
if
stack_width
==
0
then
if
#
stack_items
<=
4
then
if
#
stack_items
<=
2
then
formspec
=
formspec
..
"list[context;craft_output_recipe;5,6.3;2,1;]"
inv
:
set_size
(
"craft_output_recipe"
,
2
)
elseif
#
stack_items
>
2
and
#
stack_items
<=
4
then
formspec
=
formspec
..
"list[context;craft_output_recipe;5,5.3;2,2;]"
inv
:
set_size
(
"craft_output_recipe"
,
2
*
2
)
else
...
...
@@ -85,8 +95,16 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname)
end
inv
:
set_size
(
"craft_output_recipe"
,
1
*
#
stack_items
)
elseif
stack_width
==
2
then
formspec
=
formspec
..
"list[context;craft_output_recipe;5,5.3;2,3;]"
inv
:
set_size
(
"craft_output_recipe"
,
2
*
3
)
if
#
stack_items
<=
2
then
formspec
=
formspec
..
"list[context;craft_output_recipe;5,6.3;2,1;]"
inv
:
set_size
(
"craft_output_recipe"
,
2
)
elseif
#
stack_items
>
2
and
#
stack_items
<=
4
then
formspec
=
formspec
..
"list[context;craft_output_recipe;5,5.3;2,2;]"
inv
:
set_size
(
"craft_output_recipe"
,
2
*
2
)
else
formspec
=
formspec
..
"list[context;craft_output_recipe;5,5.3;2,3;]"
inv
:
set_size
(
"craft_output_recipe"
,
2
*
3
)
end
elseif
stack_width
==
3
then
if
stack_type
==
"cooking"
then
formspec
=
formspec
..
"list[context;craft_output_recipe;5,6.3;1,1;]"
..
...
...
@@ -114,6 +132,21 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname)
elseif
def
:
find
(
"group:dye"
)
then
dye_color
=
def
:
match
(
"group:dye,%w+_([%w_]+)"
)
def
=
"dye:"
..
dye_color
elseif
def
:
find
(
"group:flower"
)
then
flower_color
=
def
:
match
(
"group:flower,%w+_([%w_]+)"
)
if
flower_color
==
"red"
then
def
=
"flowers:rose"
elseif
flower_color
==
"yellow"
then
def
=
"flowers:dandelion_yellow"
elseif
flower_color
==
"white"
then
def
=
"flowers:dandelion_white"
elseif
flower_color
==
"blue"
then
def
=
"flowers:geranium"
elseif
flower_color
==
"orange"
then
def
=
"flowers:tulip"
else
def
=
"flowers:rose"
end
elseif
def
:
match
(
"group:stone"
)
or
def
:
match
(
"group:wood"
)
or
def
:
match
(
"group:leaves"
)
or
def
:
match
(
"group:stick"
)
or
def
:
match
(
"group:sand"
)
or
def
:
match
(
"group:tree"
)
or
...
...
@@ -126,7 +159,7 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname)
end
formspec
=
formspec
..
"image[4,6.3;1,1;gui_furnace_arrow_bg.png^[transformR90]"
..
"button[1.2,6.35;1.
5
,1;trash;Clear]"
..
"button[1.2,6.35;1.
6
,1;trash;Clear]"
..
"label["
..
(
12
/
string.len
(
stackname
))
..
",7.5;"
..
stackname
:
sub
(
1
,
30
)
..
"]"
end
...
...
@@ -164,7 +197,7 @@ function worktable.crafting(pos)
"list[current_player;main;0,3.3;8,4;]"
..
"image[5,1;1,1;gui_furnace_arrow_bg.png^[transformR270]"
..
"button[0,0;1.5,1;back;< Back]"
..
"button[0,1;1.5,1;craft
_output_recip
e;Guide]"
..
"button[0,1;1.5,1;craft
guid
e;Guide]"
..
"list[current_player;craft;2,0;3,3;]"
..
"list[current_player;craftpreview;6,1;1,1;]"
..
"listring[current_player;main]"
..
...
...
@@ -220,7 +253,8 @@ function worktable.construct(pos)
inv
:
set_size
(
"hammer"
,
1
)
inv
:
set_size
(
"storage"
,
8
*
2
)
inv
:
set_size
(
"item_craft_input"
,
1
)
meta
:
set_int
(
"recipe_num"
,
1
)
meta
:
set_int
(
"start_i"
,
0
)
meta
:
set_string
(
"infotext"
,
"Work Table"
)
worktable
.
main
(
pos
)
...
...
@@ -232,6 +266,7 @@ function worktable.fields(pos, _, fields, sender)
local
inv
=
meta
:
get_inventory
()
local
start_i
=
meta
:
get_int
(
"start_i"
)
local
inventory_size
=
meta
:
get_int
(
"inventory_size"
)
local
inputstack
=
inv
:
get_stack
(
"item_craft_input"
,
1
):
get_name
()
start_i
=
tonumber
(
start_i
)
or
0
if
fields
.
storage
then
...
...
@@ -239,9 +274,22 @@ function worktable.fields(pos, _, fields, sender)
elseif
fields
.
back
then
worktable
.
main
(
pos
)
elseif
fields
.
backcraft
or
fields
.
craft
then
if
fields
.
backcraft
then
meta
:
set_int
(
"recipe_num"
,
1
)
inv
:
set_list
(
"item_craft_input"
,
{})
inv
:
set_list
(
"craft_output_recipe"
,
{})
end
worktable
.
crafting
(
pos
)
elseif
fields
.
craft_output_recipe
then
worktable
.
craft_output_recipe
(
pos
,
0
,
1
)
elseif
fields
.
craftguide
then
worktable
.
craft_output_recipe
(
pos
,
0
,
1
,
nil
)
elseif
fields
.
alternate
then
inv
:
set_list
(
"craft_output_recipe"
,
{})
if
meta
:
get_int
(
"recipe_num"
)
>=
#
minetest
.
get_all_craft_recipes
(
inputstack
)
then
meta
:
set_int
(
"recipe_num"
,
1
)
else
meta
:
set_int
(
"recipe_num"
,
meta
:
get_int
(
"recipe_num"
)
+
1
)
end
worktable
.
craft_output_recipe
(
pos
,
start_i
,
start_i
/
(
8
*
4
)
+
1
,
inputstack
)
elseif
fields
.
trash
or
fields
.
search
or
fields
.
clearfilter
or
fields
.
prev
or
fields
.
next
then
if
fields
.
trash
then
...
...
@@ -265,6 +313,7 @@ function worktable.fields(pos, _, fields, sender)
worktable
.
craft_output_recipe
(
pos
,
start_i
,
start_i
/
(
8
*
4
)
+
1
,
nil
)
end
meta
:
set_int
(
"recipe_num"
,
1
)
inv
:
set_list
(
"item_craft_input"
,
{})
inv
:
set_list
(
"craft_output_recipe"
,
{})
end
...
...
@@ -284,7 +333,6 @@ function worktable.contains(table, element)
end
end
end
return
false
end
...
...
@@ -338,14 +386,12 @@ function worktable.move(pos, from_list, from_index, to_list, to_index, count, _)
return
count
elseif
inv
:
is_empty
(
"item_craft_input"
)
and
from_list
==
"inv_items_list"
and
to_list
==
"item_craft_input"
then
--print(dump(minetest.get_craft_recipe(stackname)))
--print(dump(minetest.get_
all_
craft_recipe
s
(stackname)))
worktable
.
craft_output_recipe
(
pos
,
start_i
,
start_i
/
(
8
*
4
)
+
1
,
stackname
)
minetest
.
after
(
0
,
function
()
inv
:
set_stack
(
from_list
,
from_index
,
stackname
)
end
)
return
1
end
return
0
...
...
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