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
Scripting Problems
saito100 Offline
Junior Member

Posts: 15
Threads: 8
Joined: Jul 2013
Reputation: 0
#1
Question  Scripting Problems

Hey guys!

I have a scripting question.

First, I will start out with the timer I tried to make that counts down at 5 second intervals from 30 seconds and then goes at 1 second intervals when it reaches 5 seconds.

void StartGame(string &in leverName, int alState)
{
if(alState==1)
{
SetLocalVarInt("i", 0);
AddTimer("Winnings", 30, "Winnings");
if(GetTimerTimeLeft("Winnings") == 30.0f)
{
SetMessage("Messages", "30", 1);
}
if(GetTimerTimeLeft("Winnings") == 25.0f)
{
SetMessage("Messages", "25", 1);
}
if(GetTimerTimeLeft("Winnings") == 20.0f)
{
SetMessage("Messages", "20", 1);
}
if(GetTimerTimeLeft("Winnings") == 15.0f)
{
SetMessage("Messages", "15", 1);
}
if(GetTimerTimeLeft("Winnings") == 10.0f)
{
SetMessage("Messages", "10", 1);
}
if(GetTimerTimeLeft("Winnings") == 5.0f)
{
SetMessage("Messages", "5", 1);
}
if(GetTimerTimeLeft("Winnings") == 4.0f)
{
SetMessage("Messages", "4", 1);
}
if(GetTimerTimeLeft("Winnings") == 3.0f)
{
SetMessage("Messages", "3", 1);
}
if(GetTimerTimeLeft("Winnings") == 2.0f)
{
SetMessage("Messages", "2", 1);
}
if(GetTimerTimeLeft("Winnings") == 1.0f)
{
SetMessage("Messages", "1", 1);
}
if(GetTimerTimeLeft("Winnings") == 0.0f)
{
SetMessage("Messages", "0", 1);
}
}
}

So as you can see when you would pull said lever down it would go to the "StartGame" function, return the "score" or variable "i" back to zero, add a timer to go to the "Winnings" function after 30 seconds, and obviously make the countdown of 30 second for the player to see. When I pull the lever down "30" will pop up as a message but the following messages will not show.

Last question is about when the timer "Winnings" ends and you get you're "prize".

void Winnings(string &in asTimer)
{
for(int i; i == 0; i--)
{
CreateEntityAtArea("money", "coins_large.ent", "money_spawn", false);
AddTimer("", 3, "Winnings");
}
}

So all this script does is it takes the value of "i" and then each time it loops it will subtract one from "i" until reaching zero. Thus, you get you're "prize". I also do realize that I need to point the timer towards a different function and THEN back to the "Winnings" function. And just for a little more info on what i'm try to do. As you will see in the picture below. The lever is to the right of you to actually start the game or the 30 second countdown to try to get as many points as you can. The way it works is that in the model editor I made the plate unbreakable and also have no gravity. Then, I set up three points at the end of the "lane" that when one of the points collide with the plate it adds 1 being if it hit the right or left point and 2 if it hits the center. You're score at the end is represented by bags of 50 thalers. Thus, left and right points equals 50 points and the middle equals a hundred. Thanks in advance for the help! Big Grin

[Image: Amnesia2013-10-2015-13-15-44.png]
(This post was last modified: 11-15-2013, 04:57 PM by saito100.)
10-20-2013, 09:32 PM
Find Reply
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Scripting Problems

The "following messages" don't show because you placed the conditional statements that check for how much time is left inside the callback of the lever. This means the time left is checked only when the lever is pulled, not every other time. But i doubt you'd receive whole numbers as a result if you had coded it properly. If you wish to compare against whole numbers, convert the float into an int. The way i'd do it is to call another function when pulled, which increments every second, using that value for the SetMessage function, and when it reaches 30 to stop calling the timer.

As for your for loop, you have "int i;", this is the same as doing int "i = 0;". So, you're just going to get one loop, therefore no point in making a loop.

Tutorials: From Noob to Pro
10-20-2013, 10:34 PM
Website Find Reply




Users browsing this thread: 1 Guest(s)