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
how do I use global variables concept? [Solved]
Acies Offline
Posting Freak

Posts: 1,643
Threads: 60
Joined: Feb 2011
Reputation: 73
#4
RE: how do I use global variables concept?

As you can hear by the name, this function adds one to the variable:
AddGlobalVarInt("TasksDone", 1);

You should insert it into the function for each event. For example: "1.Talk to "Martin Smith" - Henry's freind over the phone about his loss and other things."

I'm just speculating now, but let's assume it is triggered by clicking a telephone. Clicking the phone will play a sound/conversation between the main character and Martin. In the same function which plays the sound/executes the "happenings" simply insert the:
AddGlobalVarInt("TasksDone", 1);

That will add "1" to the variable "TasksDone". Just remember to insert it into do-once functions. By that I'm meaning you should not have it in a function which may be executed several times. Otherwise the player may do the same action 20 times (thus bypassing the demand for completing all of the tasks).

As for "checking" let's assume a second scenario; As the player enters a scriptarea close to the bed he will lie down and sleep if all of the 20 tasks are complete.

Here is the "checking part":
Spoiler below!

void ToBedFunc()
{
if (GetLocalVarInt("TasksDone") == 20)

{
FadeOut(4);
//And so forth
}
else
SetMessage("Tips", "AllTasksAreNotDone", 0.0f);
}




The line which says:
if (GetLocalVarInt("TasksDone") == 20)

Checks if "TasksDone" is equal to 20. If it is equal to 20 the player will "rest". Thus when all tasks are completed the variable "TasksDone" should be equal to 20; causing the player to sleep.

The "else" part in it says that if TasksDone is not equal to 20 it will instead display a message (which you could set to something like "I can't rest until I have finished todays jobs/tasks").

[Image: mZiYnxe.png]


(This post was last modified: 12-04-2011, 11:32 PM by Acies.)
12-04-2011, 11:30 PM
Find


Messages In This Thread
RE: how do I use global variables concept? - by Acies - 12-04-2011, 11:30 PM



Users browsing this thread: 1 Guest(s)