Differences From
Artifact [cf9865540e]:
494 494 end
495 495 end
496 496
497 497 -- handle editing request
498 498 local rpp = sorcery.cookbook.constants.recipes_per_cookbook_page
499 499 if p.mode then for idx=1,rpp do
500 500 if fields['recipe_' .. tostring(idx)] then
501 - local recnr = (bm:get_int('pagenr')-1)*rpp + idx
501 + local pg = math.max(1, bm:get_int 'pagenr') -- handle unset page
502 + local recnr = (pg-1)*rpp + idx
502 503 local rec = book.pages[recnr]
503 504 local bookchanged = false
504 505 if p.mode == 'delete' then
505 506 p.operstack:take_item(1)
506 507 table.remove(book.pages,recnr)
507 508 bookchanged = true
508 509 elseif p.mode == 'copy' and
................................................................................
526 527 name = rm:get_string('recipe_name');
527 528 })
528 529 -- insertion can operate in one of two modes: copying
529 530 -- the recipe into the book, or inserting the paper
530 531 -- directly. if there is no ink available, we use the
531 532 -- latter mode. in effect, this means deleting the
532 533 -- recipe item is insufficient ink is available.
533 - if charge_ink(constants.op_cost_insert_rec) == false then
534 + if (not p.has_pen) or charge_ink(constants.op_cost_insert_rec) == false then
534 535 p.operstack = ItemStack(nil)
535 536 end
536 537 bookchanged = true
537 538 elseif p.mode == 'cut' then
538 539 local spr = p.operstack:get_definition()._sorcery
539 540 local sch = (spr and spr.material and spr.material.data.hardness) or 2
540 541 local suses = sch * constants.cuts_per_scissor_hardness