Differences From
Artifact [5131b0247b]:
- File
disassembly.lua
— part of check-in
[72eebac4bc]
at
2020-09-26 18:49:51
on branch trunk
— add writing stand for editing codexes; add scissors, ink, erasure fluid, pens; touch up codex UI; add many recipe notes; add craft divination type for crafttools; defuckulate fucktarded crafttool impl; enhance table library with missing features like lua's table.unpack; many bug fixes and enhancements; blood for the blood god
(user:
lexi,
size: 4258)
[annotate]
[blame]
[check-ins using]
43 43 tiles = {
44 44 'default_copper_block.png';
45 45 'default_wood.png';
46 46 'default_steel_block.png';
47 47 'default_stone.png';
48 48 'default_gold_block.png';
49 49 'default_coal_block.png';
50 + };
51 + _sorcery = {
52 + recipe = {
53 + note = 'Destroy a device or object to learn how it is crafted';
54 + };
50 55 };
51 56 after_dig_node = sorcery.lib.node.purge_container;
52 57 on_construct = function(pos)
53 58 local m = minetest.get_meta(pos)
54 59 local i = m:get_inventory()
55 60 i:set_size('item',1)
56 61 i:set_size('paper',1)
................................................................................
63 68 list[current_player;main;0.25,2;8,4]
64 69
65 70 list[context;item;0.25,0.5;1,1;]
66 71 list[context;paper;2.25,0.5;1,1;]
67 72 list[context;ink;4.25,0.5;3,1;]
68 73 list[context;output;9,0.5;1,1;]
69 74
70 - listring[current_player;main] listring[context;item]
75 + listring[context;output]
71 76 listring[current_player;main] listring[context;paper]
72 77 listring[current_player;main] listring[context;ink]
78 + listring[current_player;main] listring[context;item]
79 + listring[current_player;main]
73 80 ]])
74 81 end;
75 82 on_metadata_inventory_put = update_disassembler;
76 83 on_metadata_inventory_take = function(pos,list,idx,stack,user)
77 84 local m = minetest.get_meta(pos)
78 85 local i = m:get_inventory()
79 86 local paper = i:get_stack('paper',1)
80 87 local item = i:get_stack('item',1)
81 88
82 89 if list == 'output' then
83 90 local count = stack:get_count()
91 + local leftover = sorcery.data.infusion_leftovers[item:get_name()]
92 + local lstack if leftover then
93 + lstack = ItemStack(leftover)
94 + lstack:set_count(lstack:get_count() * count)
95 + -- this slightly idiosyncratic code is used to ensure that
96 + -- itemstrings can be used in the infusion leftovers table
97 + end
84 98 item:take_item(count)
85 - i:set_stack('item',1,item)
99 + if item:get_count() > 0 then
100 + if leftover then
101 + lstack = user:get_inventory():add_item(lstack)
102 + if lstack:get_count() > 0 then minetest.add_item(pos,lstack) end
103 + end
104 + i:set_stack('item',1,item)
105 + else
106 + if leftover then
107 + i:set_stack('item',1,lstack)
108 + else
109 + i:set_stack('item',1,ItemStack())
110 + end
111 + end
86 112 for j=1,i:get_size('ink') do
87 113 local ink = i:get_stack('ink',j)
88 114 ink:take_item(count)
89 115 i:set_stack('ink',j,ink)
90 116 end
91 117 end
92 118