From 36ad0d4132872e8517226a2101b0b3d2583d0935 Mon Sep 17 00:00:00 2001 From: white-haired-uncle Date: Sat, 25 May 2024 15:51:45 -0400 Subject: [PATCH] remove a lot from items stored on unit --- lua/items.lua | 17 ++++++++++------- lua/stats.lua | 11 +++++++---- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lua/items.lua b/lua/items.lua index 573cc9c0..016898ef 100644 --- a/lua/items.lua +++ b/lua/items.lua @@ -926,13 +926,16 @@ loti.item.describe_item = function(number, sort, set_items) elseif effect.set == "lawful" then line = "" .. _"Sets alignment to lawful" .. "" elseif effect.set == "neutral" then line = "" .. _"Sets alignment to neutral" .. "" end elseif effect.apply_to == "status" then - if effect.add == "unpoisonable" then line = "" .. _"Immune to Poison" .. "" - elseif effect.add == "unslowable" then line = "" .. _"Immune to Slow" .. "" - elseif effect.add == "undrainable" then line = "" .. _"Immune to Drain" .. "" - elseif effect.add == "unplaguable" then line = "" .. _"Immune to Plague" .. "" - elseif effect.add == "unpretrifiable" then line = "" .. _"Immune to Petrify" .. "" - elseif effect.add == "unhealable" then line = "" .. _"Unhealable" .. "" - elseif effect.add == "invulnerable" then line = "" .. _"Invulnerable" .. "" end + for part in string.gmatch(effect.add, '([^,]+)') do + if line then table.insert(desc, line) end + if part == "unpoisonable" then line = "" .. _"Immune to Poison" .. "" + elseif part == "unslowable" then line = "" .. _"Immune to Slow" .. "" + elseif part == "undrainable" then line = "" .. _"Immune to Drain" .. "" + elseif part == "unplaguable" then line = "" .. _"Immune to Plague" .. "" + elseif part == "unpretrifiable" then line = "" .. _"Immune to Petrify" .. "" + elseif part == "unhealable" then line = "" .. _"Unhealable" .. "" + elseif part == "invulnerable" then line = "" .. _"Invulnerable" .. "" end + end elseif effect.apply_to == "bonus_attack" then line = "" .. _"Bonus attack: " .. effect.description .. "" elseif effect.apply_to == "status" and effect.add == "not_living" then diff --git a/lua/stats.lua b/lua/stats.lua index 70478fa6..905c56ab 100644 --- a/lua/stats.lua +++ b/lua/stats.lua @@ -93,9 +93,12 @@ function wesnoth.update_stats(original) for i, item in ipairs(visible_modifications) do -- Update objects to reflect set effects and update items if item[1] == "object" and item[2].number and item[2].sort then visible_modifications[i][2] = loti.unit.item_with_set_effects(item[2].number, set_items, item[2].sort) - - -- Legacy field: used by WML menu "Items" to show "Remove item" options - visible_modifications[i][2].description = loti.item.describe_item(item[2].number, item[2].sort, set_items) + -- extract anything we won't NEED to save in the unit + for k,v in pairs(visible_modifications[i][2]) do + if type(v) ~= "table" and k ~= "name" and k ~= "number" and k ~= "sort" then + visible_modifications[i][2][k] = nil + end + end end end @@ -105,7 +108,6 @@ function wesnoth.update_stats(original) visible_modifications = wml.get_child(remade, "modifications") vars.updated = true vars.geared = geared - -- Remove temporary dummy attacks for i = #remade,1,-1 do if remade[i][1] == "attack" and remade[i][2].temporary == true then @@ -685,6 +687,7 @@ function wesnoth.update_stats(original) -- PART XI: Call WML hooks for i = 1,#events_to_fire do + --wesnoth.interface.add_chat_message(string.format("%d) %s",i,events_to_fire[i])) remade = call_event_on_unit(remade, events_to_fire[i]) end -- Restore unit from variable after the WML hooks.