Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Increasing a global variable?
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#4
RE: Static_Objects don't appear?!

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






"What you think is irrelevant" - A character of our time

A Christmas Hunt
(This post was last modified: 04-08-2016, 02:18 PM by i3670.)
04-08-2016, 02:17 PM
Find


Messages In This Thread
[SOLVED] Increasing a global variable? - by i3670 - 03-30-2016, 06:56 PM
RE: Static_Objects don't appear?! - by Mudbill - 03-30-2016, 10:02 PM
RE: Static_Objects don't appear?! - by i3670 - 04-03-2016, 11:06 PM
RE: Static_Objects don't appear?! - by i3670 - 04-08-2016, 02:17 PM



Users browsing this thread: 1 Guest(s)