Advertisement
Vultraz

Untitled

Jun 19th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1.     local function sync_weapons_to_items()
  2.         for attack in wml.child_range(unit.__cfg, 'attack') do
  3.             if not invalid_attacks[attack.name] and not wml.get_child(inv_list_data, "item", attack.name) then
  4.                 local descrip = string.format("%s - %s %s", attack.damage, attack.number, attack.type)
  5.  
  6.                 table.insert(inv_list_data, {"item", {
  7.                     id = attack.name,
  8.                     name = first_to_upper(attack.description), -- [attack] doesn't have dedicated id keys, and the description is more like a name anyway
  9.                     image = attack.icon or string.format("attacks/%s.png", attack.name),
  10.                     description = descrip,
  11.                     effect_type = "equip",
  12.                     active = true,
  13.                     quantity = 1,
  14.                     T.command {
  15.                         T.modify_unit {
  16.                             T.filter { x = "$x1", y = "$y1" },
  17.                             { 'effect', lp8.copyTable(attack, { apply_to = 'new_attack' }) }
  18.                         }
  19.                     },
  20.                     T.removal_command {
  21.                         T.modify_unit {
  22.                             T.filter { x = "$x1", y = "$y1" },
  23.                             T.effect { apply_to = "remove_attacks", range = attack.range, name = attack.name }
  24.                         }
  25.                     }
  26.                 } })
  27.             end
  28.         end
  29.  
  30.         --wesnoth.put_unit(unit)
  31.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement