Author Topic: LABEL discussion  (Read 5692 times)

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
LABEL discussion
« on: September 29, 2010, 04:13:12 PM »
LABEL is a new mod flag, designed for allowing people to write MOD_IS_INSTALLED without relying on hardcoded component numbers.

Example use:
Code: [Select]
BEGIN ~Component name~
LABEL ~something~
<...>
REQUIRE_PREDICATE (MOD_IS_INSTALLED ~test.tp2~ (ID_OF_LABEL ~test.tp2~ ~something~))
<...>
ACTION_IF (INSTALL_ORDER ~test.tp2~ (ID_OF_LABEL ~test.tp2~ ~something) AFTER ~test2.tp2~ 5) THEN BEGIN

ID_OF_LABEL returns the component number if found, or min_int (-2^30 on the standard win32 build of WeiDU) if the tp2 doesn't exist or no such LABEL exists; it fails if two components share a LABEL, or a component has two LABELs defined.

Also, this will parse the tp2 each time it is called - 100 calls on scsii's tp2 cost about 7 seconds on my machine. I could speed this up by adding caching if there's a need (or you can speed it up yourself by cutting your tp2's size by putting each component's code in INCLUDEd files).
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline DavidW

  • Planewalker
  • *****
  • Posts: 281
Re: LABEL discussion
« Reply #1 on: September 30, 2010, 02:22:43 AM »
Cool - and yes, this was very much what I had in mind.

From a conceptual point of view, I can't think of any reason why it would matter if a component has two LABELs defined, and I can think of some cases where it would be helpful. Is that a coding limitation, or a deliberate feature?

I think we can live with a 0.07 second slowdown per component (and most of SCSII's code is INCLUDEd anyway).

Presumably LABELs need to live in the main TP2 file - putting them in INCLUDEd code wouldn't work.

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: LABEL discussion
« Reply #2 on: September 30, 2010, 06:58:28 AM »
From a conceptual point of view, I can't think of any reason why it would matter if a component has two LABELs defined, and I can think of some cases where it would be helpful. Is that a coding limitation, or a deliberate feature?
It was easier to code that way (not that it'd be hard to allow multiple LABELs per component); however, I can't allow two components (in the same tp2) to share a LABEL (ID_OF_LABEL must return a single component number), so I can't see how a component with two LABELs would be helpful.
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline DavidW

  • Planewalker
  • *****
  • Posts: 281
Re: LABEL discussion
« Reply #3 on: September 30, 2010, 07:01:03 AM »
Yes, got it: you're right, of course.

Online Mike1072

  • Planewalker
  • *****
  • Posts: 296
  • Gender: Male
Re: LABEL discussion
« Reply #4 on: September 30, 2010, 07:03:03 AM »
From a conceptual point of view, I can't think of any reason why it would matter if a component has two LABELs defined, and I can think of some cases where it would be helpful. Is that a coding limitation, or a deliberate feature?
It was easier to code that way (not that it'd be hard to allow multiple LABELs per component); however, I can't allow two components (in the same tp2) to share a LABEL (ID_OF_LABEL must return a single component number), so I can't see how a component with two LABELs would be helpful.
What if two components are later merged into one?
« Last Edit: September 30, 2010, 07:09:29 AM by Mike1072 »

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: LABEL discussion
« Reply #5 on: September 30, 2010, 07:08:59 AM »
Good point, I'll allow multiple LABELs per component.
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1030
  • Gender: Male
Re: LABEL discussion
« Reply #6 on: September 30, 2010, 08:14:01 AM »
Can the label check default to its BEGIN string (in the first .tra file, if it's traed) if there's no LABEL defined? I'm sure someone will think of some arcane reason not to do that, but otherwise the feature would be rather useless for detecting older mods unless they're all recoded.

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: LABEL discussion
« Reply #7 on: September 30, 2010, 08:22:29 AM »
No. If the older mod is updated to use LABEL (or to reword the component name), future ID_OF_LABEL will stop working. Besides, an older, unsupported mod called Karea (or something like that) would block the install if used with ID_OF_LABEL because of the "components can't share a LABEL" rule - it has three or four components (in different SUBCOMPONENT groups) all named "Reduce to 50%".
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline DavidW

  • Planewalker
  • *****
  • Posts: 281
Re: LABEL discussion
« Reply #8 on: September 30, 2010, 10:08:40 AM »
I don't propose using this for older mods (which, if they're not being maintained, have static component numbers in any case)- it's more that it's useful going forward for complex mods like SCS.


Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: LABEL discussion
« Reply #9 on: September 30, 2010, 10:13:59 AM »
I don't propose using this for older mods (which, if they're not being maintained, have static component numbers in any case)- it's more that it's useful going forward for complex mods like SCS.
The older mod I was talking about is Miloch's Aurora, actually. Besides, other mods wouldn't work if LABEL_OF_ID was called on them and the component name was a valid LABEL (for ex. bg2tweaks and 'PnP table').
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: LABEL discussion
« Reply #10 on: September 30, 2010, 11:17:04 PM »
it fails if two components share a LABEL
What's the rationale for failing instead of returning the first component to match LABEL?

Offline DavidW

  • Planewalker
  • *****
  • Posts: 281
Re: LABEL discussion
« Reply #11 on: October 01, 2010, 03:30:01 AM »
it fails if two components share a LABEL
What's the rationale for failing instead of returning the first component to match LABEL?

I don't know what the actual motivation is, but it seems a good idea to me, simply because if you're repeating a LABEL, something has gone wrong, and this ought to be signposted rather than occurring silently. (I suppose putting up an INSTALLED_WITH_WARNINGS flag would also achieve that; conversely, I can't see any particular downside to just FAILing.)

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: LABEL discussion
« Reply #12 on: October 01, 2010, 04:44:41 AM »
LABEL will print a warning if there's another such LABEL in the TP2; ID_OF_LABEL will return min_int print a warning if there is no such LABEL in the tp2 or it is repeated (returns min_int without a warning if the tp2 is not found).
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: LABEL discussion
« Reply #13 on: October 01, 2010, 06:23:16 PM »
If I am reading this correctly, this is a more intricate way of doing

BEGIN ~mymodcomponent~

COPY ~swh101.itm~ ~override/small_flag_file_that_indicates_this_component_is_installed.g3~

BEGIN ~mynextmodcomponent
REQUIRE_FILE ~override/X#BG1NPCCore.G3~ @1004 /* BG1 NPC Required Changes component is not installed. */


etc.


Is there a good reason for folks to stop flagging the components and start using an internally defined label? The only one I can think of is if R_P and R_F only check override, and someone has biff'd the install. (I'm not criticising adding the functionality, only asking what makes it more powerful/interesting/useful than simply dropping a flag file for each component and checking for it like UB/BG1NPC used to do).

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1030
  • Gender: Male
Re: LABEL discussion
« Reply #14 on: October 01, 2010, 10:46:51 PM »
If I am reading this correctly, this is a more intricate way of doing

BEGIN ~mymodcomponent~

COPY ~swh101.itm~ ~override/small_flag_file_that_indicates_this_component_is_installed.g3~
It's probably a "less intricate" or at any rate less crufty way of doing it. See here for a background discussion, if you really want some bedtime reading material :D.

It is equivalent to using MOD_IS_INSTALLED [component#] but DavidW's issue was that mod component numbers (of active mods anyhow) can be subject to change, whereas labels might be less so. It isn't really necessary unless you're in that position. For example, bigg's comment about Aurora doesn't worry me much, because I don't really plan on rearranging the existing component numbers (any more). If I did, I would probably introduce LABELs. Likewise, Level 1 NPCs has about 100 components now, but I don't see the real value of LABELs for it for the same reason, unless someone wants to make a case for that.

[Edit: on the other hand, L1NPCs relies on a !(MOD_IS_INSTALLED ~setup-scs.tp2~ 3020) to make sure it doesn't mess with BG1 NPCs affected by SCS's analogous component. So I guess I would need to know the LABEL for that if DavidW intends on changing the component number (again). If not, I don't see the need to replace a bunch of existing syntax.]
« Last Edit: October 01, 2010, 10:59:48 PM by Miloch »

Offline DavidW

  • Planewalker
  • *****
  • Posts: 281
Re: LABEL discussion
« Reply #15 on: October 02, 2010, 05:23:15 AM »
[Edit: on the other hand, L1NPCs relies on a !(MOD_IS_INSTALLED ~setup-scs.tp2~ 3020) to make sure it doesn't mess with BG1 NPCs affected by SCS's analogous component. So I guess I would need to know the LABEL for that if DavidW intends on changing the component number (again). If not, I don't see the need to replace a bunch of existing syntax.]

Good case-study, actually. I'm not intending to change the component number, but I can't promise not to, and I can't really keep track of all the mods that might be relying on my fixed component numbers.

@Cmorgan: I don't strongly feel that it is better than component flag dropping (it's a bit more elegant and aesthetically pleasing). The idea came out of a discussion of why MOD_IS_INSTALLED couldn't substitute for marker files, and consideration of what would so substitute. I'm not especially planning to retrofit SCS to this just yet, though I'll certainly use it going forward.

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: LABEL discussion
« Reply #16 on: October 02, 2010, 07:26:22 AM »
I am going to continue dropping marker files in the override, BTW - the only people who dislike them are Miloch (and WeiDU 221 removes his objections) and Jarno (but he's a colossal moron, so nobody should consider anything he says).
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: LABEL discussion
« Reply #17 on: October 02, 2010, 05:18:18 PM »
Cool - I understand. With bg1npc I think I  am stuck with marker files " just in case" / backwards compatibility, this is something that certainly attracts me for stuff I might do.

Offline GeN1e

  • Planewalker
  • *****
  • Posts: 267
  • Gender: Male
Re: LABEL discussion
« Reply #18 on: October 09, 2010, 10:31:56 PM »
Is the point of LABEL to obliterate the need of markers, or only to allow for flexible MII substitute? Because if that's the former, then I'm unsure if you are fixing anything (I may be reading this thread wrong, though), since markers in reality serve a very definite purpose, completely different from MII.
That purpose being nothing else than to act as a global over-tp2 WeiDU variable, because you can't ~SET mod_x_is_here = 1~ and expect it to be read by the next WeiDU launch.
Detectable Spells is a good example, because it now is put into separate tph and dumps a marker to prevent the repeated clean-up of previous versions (Ascension, Kelsey). And obviously it can't check for MII, since it doesn't know which mod will use in future - for example, I'm incorporating it into RtW, and SCS/RR can't know that without an update.

What really would be helpful, is to have a way to store variables between mods, perhaps by extending WeiDU.log or dumping a new WeiDU.arg into the game directory, callable with every setup launch.

Code: [Select]
~setup-mod_1_name.tp2 #component_number1~
{
  SET ag#_was_hereX = 1
}
~setup-mod_1_name.tp2 #component_number2~
{
  SET ag#_was_hereY = 1
}
~setup-mod_2_name.tp2 #component_number1~
{
  SET ag#_was_hereX = 1
  SPRINT ag#_was_here_string ~~~~~using string for a mindf@cking crazy purpose I can't ~%possibly%~ imagine~~~~~
}
Using #component_number to allow for adequate per-mod variable deletion, in case the user opts to partially reinstall later.

Using OUTER|INNER_LABEL_SET|SPRINT may also serve as a normal SET|SPRINT, though I'm certain none would ever need this, since they don't check for their own markers within that component.
« Last Edit: October 09, 2010, 10:40:04 PM by GeN1e »

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: LABEL discussion
« Reply #19 on: October 10, 2010, 06:49:37 AM »
Is the point of LABEL to obliterate the need of markers, or only to allow for flexible MII substitute? Because if that's the former, then I'm unsure if you are fixing anything (I may be reading this thread wrong, though), since markers in reality serve a very definite purpose, completely different from MII.
Marker files still remain the most effective way to track this sort of thing (you can use FILE_EXISTS ~override/banter-accelerator.mrk~ rather than keeping track of all mods that contain a banter accelerator). LABEL and MOD_IS_INSTALLED are like a Toyota Prius: it's ugly, slow and less cost-effective than oil-operated cars, but snotty intellectuals feel superior by using it because it doesn't pollute the air override.
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline Gwendolyne_FP

  • Planewalker
  • *****
  • Posts: 48
Re: LABEL discussion
« Reply #20 on: June 03, 2019, 10:23:38 AM »
Would it be possible to get rid of the warning when two or more components use the same LABEL?

I am using them for Infinity Animations to specify which IA_content is installed to run each component. That way, modders won't have to check for existing bam files (with weird names) to know if their are installed or not, but rather use this kind of code:

Code: [Select]
ACTION_IF (MOD_IS_INSTALLED "infinityanimations.tp2" (ID_OF_LABEL "infinityanimations.tp2" "IA_content_01")) BEGIN

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1064
Re: LABEL discussion
« Reply #21 on: June 08, 2019, 11:23:56 AM »
Would it be possible to get rid of the warning when two or more components use the same LABEL?
No. Labels resolve into component numbers and therefore must be unique.

Offline Gwendolyne_FP

  • Planewalker
  • *****
  • Posts: 48
Re: LABEL discussion
« Reply #22 on: June 08, 2019, 11:27:49 AM »
In this case, I am afraid to find them redundant with component numbers, therefore useless.

Offline DavidW

  • Planewalker
  • *****
  • Posts: 281
Re: LABEL discussion
« Reply #23 on: June 09, 2019, 12:45:41 PM »
In this case, I am afraid to find them redundant with component numbers, therefore useless.

The point of LABEL was always to allow constant reference to a component even when its number changed, e.g. because of a change in the logical structure of the tp2.

Offline Gwendolyne_FP

  • Planewalker
  • *****
  • Posts: 48
Re: LABEL discussion
« Reply #24 on: June 09, 2019, 03:58:09 PM »
I understand, but how many mods use LABEL?

I wanted to use them to check if IA_contents were installed. As many components share the same content, it would have been a good way to identify them and avoid checking for all the components of using the IF_FILE_EXIST command.

It works fine but unfortunately displays warnings that may confuse players.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: