The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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] In-game clock not working
DanielRand47 Away
Member

Posts: 109
Threads: 16
Joined: Mar 2012
Reputation: 3
#1
[SOLVED] In-game clock not working

Hello everyone. I am at work on a mod that will feature an in-game clock. The goal is to have the time be visible throughout the entire mod. The timer works in the first map. However, I have experienced some issues when transfering the values from one map to another. I have attached an image of the errors received.

Error Message
[Image: nwh6vUM.png]

I have also included the code as well. (Note that I will start it at line 36 in 02_Cellar.map.)

Code: 01_House.map (OnLeave only)
PHP Code: (Select All)
void OnLeave()
{
    
AddTimer("Stop"0.1f"MasterTimer");

    
SetGlobalVarInt("Hours"gameHours);
    
SetGlobalVarInt("Minutes"gameMinutes);
    
SetGlobalVarFloat("TimeScale"timeScale);


Code: 02_Cellar.map
PHP Code: (Select All)
int gameHours GetGlobalVarInt("Hours");
int gameMinutes GetGlobalVarInt("Minutes");
float timeScale GetGlobalVarFloat("TimeScale");

void MasterTimer(string &in asTimer)
{

    if(
asTimer == "Stop")
    {
        
RemoveTimer("Tick");
    }
    else if(
asTimer == "Initialize")
    {    
        
ChangeTime(gameHoursgameMinutes,"Set");
        
AddTimer("Tick"timeScale"MasterTimer");
    }
    else if(
asTimer == "Tick")
    {
        
ChangeTime(0,1,"Add");
        
AddTimer("Tick"timeScale"MasterTimer");
    }

    
SetMessage("TimeValues""" gameHours ":" gameMinutes0.0f);
}

void ChangeTime(int hoursint minutesstring changeMode)
{
    if(
changeMode == "Add")
    {
        
gameHours += hours;
        
gameMinutes += minutes;
        
        
// Add hours till minutes are less than 60
        
while(gameMinutes 59)
        {
            
gameHours++;
            
gameMinutes -= 60;
        }
    }
    else if(
changeMode == "Set")
    {
        
gameHours MathClamp(hours023);
        
gameMinutes MathClamp(minutes059);
    }
    
    
// Support Outside Function
    // Does any time-update commands.
    
OnTimeUpdate();
}

void OnEnter()
{
    
PlaySoundAtEntity("cellarambience""13_amb.snt""Player"1.0ffalse);
    
AddTimer("Initialize"2.0f"MasterTimer");
}

void OnLeave()
{
    
StopSound("cellarambience"1.0f);
    
AddTimer("Stop"0.1"MasterTimer");


I have tried everything from commenting out certain sections of code, moving variables around, conversions, and making sure spelling is correct. No positive results have shown. It seems that it may have something to do with the global variables. However, I do not know why they are not working. If anyone could provide some insight as to what the issue is, that would be greatly appreciated.

Many thanks!!
(This post was last modified: 09-22-2016, 05:01 PM by DanielRand47.)
09-22-2016, 01:12 AM
Find


Messages In This Thread
[SOLVED] In-game clock not working - by DanielRand47 - 09-22-2016, 01:12 AM
RE: In-game clock not working - by Romulator - 09-22-2016, 03:23 AM
RE: In-game clock not working - by DanielRand47 - 09-22-2016, 03:45 AM
RE: In-game clock not working - by Mudbill - 09-22-2016, 03:28 AM



Users browsing this thread: 1 Guest(s)