Commit Graph

49 Commits

Author SHA1 Message Date
SmallJoker
9533200e25 Tidy and comment filtering functions 2022-10-05 21:07:11 +02:00
SmallJoker
14da1a3dd0 Fix reverse item lookup ("usage") broken by 5ac2558
> return { specname }

This returned a number-indexed table whereas the code expects a name-indexed table
2022-04-22 22:01:15 +02:00
James William Fletcher
5ac2558da4 Speed up group filtering code
This improves the startup time dramatically by lowering the algorithm complexity.
Mainly noticeable with large inventory sizes.

Written by Test_User, post-edited by SmallJoker
2022-02-26 11:03:21 +01:00
Oversword
8c84751ff8
Add u_i initialization and craft registration callbacks (#184)
Main purpose: custom recipe sorting provided by cuszom mods.
2021-10-14 18:38:07 +02:00
SmallJoker
4d4355a741 Home: Fix error on missing write permission 2021-05-13 15:19:46 +02:00
Vanessa Dannenberg
c044f5e3b0 use the trash slot icon's alpha instead of [combine
also it's supposed to be 128px, not 256px.  fixed that.
2021-03-10 21:20:31 -05:00
Vanessa Dannenberg
afb295ec22 fix trash slot list[] offset
(only noticable when listcolors[] allows slots to be visible,
i.e. on mouseover)
2021-03-10 12:26:28 -05:00
Vanessa Dannenberg
76c9bb9517 Use 9-slicing to build inventory-type backgrounds
This way the slots are all nice and crisp regardless of GUI scale or
image size, and we only need the single slot and its bright version.

This also makes the standard crafting grid into a style table entry that
can be referenced to insert the crafting grid at its proper
style-specific position in any formspec.

And it also makes the craft grid arrow, its X position, and the crafting
grid's result slot X position into style table entries.

Includes a few public helper functions to do most of the work:

`ui.single_slot(xpos, ypos, bright)`

    Does just what it sounds like: it returns a single slot image.
    `xpos` and `ypos` are normal coordinates in slots, as you'd use in
    `image[]` element.  `bright` is a flag that switches to the brighter
    version of the slot image.

`ui.make_trash_slot(xpos, ypos)`

    Creates a single slot, with a one-item `list[]` and a trash can icon
    overlay.

`ui.make_inv_img_grid(xpos, ypos, width, height, bright)`

    Generates a `width` by `height` grid of slot images, using the
    single_slot function above, starting at (`xpos`,`ypos`) for the
    top-left.  Position is as in any `image[]` element, and dimensions
    are in integer numbers of slots (so 8,4 would be a standard inventory).
    `bright` is as above.

All three return a string that can be directly inserted into a formspec.
2021-03-09 15:04:11 -05:00
Vanessa Dannenberg
694553e68b use local "ui" to reference "unified_inventory", where practical
(makes code shorter, easier to read and write)
2021-03-09 15:04:11 -05:00
Maksim
f25426911d
Fix teleport sounds when teleport fails (#155) 2020-07-10 21:58:45 +02:00
David Leal
606ba6a1a3
Add GitHub workflow (#149) 2020-03-25 18:46:35 +01:00
Andrey Kozlovskiy
ca6d9a10df Implement new crafting algorithm (#132)
* Implement new crafting algorithm

* Take craft width into account when creating craft index
* Fix moving logic, correctly check for empty stacks
* Return early when there's not enough items for craft
* Bound match_count with smallest stack_max value, take from inventory only if needed
* Continue if item can't be moved to the current position.
* Fix metadata loss and. Improve placement for some corner cases.
* Drop items from oversized stacks on the ground
* Place items exactly as displayed in the guide
* One source list one destination. Try to take from destination list first
2019-10-26 17:22:33 +02:00
Wuzzy
5327261718 Move to MT 5.0.0 translation system 2019-10-17 21:05:08 +02:00
Panquesito7
4403b696be Replace deprecated functions with newer ones (#131)
These commits makes more compatibility with MT/MTG 5.0.0+ versions.
However, these commits breaks compatibility with the 0.4-series.
2019-06-16 10:26:40 +02:00
codexp
3988f4c572 Merge origin/master to refactor-translation branch (resolving conflicts) 2018-06-23 15:37:13 +02:00
SmallJoker
edd00f222c Replace deprecated function names, unify creative check 2018-06-23 15:02:23 +02:00
codexp
c1ab7277ab refactor code to use with intllib tool 2018-04-02 13:33:36 +02:00
Wuzzy
3209033051 Replace exclude_from_craft_guide with not_in_craft_guide 2017-02-06 15:17:53 +01:00
Foz
020732a954 Fix bug in usages. Closes #82 2016-11-18 16:34:40 -10:00
Diego Martínez
5b9a53bf29 Fail gracefully for invalid drop tables.
Notified by user `photon` on IRC.
2016-10-08 00:54:05 -03:00
Vanessa Ezekowitz
32769c9f34 Merge pull request #65 from Wuzzy2/digging_chance
Add partial support for complex (table-based) node drops
2016-08-07 12:57:39 -04:00
Wuzzy
af56ddf06b Consider max_items in complex drop analysis 2016-08-07 05:44:36 +02:00
Wuzzy
1c5fcd18ca Properly seperate chance digs from normal digs 2016-08-07 04:47:15 +02:00
Wuzzy
80f99cffe7 Take count into account for complex node drops 2016-08-07 04:38:08 +02:00
Wuzzy
09c731cee0 Reduce redundancy in chance-based drops 2016-08-07 04:21:02 +02:00
Wuzzy
08d8d99ab3 Add crafting type: digging by chance 2016-08-07 03:49:16 +02:00
Wuzzy
c816666945 Ensure formspec escaping for translated strings 2016-08-06 17:23:46 +02:00
Wuzzy
8f14d41706 Collect more missing strings for translation 2016-08-06 16:25:01 +02:00
Pedro Gimeno
f23b4aed65 Allow items to exclude their recipes from the recipes list
Certain mods add many recipes that take smaller blocks and output a bigger block. This clutters the recipes list. Case in point: the circular saw from the moreblocks mod.

This patch allows mods to tell the craft guide to not include recipes that contain certain items, by setting the group exclude_from_craft_guide = 1 in the items.
2016-03-31 03:11:32 +02:00
HybridDog
babe4380ac disallow repairing tools using the 'to craft grid', allow it to put items of specific groups and (maybe) make it keep the meta of items, remove unused elseif, change a bit translation and use table.concat at one place because I read somewhere that it's faster than .. 2015-08-16 16:40:49 +02:00
Vanessa Ezekowitz
56892b8e75 Don't add a recipe to the main list if it contains any unknown items/groups 2015-07-30 08:03:29 -04:00
ShadowNinja
7d8b5f3760 Round home positions 2015-04-18 15:23:54 -04:00
Rogier
2fd9e59242 Display conversion method symbolically and textually next to arrow 2015-03-11 16:00:37 +01:00
Tim
76a9efff71 reduce table lookups during initialization 2015-02-05 10:03:07 +01:00
Tim
1a1bfc3839 supress intllib check warning, this fixes #19 2015-02-05 10:00:10 +01:00
RealBadAngel
002bcbb6d8 Add intllib support.
Some polish and german translations.
Start adding tooltips.
2014-06-21 12:44:31 +02:00
Zefram
87f502a259 Show item usages in craft guide
When the craft guide is showing a craft, the output slot is now a button,
which causes the craft guide to show ways in which that output can be
used.  This mirrors the way input slots are buttons that show recipes
for the selected ingredient.  Usages of an item can be iterated through
in the same way as recipes for the item.  This incidentally offers some
ability to retrace one's steps through a crafting chain, without storing
actual history.
2014-06-13 11:30:09 -03:00
Zefram
4c982dd667 Fix and enhance grid shapes in craft guide
Commit 043f608145 made shaped crafting
recipes display in a grid of the recipe's minimum bounding box,
but broke the use of a fixed 1x1 grid shape for cooking recipes.
This commit generalises the dynamic-grid-shape facility, putting the
craft type registration in charge.  This restores the correct shape for
cooking recipes.

Also change the logic for dynamic grid sizes for regular shaped and
shapeless crafting.  We'd like to always use a grid shape that is
reminiscent of a regular crafting grid, as a visual cue to the crafting
method.  But it's also nice to show smaller recipes in a smaller grid.
In the expectation that crafting grids will always be square, show the
recipe in the smallest square grid that will accommodate it.
2014-06-13 09:28:39 -03:00
ShadowNinja
043f608145 Move around some group code and make the craftguide render well without a recipe
This also keeps recipes aligned to the right, close to the arrow.
It also calculates the craft's height.
2014-05-11 22:00:32 -04:00
Zefram
b492701915 Show group ingredients visually in craft guide
Where a recipe specifies an ingredient by group, show a typical group
item pictorially, with a label flag to indicate that it's a group rather
than the single item.  This is the inverse of the previous arrangement,
which identified the group by label and dipicted groupiness pictorially.
The new arrangement is easier to interpret, and if the labels are ignored
it actually shows a correct input to the crafting grid.
2014-05-02 12:19:17 +02:00
Zefram
580a832fda Use appropriate grid shape for each craft type
New system of registration of craft types, recording for each a display
description and the appropriate grid shape.  Recipes of a registered type
are shown in the correct grid.  Recipes of unregistered craft types are
still displayed as before, using the default 3x3 grid.
2014-04-30 00:11:10 +01:00
Zefram
48d28b1e5d Show non-identity digging results in craft guide 2014-04-29 22:14:08 +01:00
Zefram
87cfad559b Don't overwrite registered crafts
The crafts_table was being initialised to contain only core-registered
crafts, but this would overwrite any non-core craft types that had
already been registered via unified_inventory.register_craft().  This was
especially likely because the crafts_table initialisation runs on a delay,
following all normal initialisation.  Instead, feed the core-registered
crafts into unified_inventory.register_craft().
2014-04-29 21:38:31 +01:00
Zefram
fa0142c2c0 Look for recipes under an item's aliases
get_all_craft_recipes() returns the recipes that were registered under the
specified name, so asking about an item's canonical name won't see recipes
registered under an alias, and vice versa.  Several mods register recipes
under aliases, so the craft guide was missing that handful of recipes.
To work around it, invert the aliases table and ask explicitly about
each alias.
2014-04-22 16:52:04 -04:00
ShadowNinja
34fe44356d Remove unnecessary recipe table copying 2014-01-19 14:00:49 -05:00
ShadowNinja
26473a8346 Remove trailing whitespace 2014-01-19 13:27:52 -05:00
RealBadAngel
e44deedc53 Fix the bug clearing other than default crafting methods. 2013-10-07 04:16:31 +02:00
ShadowNinja
f974fd8c2c Update 2013-09-28 18:15:37 -04:00
RealBadAngel
e3d391d63f Update mod 2013-09-21 21:40:20 +02:00