Bennu Game Development

English Forums => Helpdesk => Topic started by: Zip on June 01, 2011, 04:20:43 PM

Title: Bennu can read clock data?
Post by: Zip on June 01, 2011, 04:20:43 PM
Hi people today i want to make a binary clock!,
but i have a problem, can bennu read sys info linke Hours Minutes Sec? or date?
and another question, there is some binary translate func in bennu?

thanx ;)
Title: Re: Bennu can read clock data?
Post by: handsource-dyko on June 02, 2011, 03:40:48 PM
There are some date and time functions in bennu. Mod_time has the ftime function, see http://wiki.bennugd.org/index.php?title=Mod_time (http://wiki.bennugd.org/index.php?title=Mod_time) for details. I don't know much about binary math operations since I never needed to work on bit level.
Title: Re: Bennu can read clock data?
Post by: Zip on June 03, 2011, 04:46:22 AM
thanx ;)
but i had a problem:
http://imageshack.us/photo/my-images/196/scee.jpg/
Title: Re: Bennu can read clock data?
Post by: handsource-dyko on June 03, 2011, 07:47:18 AM
I see you made a typo. Change mod_timer into mod_timers. That should fix it.
Title: Re: Bennu can read clock data?
Post by: Zip on June 03, 2011, 12:38:06 PM
import "mod_time"
import "mod_timers"
import "mod_text"
import "mod_key"

Process Main();
Private
    String timestring; // The string holding the formatted time
Begin

    write_string(0,0,0,0,&timestring); // Display the timestring
    timer = 100; // Make it so it updates the timestring immediately

    Repeat
    if(timer>100) // Update the timestring every 1 second
            timer = 0;
            timestring = ftime("%d-%m-%Y %H:%M:%S",time());
        end
        frame;
    Until(key(_esc))

End

other error:
Title: Re: Bennu can read clock data?
Post by: Sandman on June 04, 2011, 09:13:42 AM
Looks like your editor replaced "timestring" with "×tring".
Title: Re: Bennu can read clock data?
Post by: BlackCurtain on June 04, 2011, 09:22:15 AM
Quote from: Sandman on June 04, 2011, 09:13:42 AM
Looks like your editor replaced "timestring" with "×tring".
I think that's an & sign which the code-highlight converted wrong.
Title: Re: Bennu can read clock data?
Post by: Zip on June 04, 2011, 11:32:37 AM
what i need to do, for starting that example?
Title: Re: Bennu can read clock data?
Post by: BlackCurtain on June 04, 2011, 01:37:08 PM
Try this instead
import "mod_time"
import "mod_timers"
import "mod_text"
import "mod_key"

Process Main();
Private
    String timestring; // The string holding the formatted time
Begin

    write_string(0,0,0,0,timestring); // Display the timestring
    timer = 100; // Make it so it updates the timestring immediately

    Repeat
    if(timer>100) // Update the timestring every 1 second
            timer = 0;
            timestring = ftime("%d-%m-%Y %H:%M:%S",time());
        end
        frame;
    Until(key(_esc))

End

I think the & sign in write() gave you the error
Title: Re: Bennu can read clock data?
Post by: Zip on June 04, 2011, 02:40:35 PM
Quote:11: error: Data type not accepted here ( token error: "timestring" ).
Title: Re: Bennu can read clock data?
Post by: BlackCurtain on June 04, 2011, 03:34:36 PM
use write() instead of write_string().
Title: Re: Bennu can read clock data?
Post by: Zip on June 06, 2011, 01:47:45 PM
import "mod_time"
import "mod_timers"
import "mod_text"
import "mod_key"

Process Main();
Private
    String timestring; // The string holding the formatted time
timer;
Begin

    write(0,0,0,0,timestring); // Display the timestring
    timer = 100; // Make it so it updates the timestring immediately

    Repeat
    if(timer>100) // Update the timestring every 1 second
            timer = 0;
            timestring = ftime("%d-%m-%Y %H:%M:%S",time());
        end
        frame;
    Until(key(_esc))

End

in that version have'nt cmd error, but i see just a window all black
Title: Re: Bennu can read clock data?
Post by: BlackCurtain on June 06, 2011, 02:01:30 PM
Quote from: Zip on June 06, 2011, 01:47:45 PM
import "mod_time"
import "mod_timers"
import "mod_text"
import "mod_key"

Process Main();
Private
    String timestring; // The string holding the formatted time
timer;
Begin

    write(0,0,0,0,timestring); // Display the timestring
    timer = 100; // Make it so it updates the timestring immediately

    Repeat
    if(timer>100) // Update the timestring every 1 second
            timer = 0;
            timestring = ftime("%d-%m-%Y %H:%M:%S",time());
        end
        frame;
    Until(key(_esc))

End

in that version have'nt cmd error, but i see just a window all black

Well you have to initialize the window first with set_mode()
Title: Re: Bennu can read clock data?
Post by: Zip on June 06, 2011, 02:26:32 PM
no thats not the problem..
import "mod_time"
import "mod_timers"
import "mod_text"
import "mod_key"

process Main();
private
    String timestring; // The string holding the formatted time
timer;
begin
    set_mode(320,240,16);
    write(0,0,0,0,timestring); // Display the timestring
    timer = 100; // Make it so it updates the timestring immediately

    repeat
    if(timer>100) // Update the timestring every 1 second
            timer = 0;
            timestring = ftime("%d-%m-%Y %H:%M:%S",time());
        end
        frame;
    until(key(_esc))
let_me_alone();
end

its same.. black little window whitout string of text :/
Title: Re: Bennu can read clock data?
Post by: Sandman on June 06, 2011, 11:12:26 PM
write(0,0,0,0,timestring);
does not update, just writes the text as it is when you call it. You need
write_string(0,0,0,0,&timestring);

We can only conclude the compilation behaviour of Bennu has changed. The problem here is that Bennu handled references to arrays as though it were referencing the first elements. Thus timer was read as timer[0]. However, this version (don't know from which) does not do this. This means that it now gives a type error, because you try to compare an int[] and an int. So the solution is to use timer[0] instead of timer. Do not use your own private called timer, because that will not be updated by Bennu.

Correct code:
import "mod_time"
import "mod_timers"
import "mod_text"
import "mod_key"
import "mod_video"
import "mod_proc"

process Main();
private
   String timestring; // The string holding the formatted time
begin
   write_string(0,10,10,0,& timestring); // Display the timestring (the space after the & is not needed, just to fix the forum display...)
   timer[0] = 100; // Make it so it updates the timestring immediately

   repeat
    if(timer[0]>=100) // Update the timestring every 1 second
           timer[0] = 0;
           timestring = ftime("%d-%m-%Y %H:%M:%S",time());
       end
       frame;
   until(key(_esc))
let_me_alone();
end
Title: Re: Bennu can read clock data?
Post by: Zip on June 06, 2011, 11:18:53 PM
YEA thanx so much now it works
should modify the example in the wiki with that
Title: Re: Bennu can read clock data?
Post by: Zip on June 07, 2011, 11:31:32 AM
and for convert in binary there is some module in bennu?