Overview
| Comment: | add tool wear to lathe, add page turning sounds for cookbooks |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
0dbb4f52c3ee72f790af685a0bc1d4d3 |
| User & Date: | lexi on 2021-07-08 01:08:09 |
| Other Links: | manifest | tags |
Context
|
2021-07-08
| ||
| 11:25 | lathe is a mess but whatever i dont care it works now check-in: 77b901d950 user: lexi tags: trunk | |
| 01:08 | add tool wear to lathe, add page turning sounds for cookbooks check-in: 0dbb4f52c3 user: lexi tags: trunk | |
|
2021-07-07
| ||
| 23:40 | add lathe, bug fixes, new sounds check-in: 200ec592d5 user: lexi tags: trunk | |
Changes
Modified cookbook.lua from [4b9992727f] to [1bf06d7139].
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 |
local stack = uinv:get_stack('main', idx)
local book = bookprops(stack)
local meta = stack:get_meta()
local curpage = meta:contains("pagenr") and meta:get_int("pagenr") or 1
local pagect = math.ceil(#book.pages / constants.recipes_per_cookbook_page)
if curpage > 1 and fields.pageback then
meta:set_int('pagenr', curpage - 1)
elseif curpage < pagect and fields.pagenext then
meta:set_int('pagenr', curpage + 1)
end
uinv:set_stack('main',idx,stack)
bookform(stack,user)
end)
minetest.register_on_craft(function(stack,player,grid,inv)
|
> | | | | > > |
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 |
local stack = uinv:get_stack('main', idx)
local book = bookprops(stack)
local meta = stack:get_meta()
local curpage = meta:contains("pagenr") and meta:get_int("pagenr") or 1
local pagect = math.ceil(#book.pages / constants.recipes_per_cookbook_page)
if fields.pageback or fields.pagenext then
if curpage > 1 and fields.pageback then
meta:set_int('pagenr', curpage - 1)
elseif curpage < pagect and fields.pagenext then
meta:set_int('pagenr', curpage + 1)
end
minetest.sound_play('sorcery_pgturn', { pos = pos, gain = 0.6 })
end
uinv:set_stack('main',idx,stack)
bookform(stack,user)
end)
minetest.register_on_craft(function(stack,player,grid,inv)
|
Modified itemclass.lua from [5df312f3fb] to [2e8a1de5b1].
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
-- gem/crystalline and metal/metallic differentiate
-- between crafting materials (i.e. gems or ingots
-- themselves) and items crafted from those materials.
-- the former includes only crafting materials, the
-- latter includes both.
gem = {
compat = 'gems';
groups = { 'gem', 'crystal'; };
predicate = function(name)
if minetest.get_item_group(name, 'sorcery_gem') ~= 0
or minetest.get_item_group(name, 'sorcery_shard') ~= 0 then
return minetest.registered_items[name]._sorcery.material;
end
end;
|
> |
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
-- gem/crystalline and metal/metallic differentiate
-- between crafting materials (i.e. gems or ingots
-- themselves) and items crafted from those materials.
-- the former includes only crafting materials, the
-- latter includes both.
gem = {
compat = 'gems';
finagle = function(g) return {data = sorcery.data.gems[g.id]} end;
groups = { 'gem', 'crystal'; };
predicate = function(name)
if minetest.get_item_group(name, 'sorcery_gem') ~= 0
or minetest.get_item_group(name, 'sorcery_shard') ~= 0 then
return minetest.registered_items[name]._sorcery.material;
end
end;
|
Modified lathe.lua from [f0ca6bd16e] to [5af73c1767].
54
55
56
57
58
59
60
61
62
63
64
65
66
67
...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
if not inv:is_empty('preview') then
for i=1, inv:get_size('preview') do
inv:set_stack('preview',i,ItemStack())
end
end
return
end
local tech = sorcery.lathe.tooltech(tool)
local rec = R[wkpc:get_name()][tech]
tech = sorcery.lathe.techs[tech]
-- fill in the preview slots
local j = 1
................................................................................
else return 0 end
else return stack:get_count() end
end;
on_metadata_inventory_put = sorcery.lathe.update;
on_metadata_inventory_take = function(pos, list, idx, stack, user)
if list == 'preview' then
local l = sorcery.lathe.get(pos,idx,stack:get_count())
if sorcery.lathe.techs[l.tech].consume then
l.tool:take_item(l.cost)
elseif sorcery.lathe.techs[l.tech].dmg then
--TODO wear down tool
end
l.wkpc:take_item(l.qty)
l.inv:set_stack('tool', 1, l.tool)
l.inv:set_stack('workpiece', 1, l.wkpc)
minetest.sound_play('sorcery_clank', { pos = pos, gain = 0.9 })
end
sorcery.lathe.update(pos)
|
>
>
>
>
>
>
>
<
|
>
>
>
>
>
>
>
>
>
>
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
...
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
if not inv:is_empty('preview') then
for i=1, inv:get_size('preview') do
inv:set_stack('preview',i,ItemStack())
end
end
return
end
local tmat = sorcery.itemclass.get(tool:get_name(),'material')
local wmat = sorcery.itemclass.get(wkpc:get_name(),'material')
-- obey level restrictions. TODO honor Rend
if (wmat and wmat.data.level or 0) > (tmat and (tmat.data.maxlevel or tmat.data.level) or 0) then
return
end
local tech = sorcery.lathe.tooltech(tool)
local rec = R[wkpc:get_name()][tech]
tech = sorcery.lathe.techs[tech]
-- fill in the preview slots
local j = 1
................................................................................
else return 0 end
else return stack:get_count() end
end;
on_metadata_inventory_put = sorcery.lathe.update;
on_metadata_inventory_take = function(pos, list, idx, stack, user)
if list == 'preview' then
local l = sorcery.lathe.get(pos,idx,stack:get_count())
if sorcery.lathe.techs[l.tech].consume then
l.tool:take_item(l.cost)
elseif sorcery.lathe.techs[l.tech].dmg then
local mat = sorcery.itemclass.get(l.tool,'material')
local mmat = sorcery.itemclass.get(l.wkpc,'metal')
local dur = 100
local lfac = 1
if mat then
local dur = mat.data.durability or dur
lfac = (mmat and mmat.data.level or 1) /
(mat.data.maxlevel or mat.data.level or 1)
end
local ch = 65535 / dur
l.tool:add_wear(4 * ch * l.cost * lfac)
end
l.wkpc:take_item(l.qty)
l.inv:set_stack('tool', 1, l.tool)
l.inv:set_stack('workpiece', 1, l.wkpc)
minetest.sound_play('sorcery_clank', { pos = pos, gain = 0.9 })
end
sorcery.lathe.update(pos)
|
Modified writing.lua from [57199bc1f0] to [cf9865540e].
477 478 479 480 481 482 483 484 485 486 487 488 489 490 |
-- handle page change request
if fields.nextpage or fields.prevpage then
local page = math.max(1,bm:get_int('pagenr'))
if fields.nextpage then page = page + 1
elseif fields.prevpage then page = page - 1 end
bm:set_int('pagenr',math.max(1,page))
changed = true
end
-- handle retitle request
if fields.title then
if fields.title ~= bm:get_string('description') then
if charge_ink(constants.op_cost_retitle) then
|
> |
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
-- handle page change request
if fields.nextpage or fields.prevpage then
local page = math.max(1,bm:get_int('pagenr'))
if fields.nextpage then page = page + 1
elseif fields.prevpage then page = page - 1 end
bm:set_int('pagenr',math.max(1,page))
minetest.sound_play('sorcery_pgturn', { pos = pos, gain = 0.6 })
changed = true
end
-- handle retitle request
if fields.title then
if fields.title ~= bm:get_string('description') then
if charge_ink(constants.op_cost_retitle) then
|