mirror of
https://github.com/minetest-mods/technic.git
synced 2025-07-04 09:10:38 +02:00
Get rid of deprecated metadata (#628)
The deprecated metadata gets converted to a proper ItemStackMetaRef. All keys stay the same except for: - Cans that use `can_level` now, since they didn't store a serialized table in the metadata before. - `charge` which is now `technic:charge`, since any item (also from other mods) may have a technic charge which can cause compatibility problems. Backwards compatibility is kept but going back to older `technic` versions might result in misbehaving circuits.
This commit is contained in:
@ -41,8 +41,9 @@ local function screwdriver_handler(itemstack, user, pointed_thing, mode)
|
||||
-- contrary to the default screwdriver, do not check for can_dig, to allow rotating machines with CLU's in them
|
||||
-- this is consistent with the previous sonic screwdriver
|
||||
|
||||
local meta1 = minetest.deserialize(itemstack:get_metadata())
|
||||
if not meta1 or not meta1.charge or meta1.charge < 100 then
|
||||
local meta = technic.get_stack_meta(itemstack)
|
||||
local charge = meta:get_int("technic:charge")
|
||||
if charge < 100 then
|
||||
return
|
||||
end
|
||||
|
||||
@ -64,9 +65,9 @@ local function screwdriver_handler(itemstack, user, pointed_thing, mode)
|
||||
minetest.swap_node(pos, node)
|
||||
|
||||
if not technic.creative_mode then
|
||||
meta1.charge = meta1.charge - 100
|
||||
itemstack:set_metadata(minetest.serialize(meta1))
|
||||
technic.set_RE_wear(itemstack, meta1.charge, sonic_screwdriver_max_charge)
|
||||
charge = charge - 100
|
||||
meta:set_int("technic:charge", charge)
|
||||
technic.set_RE_wear(itemstack, charge, sonic_screwdriver_max_charge)
|
||||
end
|
||||
|
||||
return itemstack
|
||||
|
Reference in New Issue
Block a user