What does "not local" mean?

Post » Wed Nov 04, 2009 4:23 pm

After a lengthy hiatus away from Morrowind, my kids got me back into it, and I have been looking at an old mod I was building. I was looking at dialogue, and what the logic is behind the "not local" thing, and suddenly it struck me. I expect many people will know this already, but I am equally sure many were as puzzled as me.

Say we have this:

not local ... my_short ... = ... 2

The way to look at it is to separate out the "not" so it looks like this

not ( local:my_short = 2 )

If the local variable "my_short" exists and is 2, then do NOT use this dialogue entry. But if "my_short" does not exist, or it exists but is not 2, then (if all the other conditions are okay) use this dialogue entry.
User avatar
marie breen
 
Posts: 3388
Joined: Thu Aug 03, 2006 4:50 am

Post » Wed Nov 04, 2009 10:31 pm

Unfortunately, it's not as logical as you think. It's explained completely in the CS help file:

This is true if the speaker does not have this local variable. Unlike most "Not" functions, this one does care what you set the variable to. Both the dialogue and the variable itself should be set to 0. This can be confusing. Here is a table of how this works:


Not Local Variable Exists Value Pass?
(in dialogue) (y/n) (in the script) (speaker will say this)
= 0 No NA Yes
= 0 Yes 0 No
= 0 Yes 5 Yes
= 1 No NA Yes
= -3 Yes -3 No


So if you use Not Local NoLore == 1, and NoLore is called in the NPC's script, then the NPC will not say that dialogue entry. The value of the variable does not matter. If it's called in the actor's script, the actor will not say the dialogue period...as far as I understand.

If you want the NPC to say the dialogue when a local variable is set to a specific number, then it's better to use Local instead of Not Local. So if you set Local to != 2, then the NPC will not say that entry if the value is 2, but say it under all other circumstances.
User avatar
Kira! :)))
 
Posts: 3496
Joined: Fri Mar 02, 2007 1:07 pm

Post » Wed Nov 04, 2009 4:14 pm

The table works fine.

If the variable does not exist, then local= will be false, so when you NOT that you get that it does pass (rows 1 and 4)

If the variable does exist, and is the same, then local= will be true, so when you NOT that you get that it doesn't pass (rows 2 and 5)

If the variable does exist, and isn't the same, then local= will be false, so when you NOT that you get that it does pass (row 3)

So what should happen (and I admot I have not tested this) is that if you set Not Local NoLore == 1, and NoLore is declared in the NPC's script, then the NPC WILL say that dialogue entry, because NoLore will be zero, and this will be like row 3. On the otherhand, if you set Not Local NoLore == 0, then that would be like rows 2 and 5, so this condition will not pass (because the NoLore variable defaults to zero), and the dialogue does not appear.
User avatar
Siobhan Thompson
 
Posts: 3443
Joined: Sun Nov 12, 2006 10:40 am

Post » Thu Nov 05, 2009 12:07 am

So what should happen (and I admot I have not tested this) is that if you set Not Local NoLore == 1, and NoLore is declared in the NPC's script, then the NPC WILL say that dialogue entry, because NoLore will be zero, and this will be like row 3. On the otherhand, if you set Not Local NoLore == 0, then that would be like rows 2 and 5, so this condition will not pass (because the NoLore variable defaults to zero), and the dialogue does not appear.

Your instincts are correct - the noLored NPC will use all of the topics filtered for Not Local: noLore = 0. This may be of interest to companion modders who usually do not want their companions to have an encyclopedic knowledge of all the local topics whenever he or she follows the player into town. So most companion scripts declare short noLore. However, if the NPC might reasonably know a particular town well (spent time there before meeting the player) the companion's script can set noLore to 1 when the NPC enters that particular town and sets it back to 0 upon leaving.
User avatar
kasia
 
Posts: 3427
Joined: Sun Jun 18, 2006 10:46 pm


Return to III - Morrowind