ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Adding the time to the HUD

« Previous 10 events | 1 2 3 4 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  08:09:12  9 March 2009
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4281

---QUOTATION---
Just in case someone needs this code later:


--Time display for in game mini map
show_time()

--Time display for in game mini map
function show_time()
    local hud = get_hud()
    local cs = hud:GetCustomStatic("hud_show_time")
    if cs == nil then
        hud:AddCustomStatic("hud_show_time", true)
        cs = hud:GetCustomStatic("hud_show_time")
    end
    local time_h = level.get_time_hours()
    local time_m = level.get_time_minutes()
    local msg
    if time_m >= 10 then
        msg = string.format(" %02d:%02d\\n", time_h, time_m)
    else
        msg = string.format(" %02d:%02d\\n", time_h, time_m)
    end
    if cs ~= nil then
        cs:wnd():SetText(msg)
    end
end
---END QUOTATION---


There's some info missing here. The show_time() function call needs to be inside the actor_binder:update() event loop, and I strongly recommend that you put it inside the if self.next_restrictors_update_time < time then ... end block so that you are not continuously refreshing the screen with info that changes only every six seconds in the normal game.

Even with the speedup functionality you guys are using, checking every 200 milliseconds should be enough. You can also check to see if the minutes have changed before performing another update.

Also, the test if time_m >= 10 then is not necessary in the current version of the routine; I suspect there's a typo in one of the lines since both formats are the same in this version. The idea is to print a zero and a digit if the minute value is less than 10 (i.e., one digit instead of two).

That's cool stuff, bamah. Thanks for posting it! And thanks for cleaning it up, Don Reba -- although this forum software still manages to mangle the quoting of same...
  08:33:34  9 March 2009
profilee-mailreply Message URLTo the Top
romulous
Senior Resident
 

 
On forum: 12/28/2007
Messages: 1868

---QUOTATION---
Just in case someone needs this code later:


--Time display for in game mini map
show_time()

--Time display for in game mini map
function show_time()
    local hud = get_hud()
    local cs = hud:GetCustomStatic("hud_show_time")
    if cs == nil then
        hud:AddCustomStatic("hud_show_time", true)
        cs = hud:GetCustomStatic("hud_show_time")
    end
    local time_h = level.get_time_hours()
    local time_m = level.get_time_minutes()
    local msg
    if time_m >= 10 then
        msg = string.format(" %02d:%02d\\n", time_h, time_m)
    else
        msg = string.format(" %02d:%02d\\n", time_h, time_m)
    end
    if cs ~= nil then
        cs:wnd():SetText(msg)
    end
end
There's some info missing here. The show_time() function call needs to be inside the actor_binder:update() event loop, and I strongly recommend that you put it inside the if self.next_restrictors_update_time < time then ... end block so that you are not continuously refreshing the screen with info that changes only every six seconds in the normal game.

Even with the speedup functionality you guys are using, checking every 200 milliseconds should be enough. You can also check to see if the minutes have changed before performing another update.

Also, the test if time_m >= 10 then is not necessary in the current version of the routine; I suspect there's a typo in one of the lines since both formats are the same in this version. The idea is to print a zero and a digit if the minute value is less than 10 (i.e., one digit instead of two).

That's cool stuff, bamah. Thanks for posting it! And thanks for cleaning it up, Don Reba -- although this forum software still manages to mangle the quoting of same...
---END QUOTATION---



Seriously, if anyone at all can get this to work, please upload the two files to somewhere so I can download them. I copied and pasted into that section of bind_stalker, and then updated the ui xml file. Loaded STALKER, instant CTD.

Expression : fatal error
Function : CScriptEngine::lua_error
File : E:\stalker\patch_1_0004\xr_3da\xrGame\script_engine.cpp
Line : 73
Description : <no expression>
Arguments : LUA error: ...ow of chernobyl\gamedata\scripts\bind_stalker.script:298: attempt to call global 'show_time' (a nil value)

So, a working copy of both files would be very much appreciated.

Thanks.

CM
  09:08:35  9 March 2009
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4281
You put the function call in the loop the way I said. The "function call" is the single line I quoted: show_time(). It is the call to the function show_time().

Just put that one line inside the loop block, as I'll show below.

The routine itself is is a separate function. You put it at the same "level" as the other "function xxx() ... end" routines.
__________
function show_time()
    -- ... the contents of the function are here
end

function actor_binder:update(delta)
       -- ... stuff
       if self.next_restrictors_update_time < time then
               bind_restrictor.actor_update(delta)
               show_time() -- put this line here
               -- ... more stuff
       end
       -- ... still more stuff
end

¯¯¯¯¯¯¯¯¯¯
If you declare a function A() inside another function B(), that A() function is not global, it is only accessible in the block where it is placed in B() -- if the language permits this.
  09:24:55  9 March 2009
profilee-mailreply Message URLTo the Top
romulous
Senior Resident
 

 
On forum: 12/28/2007
Messages: 1868

---QUOTATION---
You put the function call in the loop the way I said. The "function call" is the single line I quoted: show_time(). It is the call to the function show_time().

Just put that one line inside the loop block, as I'll show below.

The routine itself is is a separate function. You put it at the same "level" as the other "function xxx() ... end" routines.
__________
function show_time()
    -- ... the contents of the function are here
end

function actor_binder:update(delta)
       -- ... stuff
       if self.next_restrictors_update_time < time then
               bind_restrictor.actor_update(delta)
               show_time() -- put this line here
               -- ... more stuff
       end
       -- ... still more stuff
end

¯¯¯¯¯¯¯¯¯¯
If you declare a function A() inside another function B(), that A() function is not global, it is only accessible in the block where it is placed in B() -- if the language permits this.
---END QUOTATION---



Thanks. Same effect though - instant CTD and same error. Here are the two (modified with those changes) files if anyone wants to have a go at getting this to work:

http://www.mediafire.com/?sharekey=026019724dca724b8d78a0e555291609e04e75f6e8ebb871

Regards,

CM
  10:22:53  9 March 2009
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4281
Okay, I don't have access to Mediafire files, so someone else will have to answer you, or you can wait for the update to the demo that I'll work on after I get time.*

However, if that call is on line 298 in the ZRP R11 bind_stalker.script, my bet is that you didn't put the entire 19 lines of the show_time() function above the actor_binder:update() function.

Where I said " -- ... stuff", there's code in the file that I didn't show.

Get some patience, guy, and I mean right now! (Twist on old joke.)

___________
*Heh; in the game I've already got time speed up and time slow down, as well as time speed query, and it's okay to save at any speed because you can restore the time to the setting you want whenever you want. But you can starve to death in speedup, or die in slowdown because your stamina takes 10 to 100 times longer to recover, so I'm thinking of not releasing it.
  13:50:50  9 March 2009
profilee-mailreply Message URLTo the Top
notanumber
mod abuser & exploiter
(Resident)

 

 
On forum: 03/22/2008
 

Message edited by:
notanumber
03/09/2009 15:36:10
Messages: 2818

---QUOTATION---
But you can starve to death in speedup, or die in slowdown because your stamina takes 10 to 100 times longer to recover, so I'm thinking of not releasing it.
---END QUOTATION---


I think that it should be just as safe as some of the other ZRP debug features
Avoiding death from starvation is easy: just equip any health-restoring artifact (even stone blood) and you won't die.

Other adverse effects of speedup can be NPCs or mutants spawning so frequent that whatever killed them in the first place doesn't walk away far enough and you'll see the cadavers piling up.
  14:53:16  9 March 2009
profilee-mailreply Message URLTo the Top
BobBQ
2007-2017
(Resident)

 

 
On forum: 07/30/2007
Messages: 3336
Lo and behold, we have timekeeping!
  10:33:03  11 March 2009
profilee-mailreply Message URLTo the Top
romulous
Senior Resident
 

 
On forum: 12/28/2007
Messages: 1868

---QUOTATION---
*Heh; in the game I've already got time speed up and time slow down, as well as time speed query, and it's okay to save at any speed because you can restore the time to the setting you want whenever you want. But you can starve to death in speedup, or die in slowdown because your stamina takes 10 to 100 times longer to recover, so I'm thinking of not releasing it.
---END QUOTATION---



I love debug features Please release, but maybe have a - hidden - download link on the ZRP website. Hidden so that the hoards of Nymlits can't get to it, but us (semi?) evolved-Nymlits can!

CM
  19:59:44  12 March 2009
profilee-mailreply Message URLTo the Top
Darius6
The sound guy...
(Resident)

 

 
On forum: 04/05/2007
 

Message edited by:
Darius6
03/12/2009 20:03:29
Messages: 2131
I wanted to ask, may I use this function in the upcoming version of 1154 hud? And if yes, who should I credit for it?
  20:18:02  12 March 2009
profilee-mailreply Message URLTo the Top
Becquerel
(Senior)
 
On forum: 09/10/2008
Messages: 102
Interesting question. I'm bumping this thread up.
I hope modders will integrate someday a clock into the hud which is round, little and consists of semi-transparent clock image. Depending on the time of day (AM or PM), the passed hours are filled up with red or yellow colour.
 
Each word should be at least 3 characters long.
Search:    
Search conditions:    - spaces as AND    - spaces as OR   
 
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
 

All short dates are in Month-Day-Year format.


 

Copyright © 1995-2020 GSC Game World. All rights reserved.
This site is best viewed in Internet Explorer 4.xx and up and Javascript enabled. Webmaster.
Opera Software products are not supported.
If any problem concerning the site functioning under Opera Software appears apply
to Opera Software technical support service.