Results 1 to 37 of 37

In-game timer with good formatting

  1. #1
    Rebmem
    Join Date
    Sep 2001
    Location
    Kelowna, BC

    In-game timer with good formatting

    Based on mecha's info I threw together a quick timer for HW2 MP play. Just create a file called autoexec.lua in you hw2/bin directory, and add the following code:

    function updateTimer()
    dr_clear("timer")
    dr_setautoclear("timer",0)
    local time = Universe_GameTime();
    local h = floor(time/3600.0);
    local m = floor(time/60.0) - h*60;
    local s = time - m*60 - h*3600;
    local str = format("Time: %2.0f:%2.0f:%3.1f",h, m, s)
    dr_text2d("timer",0.25,0.97,str, 200,120,240)
    end

    Rule_AddInterval("updateTimer", 1)

    You'll get reasonably well-formatted time on-screen as h:m:s since level start.

    [edit] hopefully I got all the bugs out
    Last edited by Eiden; 26th Nov 03 at 12:28 AM.

  2. #2
    I am not a Cylon NovaBurn's Avatar
    Join Date
    Mar 2003
    Location
    Fort Worth, Texas
    Confirmed on that timer working, GG. I will post screenies later

  3. #3
    cheers!

  4. #4
    Rebmem
    Join Date
    Sep 2001
    Location
    Kelowna, BC
    BTW, in this statement

    dr_text2d("timer", 0.25, 0.97, str, 200, 120, 240)

    It would appear that the parameters mean
    0.25*screen_width = x
    0.97*screen_height = y (from bottom of screen!)
    str = duh...
    200 = red component
    120 = green component
    240 = blue component

    So.... place it where you want, and colour it how you want. I have mine at x = 0, y = 0.98....

    Mecha, now how do I add buttons?
    Last edited by Eiden; 8th Sep 03 at 4:08 PM.

  5. #5
    Time Raider Ressev's Avatar
    Join Date
    Sep 2001
    Location
    Not where... but When
    Nice job Eiden

  6. #6
    Rebmem
    Join Date
    Sep 2001
    Location
    Kelowna, BC
    Here's some updated code:

    function updateTimer()
    dr_clear("timer")
    dr_setautoclear("timer",0)
    local time = Universe_GameTime();
    local h = floor(time/3600.0);
    local m = floor(time/60.0);
    local s = time - m*60;
    local str = format("Time: %2.0fh %2.0fm %3.1fs",h, m, s)
    dr_text2d("timer",0.0,0.98,str, 255,255,255)
    end

    Rule_AddInterval("updateTimer", 1)

    It's better placement, makes the timer white, and uses h m s to denote time. I find it more readable somehow...

  7. #7
    Worst.Religion.Ever. Dyntheos's Avatar
    Join Date
    Oct 1999
    Location
    Australia
    screen shot



    nice work Eiden, and thx mecha for the code.

  8. #8
    Zone_alarm
    Guest
    Nice job Eiden, thx for this public imformation.

    Zone_alarm / ZONA DSD

  9. #9
    w00d
    Guest
    nice

  10. #10
    Forum punned-it Retroboy's Avatar
    Join Date
    Aug 2002
    Location
    Hopefully at the lake. Miss that place terribly in the winter.


    -- Retro

  11. #11
    From another dimension SpinDizzy's Avatar
    Join Date
    Aug 2002
    Location
    Derby, U.K
    :thumb:

  12. #12
    ZuiljiN
    Guest
    Nice job Eiden and thx mecha

    here another timer...classic..simple but effective

    function updateTimer()
    dr_clear("timer")
    dr_setautoclear("timer",0)
    local time = Universe_GameTime();
    local h = floor(time/3600.0);
    local m = floor(time/60.0);
    local s = time - m*60;
    local str = format("%2.0f: %02.0f: %02.0f",h, m, s)
    dr_text2d("timer",0.0,0.98,str, 255,255,255)
    end

    Rule_AddInterval("updateTimer", 1)

    screenshot

  13. #13
    I do all my own stunts Dan Van Crone's Avatar
    Join Date
    May 2002
    Location
    Adelaide, Australia
    Heh... it took Dyn 30 seconds to find the screenshot button.

  14. #14
    Wow, this timer works in the SP game too! If it works on the full game, it will be invalueable to discussing SP strategies and events.
    Blow them them up, blow them to bits!

  15. #15
    I am a sun God Ammon Ra's Avatar
    Join Date
    Mar 2002
    Location
    Europe.
    hehe...i hereby call this the "first mod" :jk:

    good job btw

  16. #16
    cateye
    Guest
    What can i say? THANX :baloons:

  17. #17
    Zang
    Guest
    Nice job! Looks like a good first mod

    And...Dyntheos...I've seen many people with the build manager reduced like you have in your SS, how do I go about changing mine to be like that?

  18. #18
    nickersonm
    Guest
    Press q.

  19. #19
    TyrealMathias
    Guest
    yummy... strat discs will be henceforth worthwhile :-D thankies, mecha, thankies Eiden :-D

  20. #20
    Atmospheric Entry Elephant The5thElephant's Avatar
    Join Date
    Mar 2002
    Location
    Alphabet City (NYC)
    Are there any other codes like this that you can just throw in to add cool stuff?




  21. #21
    Thx a lot guys, im using the clock with the small formating, less cluttered.

    Customisable interface. Goody!

  22. #22
    Artagnan
    Guest
    wow, that is beautiful, I wonder if Homeworld2 will have the same sort of hud modding that was so wonderful in tribes 1 (I miss the good old days.....)
    what other commands are possible? I would love to see a hud that tells you have much health each of your groups has in the upper left corner...... though I don't know why really.
    on ya, and shortcut keys for buy interceptor etc.

  23. #23
    Chronologically challenged Timeless's Avatar
    Join Date
    Jun 2002
    Location
    Colorado
    What do you use to type of this little timer mod? You can't just a notepad program, can you?

  24. #24
    ZuiljiN
    Guest
    yeah you can write it in notepad or any texteditor...make sure you save as autoexec.lua and not autoexec.lua.txt if you use notepad :P

  25. #25
    TyrealMathias
    Guest
    the ability to scroll the small build list (the 'q' one on the left..) would be nice...

  26. #26
    Lost in the code... Mikali's Avatar
    Join Date
    Jun 2003
    Location
    %HW2_ROOT%
    Is there any way to set the timer to a particular in-game action? Start to end of a research or building que, for example? Time it takes to move a unit from one location to another?

    -Mikail

  27. #27
    dvhh
    Guest
    just to correct (not really an issue)

    function updateTimer()
    dr_clear("timer")
    dr_setautoclear("timer",0)
    local time = Universe_GameTime();
    local h = floor(time/3600.0);
    local m = floor(time/60.0) - h*60;
    local s = time - m*60;
    local str = format("%2.0f: %02.0f: %02.0f",h, m, s)
    dr_text2d("timer",0.0,0.98,str, 255,255,255)
    end

    however that would be a good start to find out the hw2-lua functions

  28. #28
    CECIL
    Guest
    So does anyone know to what extent you can add in code like that? I'm hoping it's not a possible way for people to cheat...

  29. #29

    Re: In-game timer with good formatting

    hi. for those of you who don't remember the fun days of DOS and autoexec.bat and config.sys, here's a way to create that ".lua" file easily: open your Homeworld directory using windows explorer (found in program files/sierra/homeworld2...) and open the /Bin folder. Once there, open up the File menu bar in your windows explorer tool bar and select the cascading option, New, and end your select function on Text document; Now, open up the new text document called, "New Text Document.txt"; copy & paste whatever code you want (of the four options above) into this new document; exit and save; now, rename (using right click function on the text document; or single clicking on the document title itself) the document title to read: "autoexec.lua"

    there. done.

  30. #30
    Member
    Join Date
    May 2003
    Location
    Lugano, Switzerland
    Originally posted by CECIL
    So does anyone know to what extent you can add in code like that? I'm hoping it's not a possible way for people to cheat...
    Looking at what we've seen, many functions are exposed to the Lua interpreter. All depends on which ones are.

  31. #31
    This thread should be moved to the mod or HW2 discussion forum for greater exposure. It deserves it.

  32. Technical Help Senior Member Modding Senior Member Homeworld Senior Member  #32
    www.relicnews.com ÜberJumper's Avatar
    Join Date
    Sep 1999
    Location
    South Surrey, BC Canada
    Can anyone confirm if their hw2.log files are filling with errors when using this?

    1: function `updateTimer' at line 5 [string ""]
    parameter: attempt to call global `Universe_GameTime' (a nil value)

  33. #33
    sfuller
    Guest
    thanks makes the game much more...depressing...

  34. #34
    Carch
    Guest
    Originally posted by dvhh
    just to correct (not really an issue)

    function updateTimer()
    dr_clear("timer")
    dr_setautoclear("timer",0)
    local time = Universe_GameTime();
    local h = floor(time/3600.0);
    local m = floor(time/60.0) - h*60;
    local s = time - m*60;
    local str = format("%2.0f: %02.0f: %02.0f",h, m, s)
    dr_text2d("timer",0.0,0.98,str, 255,255,255)
    end

    however that would be a good start to find out the hw2-lua functions
    Still got a bug in there, if the game goes over an hour. Try this:

    Code:
    function updateTimer()
      dr_clear("timer")
      dr_setautoclear("timer",0)
      local time = Universe_GameTime()
      local h = floor(time/3600.0)
      local m = floor(time/60.0 - h*60)
      local s = time - m*60 - h*3600
      local str = format("%2.0f:%02.0f:%02.0f",h, m, s)
      dr_text2d("timer",0.0,0.98,str, 255,255,255)
    end
    
    Rule_AddInterval("updateTimer", 1)
    (afaik the semicolons in the original function are extraneous also)

  35. #35
    Vittore
    Guest
    With the latest code supplied by Carch, I am getting the following appearing a lot in my hw2.log:

    stack traceback:
    1: function `updateTimer' at line 4 [string ""]
    parameter: attempt to call global `Universe_GameTime' (a nil value)

  36. #36
    Flaggherty
    Guest

    timer not visible on sensor manager

    Hey, found this thread and gotta say I'm really impressed with how easy it is to add things to the UI. One problem I have though is that putting the clock in the very top left of the screen makes the timer invisible when I go into the sensors manager (since there's a black bar over the top of the screen). I want the timer to be where it is though, so is there any way to make the clock appear over the bar?
    Oh, and I'm getting the 'nil value' error, too.

  37. #37
    Papa-Smurf
    Guest
    thats ace

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •