Skip to main content
Recent Posts
42
User Tools / Re: Percussion splitter
Last post by Flurmy -
Since I don't want to roll back my NWC installation and I'm almost sure I forgot to change some items :P , yukulele, could you please try this (beta) version? Thanks.

[edit: tool version officially released and attached to the first message]
45
User Tools / Re: Percussion splitter
Last post by Flurmy -
Quote
In the new beta, the |Text:*| property and User object properties are now stored as strings (replaces the nwcOptText object).

In the current general release, text properties use a nwcOptText class for storage. This is a heavy operation that requires an additional allocated table just to store the encoded string.
In this same release, user object properties are all stored as raw, encoded strings. This creates a complicated approach to handling the text properties.

In the new beta, all of these text properties are maintained as simple decoded strings. All simple strings are passed through an encoding filter before writing them back into a nwctxt file stream, which strives to make scripting changes to these properties much simpler.
It does create an issue for current tools.

As it currently stands, changes will be required in tool code when accessing these text properties. Perhaps the easiest way to handle this is by two utility functions:
Code: [Select · Download]
local function GetTextProp(item,lbl)
  local t = item.Opts[lbl]
  return (t and t.Text) and t.Text or t
end
Code: [Select · Download]
local function SetTextProp(item,lbl,txt)
  item:Provide(lbl,'')

  if item.Opts[lbl].Text then
    item.Opts[lbl].Text = txt
  else
    item.Opts[lbl] = txt
  end
end
47
User Tools / Re: Percussion splitter
Last post by Flurmy -
A-ha!
I seem to remember (quite surprising for me!  ;D ) that a small change about this was made in the lua libraries in NWC 2.8 Beta 1 (the one I'm using).
Which version of NWC are you using?
49
User Tools / Re: Percussion splitter
Last post by Flurmy -
But I don't know why the behaviour is different on my side.
So do I.

But:
  • In your snippet the staff name is "perc", in your dump is "perc." but, even after changing it, I found no difference in the result.
  • Using your dump routine I get:
    Code: [Select · Download]
    { 
       ["Name"] = perc.,
       ["Group"] = Standard,
    }

Quite different! Why?
50
User Tools / Re: Percussion splitter
Last post by yukulele -
After a few debug time I realize that `Item.Opts` have this structure for me:

Code: [Select · Download]
{
  ["Group"] = { ["Text"] = Standard, },
  ["LabelAbbr"] = "abbr",
  ["Label"] = { ["Text"] = label, },
  ["Name"] = { ["Text"] = perc, },
}

So I now use:
Code: (lua) [Select · Download]
local Name = Item.Opts.Name.Text or Item.Opts.Name
local PercStaffNumber = string.match(Name, PercStaffName.."(%d+)")

But I don't know why the behaviour is different on my side.

my debug code:
Spoiler (click to show/hide)