Frictional Games Forum (read-only)

Full Version: [SOLVED] Increasing a global variable?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
**Check last post for current issue**

So I have a bit of a problem. All of a sudden my static objects won't show up in their designated position, they don't even show up at all. From the look of it, only SO are affected because entities are visible. Does anyone know what the problem is? Is it occluders perhaps?

How it looks In-Game:
Spoiler below!

[Image: cAIE16p.png]


How it looks in MapView/LevelEditor:
Spoiler below!

[Image: IJkwhxV.png]

[Image: vcf8mtu.png]

Could be a difference in the main folder's resources.cfg compared to your mod's resources.cfg. Your mod uses yours (obviously), but the editors I believe always use the main one.

You can also check the hpl.log for errors of why it didn't load.
Hmm, solved itself somehow...thanks anyway Smile
Didn't want to make a new thread for this question.

How do globals work in SOMA? I have this script where I need to keep track of how many entities (c_part_xx) there are in the area. But I have no idea what the code is for increasing a global's value.

It's not really an looking-for-error-mistake. It's more of an I-don't-know-the-right-code. The cScript_SetGlobalVarInt works and the cScript_GetGlobalVarInt, but not the cScript_AddGlobalVarInt (presumably because it doesn't exist)

Spoiler below!

void OnStart()
{
Map_AddTimer("Timer_Power_Off", 3.0f, "Timer_Power");
Map_AddTimer("Timer_Power_On", 3.5f, "Timer_Power");

cScript_SetGlobalVarInt("LocalVarComputer", 0);
}

bool AttachComputerPart_Func(const tString &in asStickyArea, const tString &in asBodyName)
{
cScript_AddGlobalVarInt("LocalVarComputer", 1);

if(cScript_GetGlobalVarInt("LocalVarComputer") == 5){
for(int i=1;i<=9;i++){
Entity_SetInteractionDisabled("c_part_"+i+"", true);
}
}

return true;
}

bool DetachComputerPart_Func(const tString &in asStickyArea, const tString &in asBodyName)
{
cScript_AddGlobalVarInt("LocalVarComputer", -1);
return true;
}





If the "Add" script is lacking, you could always do it with something like this:

PHP Code:
cScript_SetGlobalVarInt("LocalVarComputer"cScript_GetGlobalVarInt("LocalVarComputer") + 1

Better yet, if this is something you use a lot, create your own quick function for it:

PHP Code:
void cScript_AddGlobalVarInt(string varNameint valueToAdd) {
    
cScript_SetGlobalVarInt(varNamecScript_GetGlobalVarInt(varName) + valueToAdd);


Then you can use the code you originally had by just including this function somewhere in your file (or a global.hps if there is one). I haven't tested any of this in SOMA so it might be preferrably done differently.
Might work. I bypassed the problem by using GetCollide instead. But this will come in handy in the future I'm sure.