Author Topic: ANALOG CLOCK  (Read 1248 times)

Re: ANALOG CLOCK
« Reply #20 on: 21 Jan 2020, 15:26 »
hello, thanks for the answer, then let's start over, a simple thing for you, use the animated command that from how as you can see in the picture does not work because I'm wrong something,
gclock = gui
bclock = button gui gclock
clock24 is view animated
what am i wrong with this command ?, what should i write exactly, then first i was trying your script but by mistake i then send you the photo, of your script i created 4 int in global variabiles and copied your script, on function repeatedly_execute_always ()
only that later he gave me an error at this point

GlobalScript.asc(128): Error (line 128): Nested functions not supported (you may have forgotten a closing brace)

// Called when a dialog script line "run-script" is processed
function dialog_request (int param)
{
}

thanks anyway :)





« Last Edit: 21 Jan 2020, 15:38 by katie08cd »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: ANALOG CLOCK
« Reply #21 on: 21 Jan 2020, 17:13 »
From the manual: Button.Animate(int view, int loop, int delay, RepeatStyle)

So you probably want something like: Bclock.Animate(CLOCK24, 0, 10, eRepeat); (where 10 is the speed the animation will run, and eRepeat to make it animate constantly)

About the last one, it tells you exactly what is wrong. You forgot a } (closing brace).
Now, you don't show your code and cut it, but I can see that there's a dotted line behind 123 that has no closing } bellow it. Try adding a line between line 123 and 124 and add a } under the dotted vertical line.
There are those who believe that life here began out there...

Re: ANALOG CLOCK
« Reply #22 on: 21 Jan 2020, 18:09 »
yeep, small steps, the clock works, how do i calculate the delays? is there by chance a delay converter for seconds or minutes? , now that it finally works I can interact, now if from this animation I would like to make a similar sequence,

gClock.Visible = true;
    Bclock.Animate (CLOCK24, 0, 10, eRepeat);
10 speed = I want to change it in 20 minutes

after I try again your script, thank you very much

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: ANALOG CLOCK
« Reply #23 on: 21 Jan 2020, 19:11 »
uhm... number too big that my mind explodes.  Math is not my forte...


My script "manually" animates your clock every 20 minutes.
So it does exactly what you want to do with the animation (Meaning you don't need to animate the button it at all! as I'm manually changing it at the appropriate time).
Note that if you are animating the clock, changing the clocks normalGraphic will likely not work. Since there's a warning about it in the manual. My advice is: forget animating the clock. That's not really what you want, when we talk about animating is something that will run a quick/short animation sequence once or keep repeating it.
Delete or comment out the Bclock.animate command, and go with the code.


There are those who believe that life here began out there...

Re: ANALOG CLOCK
« Reply #24 on: 21 Jan 2020, 20:01 »
ok I solved your script, it just doesn't move, I even changed the number of frames, seconds, minutes, but nothing doesn't change, what escapes me to make it work? is not that maybe you have to set the script on the view for it to work?
Bclock24.NormalGraphic intHour + = 77;
77 and to test if it moves because with 88 it stays still
Bclock.Animate (CLOCK24, 0, 30, eRepeat);
with this command animation works but with other AGS, I always make a test copy to try the functions, but unfortunately I see that by mistake if I insert the view, anyway thank you so much with the normalgraphic command (which I didn't know how to use) I can also create the pages for dialogue and much more, thanks again

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: ANALOG CLOCK
« Reply #25 on: 21 Jan 2020, 21:13 »
Please copy paste the entire function.  :-\
There are those who believe that life here began out there...

Re: ANALOG CLOCK
« Reply #26 on: 21 Jan 2020, 21:19 »
ok I tried with delays, and I did some tests
40 = 1 sec
2400 = 1 min
12000 = 5 min
36000 = 15 min
48000 = 20 min
unfortunately though if I put 33000 delay, the clock goes crazy it runs very fast, so I assume there is a limit also in the delay
32000 = 13 min> the maximum limit of 13 minutes

Re: ANALOG CLOCK
« Reply #27 on: 21 Jan 2020, 21:22 »

function repeatedly_execute_always()
{
  //intSecunds++;
  if (intSecunds*GetGameSpeed()==2400)
  {
    intSecunds=0;
    intMinute++;
    if (intMinute==1) // Because you wish to change the hour at every 20 minutes and not real time (every 60 minutes).
    {
        intMinute=0;
        intHour++;
        Bclock24.NormalGraphic=88+intHour;
        if (intHour==12 && intHour==24)
        {
          Bclock24.NormalGraphic=00; // this resets the clock image to 00:00
          if (intHour==0)
          {
          intHour=0;
          intDay++;
          }
        }
    }
  }
 
 }

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: ANALOG CLOCK
« Reply #28 on: 21 Jan 2020, 22:19 »
 //intSecunds++; <-- this is commented out. That's why the clock isn't running. Remove the // from it

Also, please wrap your code here in the forum with the [ code] [ /code] tags, or copy/paste and then select/highlight your code and choose the # button.
« Last Edit: 21 Jan 2020, 22:22 by Cassiebsg »
There are those who believe that life here began out there...

Re: ANALOG CLOCK
« Reply #29 on: 21 Jan 2020, 22:46 »
ok it works but I notice two problems
if (intMinute == 1) // Because you wish to change the hour at every 20 minutes and not real time (every 60 minutes).

1. is there a second, not a minute, that is normal, or do I have to calculate the seconds by minutes?

2. no it resets to the frame continues indefinitely showing me other images of the game, as if there was no stop despite putting the start frame. and the final frame, it seems that it does not find it

Code: Adventure Game Studio
  1.  intMinute=0;
  2.         intHour++;
  3.         Bclock24.NormalGraphic=77+intHour;
  4.         if (intHour==12 && intHour==24)
  5.         {
  6.           Bclock24.NormalGraphic=80; // this resets the clock image to 00:00
  7.           if (intHour==0)
  8.           {
  9.           intHour=0;
  10.           intDay++;

I also did the test to put only 4 frames
from 77 to 80, but it does not stop it continues showing me all the images of the game

other strange thing, if I put any frame like 77 and in the button is set 77, he starts from 80, so I have to put 75 if I want to see frame 77, strange as what

as always thank you
« Last Edit: 21 Jan 2020, 23:36 by katie08cd »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: ANALOG CLOCK
« Reply #30 on: 21 Jan 2020, 23:37 »
Please show me the numbers of your clock images. Sprite number.

No.

1. intSecund is keeping track of the seconds that have passed. Once the seconds reach 60 they are reset to 0 and to intMinute is added 1. This keeps repeating, until intMinutes reaches 20 (because you want 1 hour in game to equal 20 minutes in real life time), then IntMinutes gets reset to 0, to intHour it's added 1 and the clock changes to the next sprite.

2. There's in no stop sprite, just the sprite that corresponds to clock at 00:00!

And also, that is not the code I posted before. You have changed it at one point or another, and thus it does not work.  :-\ Please copy/paste my code (https://www.adventuregamestudio.co.uk/forums/index.php?topic=57712.msg636615180#msg636615180) and do not make changes. I have edited my code to add the missing closing bracket.
There are those who believe that life here began out there...

Re: ANALOG CLOCK
« Reply #31 on: 22 Jan 2020, 00:26 »
https://drive.google.com/file/d/1jjhytBxb6M14_FVlywSWh7Bsm7HL4Jf3/view

hello, I tried again but nothing, it does not stop continue with all the images, I prepared a copy so at least you can understand, maybe you need a reset or stop variable, I don't know, any frame that I put (even not clock) starts always with 4 frames first, so if in the first frame it says 77, I have to put 74 to start it, and then it does not stop it continues always, thanks again

push inizia, caso 1 to play
sorry for the graphic :)

I also did the test to set the 1 sprite to 12, but it does not stop always continues

        intMinute=0;
        intHour++;
        Bclock24.NormalGraphic=1+intHour; // 88 is sprite number that corresponds your clock at 00:00 (note that this only works if 89 is hour 01:00, and 90 is 02:00, etc)
        if (intHour==12 && intHour==24)
        {
          Bclock24.NormalGraphic=12; // this resets the clock image to 00:00
          if (intHour==24)
          {
          intHour=0;
          intDay++;

« Last Edit: 22 Jan 2020, 00:41 by katie08cd »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: ANALOG CLOCK
« Reply #32 on: 22 Jan 2020, 07:26 »
I fixed it, there's a if/else missing to change the sprite number when intHour is bigger than 11, need to subtract 12 to get the correct sprite to show again.
I'll post the fixes (there's more than one) later, as I needed to leave  now.
There are those who believe that life here began out there...

Re: ANALOG CLOCK
« Reply #33 on: 22 Jan 2020, 13:36 »
wowww :) thank you, I'm glad you did it, congratulations

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: ANALOG CLOCK
« Reply #34 on: 22 Jan 2020, 14:10 »
Okay, I'm back.

I started by checking the sprite numbers, and the sprite for clock 00:00 was the last one of the series, not the first.
So I started by re-numbering the sprites. They now run from 100 to 111, and 100 is 00:00, 101 is 01:00, etc, up to clock 11:00.
I had to delete the frames on the clock view, but you don't need them anyway.

Here's the remaining changes I did:
Code: Adventure Game Studio
  1. function repeatedly_execute_always()
  2. {
  3.   if (gClock.Visible==true)
  4.   {
  5.   intSecunds++;
  6.   if (intSecunds==60*GetGameSpeed())
  7.   {
  8.     intMinute++;
  9.     intSecunds=0;if (intMinute==20) // Because you wish to change the hour at every 20 minutes and not real time (every 60 minutes).
  10.     {
  11.       intHour++;
  12.       intMinute=0;
  13.       if (intHour<=11)Bclock24.NormalGraphic=100+intHour; // 100 is sprite number that corresponds your clock at 00:00
  14.       else Bclock24.NormalGraphic=100+intHour-12; // Need to remove 12h to get the correct sprite number
  15.       if (intHour==12 || intHour==24)
  16.       {
  17.         Bclock24.NormalGraphic=100; // this resets the clock image to 00:00
  18.         if (intHour==24)
  19.         {
  20.           intHour=0;
  21.           intDay++;
  22.         }
  23.       }
  24.     }
  25.     CheckRoomBackground(); // this script can be found in Scripts->CustomScripts and it will change the room background acording to the clock at game start                    
  26.     }
  27.    //player.SayBackground(String.Format("%d:%d:%d", intHour, intMinute, intSecunds/GetGameSpeed())); // for debug purpose, player will tell the time
  28.   }
  29. }
  30.  

I created a new Script in called CustomScripts (use it to add new scripts you wish to call from anywhere in script, and don't want it messed with GlobalScript functions).

Here you find the new function:
Code: Adventure Game Studio
  1. void CheckRoomBackground()
  2. {
  3.         if ((intHour<6)||(intHour>=19 && intMinute>=1)) SetBackgroundFrame(0); // Night Background
  4.         else if (intHour==6 && intMinute==0) SetBackgroundFrame(1); // Dawn Background
  5.         else if (intHour>=6 && intMinute>=1) SetBackgroundFrame(2); // Day Backgrund
  6.         else if (intHour==19 && intMinute==0) SetBackgroundFrame(3); // Sunset Background
  7. }
  8.  

And in the Header: import void CheckRoomBackground();

Use this function to set you your room before fade in (as seen in room 40):

Code: Adventure Game Studio
  1. function room_Load() // remember to plug this function to room events, just copy/pasting it won't work.
  2. {
  3.         CheckRoomBackground(); // this script can be found in Scripts->CustomScripts and it will change the room background according to the clock at game start
  4. }
  5.  

Also, if you open Room40 and look at the Backgrounds, you'll notice I've added 3 new BGs.
Background 0 (default) is the one you had, which is Evening/Night,
Background 1 is Dawn,
Background 2 is Day,
Background 3 is Sunset.

Note: I don't know what happens if AGS tries to set a Background in a room that only has 1 background. I'm guessing the two options are "Nothing happens or game crashes..."  (roll)

Here's your source back: https://www.mediafire.com/file/vo67divmugtk8sc/orologio.zip/file
« Last Edit: 22 Jan 2020, 14:19 by Cassiebsg »
There are those who believe that life here began out there...

Re: ANALOG CLOCK
« Reply #35 on: 22 Jan 2020, 17:23 »
OMG WOW, when I go to the map to go to the police, you see the background, fantastic * _ *, I made you create a wonderful script, thanks it was what I wanted, but now the game starts at 9 am, so I just have to change it sprites from 00 to 9, and then the change background script that corresponds to the time, thanks again

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: ANALOG CLOCK
« Reply #36 on: 22 Jan 2020, 17:36 »
NONONONO

Just open Global Variables, edit intHour and set the default to 9!
There are those who believe that life here began out there...

Re: ANALOG CLOCK
« Reply #37 on: 22 Jan 2020, 18:17 »
ok if I put 9 in global variabiles, the backgrounds go to me like the XD disco strobe effect, they cycle, if I set sprite 109 in the script and the gclock button disappears, because obviously the sprite sequence has changed, so what should I change to to start the game at 9? if I change the sprites the sequence is correct because it is set to 12 sprites, and those remain, the sprite 00 becomes 9 etc., and continues the cycle, the problem and the backgrounds change, now in this script the 6 is set as a time, or number of sprites? because in this way I could change it just tell him where the sprite 6 is located etc, thanks anyway I really like the script

Code: Adventure Game Studio
  1. if ((intHour <6) || (intHour> = 19 && intMinute> = 1)) SetBackgroundFrame (0); // Night Background
  2. else if (intHour == 6 && intMinute == 0) SetBackgroundFrame (1); // Dawn Background
  3. else if (intHour> = 6 && intMinute> = 1) SetBackgroundFrame (2); // Day Backgrund
  4. else if (intHour == 19 && intMinute == 0) SetBackgroundFrame (3); // Sunset Background
« Last Edit: 22 Jan 2020, 18:30 by katie08cd »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: ANALOG CLOCK
« Reply #38 on: 22 Jan 2020, 18:59 »
That is not sprite number, it's hour.  :~(
There are those who believe that life here began out there...

Re: ANALOG CLOCK
« Reply #39 on: 22 Jan 2020, 19:14 »
yes I noticed, but how come if I set it to 9 in global variabiles, the backgrounds cycle me? and then I was weighing if instead of the script with the background change, they put something like if sprite 109 changes bacground 1, can we do it? do you think so we can solve the problem, because it is fantastic but my office in the game opens at 9 am XD, as always thank you very much, another thing I noticed that I no longer see the dark around the icons (before it was gray if I went to hotspots etc, what command did you use or setting to make sure that you don't see the grayness between the icons, thanks