Talk:Checking if a Mod is affecting an Object

From the Fallout3 GECK Wiki
Revision as of 18:29, 17 January 2009 by imported>Cipscis (→‎Concern: About the result script)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Concern[edit source]

If more than one mod does this, it will probably still work for the overwritten mod and therefore ruin the test. Oblivion, at least, did not look up variables by name, but by index, so even if the two different mods have two different scripts with two differently named variables, if they both have a single short variable that is set to 1, then both mods will see it as set to 1. Therefore, this only works if no one else is using it, I think. This would need testing though because things may have changed between Oblivion and Fallout.

A better idea might be to use a Ref variable, and then set it to a reference specifically from your mod. It would be impossible for another mod to set the ref the same way.
DragoonWraith · talk · 16:54, 26 December 2008 (UTC)

Thanks DragoonWraith, I didn't realise that might be the case. I'll test it out today and see if this is the case, but I think you're probably right based on what the GECK says when I select the variable for the condition (it talks about its index). I suppose that because persistent references that are created in the plugin are used in this case, setting a ref variable to GetSelf/This should be sufficient.
-- Cipscis 23:45, 26 December 2008 (UTC)
I don't think GetSelf will work - GetSelf as a reference will always be from your mod. If everyone scripts the script to use GetSelf, then the script will still be checking your reference, and therefore your condition will remain true. Remember, the variable is separate for each reference, so when you check yourRef.var == yourRef, you'll definitely get true because yourRef.var is set to GetSelf.
Instead, you could hard-code it to set the reference to your persistant reference. If another person does the same, the script will change and the ref will read their reference. Then you know your changes haven't taken effect.
All in all, however, it seems to make more sense to simply check the various values on the item to see if they match what you want them to match (especially if it would be acceptable for another mod to change other values on the form). FOSE should have item-statistics checking functions very soon.
DragoonWraith · talk · 05:15, 27 December 2008 (UTC)
Yeah, I realised the problem with using GetSelf a couple of minutes after I wrote that... I tried using GetScriptVariable to point to a specific reference, but it won't accept alphanumeric values - it looks like it wasn't intended for use with reference variables.
You're right, the best method is probably to just check various values. The main challenge here is to set some attribute to a value that no other plugin will set it to. The most obvious way that I can think of is to use a float variable set to a very specific (probably random) value. That way it's extremely unlikely - basically impossible - that another data file will set that variable to the same value
-- Cipscis 23:34, 11 January 2009 (UTC)
Hopefully, with the new method that I've put in the article, this is no longer a concern.
-- Cipscis 09:46, 17 January 2009 (UTC)
Looks good, yes. The only thing left, IMO, is that if ( refVar == ref ) is not great practice; it is unreliable in certain situations (usually dealing with the player which wouldn't affect this, but just for the sake of good scripting practice). Instead, use if ( refVar.GetIsReference ref ), that one works correctly.
DragoonWraith · talk · 18:48, 17 January 2009 (UTC)
Done, thanks for the tip!
-- Cipscis 23:17, 17 January 2009 (UTC)
I've changed the example result script back to the way it used to be. Reference variables from other scripts can't be used to call reference functions, and result scripts can't declare their own reference variables to get around this.
-- Cipscis 23:29, 17 January 2009 (UTC)