Frictional Games Forum (read-only)
[SOLVED] Increasing a global variable? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: SOMA (https://www.frictionalgames.com/forum/forum-55.html)
+--- Forum: User created content (https://www.frictionalgames.com/forum/forum-79.html)
+---- Forum: Development (https://www.frictionalgames.com/forum/forum-82.html)
+---- Thread: [SOLVED] Increasing a global variable? (/thread-43591.html)



[SOLVED] Increasing a global variable? - i3670 - 03-30-2016

**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]




RE: Static_Objects don't appear?! - Mudbill - 03-30-2016

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.


RE: Static_Objects don't appear?! - i3670 - 04-03-2016

Hmm, solved itself somehow...thanks anyway Smile


RE: Static_Objects don't appear?! - i3670 - 04-08-2016

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;
}








RE: [SOLVED] Increasing a global variable? - Mudbill - 04-10-2016

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.


RE: [SOLVED] Increasing a global variable? - i3670 - 04-10-2016

Might work. I bypassed the problem by using GetCollide instead. But this will come in handy in the future I'm sure.