Showing global ints?

Is there a console command or some other way that enables you to see what a global int is or a local one ?

Also I use global ints for conversations, when the story gets to a certain point I create a global int set to 1 that will be the condition of a conversation line, at the end of that particular conversation I set it to 2 so it wont fire again. I always do this and have done it a lot, never having an issue.

But for some reason one companion’s global ints aren’t working and he’s missing conversation lines, I have checked and double checked that they match with the conditions to start the conversation and the other two companions conversations work fine.

Any idea how this could happen and go wrong ?

I’ll try and make a script for you that you can use with the console command. I just need a few minutes and I’ll be back.

Here’s a script you can use in the console command:

void main(string sGlobal)

	object oPC = GetFirstPC();
	int nGlobal = GetGlobalInt(sGlobal);

	SendMessageToPC(oPC, IntToString(nGlobal));
	SetNoticeText(oPC, "Current GlobalInt with " + sGlobal + " is (Total: " + IntToString(nGlobal) + ")");

If you call this script Globalintshow for example then the console command would be:

rs Globalintshow(“thestringofyourglobalint”)

I tested it, and it works on my end at least.


Awesome ! Thanks angalf I’ll test it and get back to you soon.

1 Like

It’s working perfectly and now lives in the campaign folder so I’ll be testing with it whenever I know one should change… Thank you very much, you have made the invisible visible !


Great to hear. Hopefully you can get to the bottom of what is wrong with your global ints. I have on rare occasions had problems like this. If I remember correctly there was some weird stuff like this going on in my first module…but after that I don’t think I’ve ever had problems with local and global ints. So it’s really strange.

If you need a script for local ints too I would have to change the code somewhat, but it’s doable.

Here is code for a local int:

void main(string sLocal, string sOwner)

	object oPC = GetFirstPC();
	object oOwner = GetObjectByTag(sOwner);
	int nLocal = GetLocalInt(oOwner,sLocal);

	SendMessageToPC(oPC, IntToString(nLocal));
	SetNoticeText(oPC, "Current LocalInt " + sLocal + " attached to " + sOwner + " is " + IntToString(nLocal) + "");

If you call this script Localintshow for example then the console command would be:

rs Localintshow (“thestringofyourlocalint”,“tagoftheobject”)

1 Like

You can also try using a console command like so:
dm_getvarint name
dm_getvarstring name

e.g. to get the int of a DoOnce variable, you would enter this in your console:
dm_getvarint DoOnce

Those will display the variable in your message window.

You can also use the following to SET those variables as well:
dm_setvarint name ###
dm_setvarstring name string

e.g. to Set the int of a DoOnce variable to three, you would enter this in your console:
dm_setvarint DoOnce 3

No commas, just keep a space between. The variable names are case sensitive.


andgalf… I’m beginning to wonder if it’s me clicking through conversations fast so I’ve moved them onto the npc lines not the PC just in case, because they’re the ones that start running before you click so have more time to work. It shouldn’t make a difference but I’m just guessing and being a bit superstitious.

I’ve stuck the local int finder script in the campaign folder too so I’m all ready to test the sneaky little beasts now… Many thanks.

travus…Thanks for the info, that is definitely going to come in handy when I forget something and I’m testing a mod or wondering why something didn’t happen like it should.

This thread could be a sanity saver for people testing their mods ( I am included already ) !

I really don’t think that could be it. I mean, the game is pretty fast when reading code. I’ve had delays like 0.1 and 0.11 and the game still pick that up, so for it to be disturbed by your clicking…I find that hard to believe, but who knows. NWN2 acts really odd sometimes.


Are you checking your ints for actual values or just if TRUE?

i.e. If you set an int to 2, this will return TRUE and is indistinguishable from 1 as far as TRUE is concerned.

Therefore, you need to make sure that you are testing the new value as if x = 2 rather than if x = TRUE to ensure the condition passes correctly.



Global ints are what they say they are “global”, meaning they are not specifically "object " specific. Therefore, your sentence is a little unusual as the companion would not have their own global ints (they have local ones but not global ones), UNLESS you are setting global ints for them using specific variable holders just for them based upon something like their names. So, maybe you should be setting the companions int checks as “local” and not “global”? For instance, if you have set two companions with global int checks, then unless the variable holder differs, then only one will fire, due to it setting the global for all companions that use the same global check.

Really good point you made there,Lance. In my first module I think I used local and global ints ranging from 1 to 5, but I don’t do that anymore precisely because of what you’re saying. That could indeed be the problem that Tsongo is facing in this case. I wonder why I didn’t think about that.

1 Like

andgalf… I have no idea why it happens the conversation node was a wild guess and you’re right it shouldn’t affect anything.

Lance_Botelle… The global ints I use are the ones that come with the actions in the conversation editor (ga_global_int ). So when I reach a certain point in the story and a conversation happens I create and set the int. eg. orcs_dead to 1. Then in the companion’s conversation there is a condition that if orcs_dead is 1 you can now talk about killing the orcs.

During this conversation about orc killing the global int orcs_dead is set to 2, that way the conversation will not start again and is effectively closed because the condition wants to find orcs_dead as 1.

I have done all my companion conversations like this in all my mods and never had an issue but for some unknown reason some of one companions conversations don’t always work. He is cursed and it is random, which is why I wondered if it’s how fast I click it during the conversation that sets the global int the first time.

Thanks for the ideas but my way of doing this is far more simple than what you are describing and I wouldn’t dream of getting that complicated with this sort of thing. It’s always worked and I’m doing exactly the same thing, all global ints are always a different name and it’s a mystery… But at least now I know how to check if they exist and that could eliminate an issue.

I understand it’s only one companion who is “cursed”, and always the same? Could it be then that the ga_global_int call is skipped depending on previous choices (conversation nodes)? Then it’s not “how fast you click” but “what nodes you choose”.

4760… Choices of dialogue, what are they ? I very rarely have them, but good idea and I always make sure the global ints come at the start before there are male/ female options or something like that.

Sometimes the conversation global int works and sometimes it doesn’t, it’s weird. I have played right through this particular module five times and only once got all the companion’s conversations and that wasn’t the last time I played it when he skipped two.

I’m now considering doubling the “ints”, having a local one on the companion and a global one too then a double “or” condition for the conversation thread and cancelling them both later on after it starts. It’s very strange and I can’t see why it wont behave.

Next time I play it I’m going to check the ints straight after the conversations they’re in with angalf’s script and at least that will isolate whether it’s the first conversation that gives them or the companion’s conversation that’s not picking up on it. I’ll also save before the conversation and whizz through it to see if that makes a difference.

It’s not game breaking but annoying that you can write something and it disappears, never to be seen, plus my poor companion doesn’t get a say in things as much as the others.

It’s when parts of the dialog show based on conditions (the gc_ stuff) or when there are several options for the player to reply to the NPC (for example: chaotic, neutral, lawful versions): more branches usually mean more endings (or different ga_global_int values/variables).

Also, since you’re using global ints, is it possible the int in question is changed during another conversation, thus preventing the poor companion from having anything to say?

4760… I was joking I don’t have many ( if any ) choices in my modules, I’m not a fan of them unless they actually make a difference. I have conditions for male/ female romance/ not and that’s about it unless something will actually change an outcome.

If I had choices that were meaningful I’d be writing conversations forever and have even more global ints depending on what somebody answered to other questions… If someone chose nasty one time, then pleasant and finally neutral my head would definitely explode because it’s hard to make that add up and make sense !

It’s highly unlikely I’ve used the same named int anywhere as they have the companion’s tag in their names, can you wipe them in any way by changing modules ? I thought global meant they travel across the campaign.

Just a thought, if there is a particular conversation where these errors occur, would you be willing to share that conversation file perhaps? One of us here could take a look at it and see if we notice any errors?

andgalf… It’s quite a few conversations linked to one companion conversation. They all work sometimes so can’t be wrong and I’ve done this a lot with every companion I’ve ever created and only this one has issues.

So without him around and the same situations ( which would need the campaign + four modules ) you’d be hard pressed to replicate it or see what happens.

I’ll let you know what happens next time I play through it and run your script after saving before vital conversations and trying to break it when I run the conversation.

And it’s not that (I think you said that already) if you have different answers in a conversation that you’ve forgotten to put a ga_global_int or ga_local_int on a certain node? Or maybe if you “miss” a conversation where this global int or local int is set… I mean, things like these have happened to me.

One player reported that he couldn’t finish my second module because of a thing like this, and I double and tripple checked the conversation and couldn’t find anything wrong so…maybe on rare occasions these faults occur, I don’t know.