Weekday next to date

Users who are viewing this thread

Hy, I always wanted to know the day of the week in the game, so yesterday I decided to learn how to use the module system and see if it could be done. And today I decided to post it here in case someone wants to use it too.

First search in module_scripts.py for the string "game_get_date_text" then add the code after the (assign, ":cur_year", 1257)(which assigns the starting year), make sure you don't modify any of the code you just need to add the code.

Code:
    # Aca empieza el codigo de la semana/ Here starts the weekday code
      (store_mod, ":week_day", ":num_days", 7),
      (val_add, ":week_day", "str_weekday_0"),
      (str_store_string, s1, ":week_day"),
    # Aca termina el codigo de la semana/ Here ends the weekday code

    # 12 hour am pm clock
      (store_time_of_day, ":timeofday"),
      (try_begin),
      (ge,":timeofday",12),
        (assign, reg4, 1),
        (val_sub, ":timeofday", 12),
      (else_try),
        (assign, reg4, 0),
      (try_end),
      (try_begin),
      (eq, ":timeofday", 0),
        (assign, ":timeofday", 12),
      (try_end),
      (assign, reg3, ":timeofday"),



Then you need to enter into module_strings.py and search for:

Code:
  ("january_reg1_reg2", "January {reg1}, {reg2}"),
  ("february_reg1_reg2", "February {reg1}, {reg2}"),
  ("march_reg1_reg2", "March {reg1}, {reg2}"),
  ("april_reg1_reg2", "April {reg1}, {reg2}"),
  ("may_reg1_reg2", "May {reg1}, {reg2}"),
  ("june_reg1_reg2", "June {reg1}, {reg2}"),
  ("july_reg1_reg2", "July {reg1}, {reg2}"),
  ("august_reg1_reg2", "August {reg1}, {reg2}"),
  ("september_reg1_reg2", "September {reg1}, {reg2}"),
  ("october_reg1_reg2", "October {reg1}, {reg2}"),
  ("november_reg1_reg2", "November {reg1}, {reg2}"),
  ("december_reg1_reg2", "December {reg1}, {reg2}"),

and replace it with:

Code:
  ("january_reg1_reg2", "{reg2} January {reg1}, {s1} {reg3}{reg4?pm:am}"),    #Agrego el string s2 con el dia de la semana en todos los meses
  ("february_reg1_reg2", "{reg2} February {reg1}, {s1} {reg3}{reg4?PM:AM}"),  #Adds s2 string with the week day
  ("march_reg1_reg2", "{reg2} March {reg1}, {s1} {reg3}{reg4?PM:AM}"),
  ("april_reg1_reg2", "{reg2} April {reg1}, {s1} {reg3}{reg4?PM:AM}"),
  ("may_reg1_reg2", "{reg2} May {reg1}, {s1} {reg3}{reg4?PM:AM}"),
  ("june_reg1_reg2", "{reg2} June {reg1}, {s1} {reg3}{reg4?PM:AM}"),
  ("july_reg1_reg2", "{reg2} July {reg1}, {s1} {reg3}{reg4?PM:AM}"),
  ("august_reg1_reg2", "{reg2} August {reg1}, {s1} {reg3}{reg4?PM:AM}"),
  ("september_reg1_reg2", "{reg2} September {reg1}, {s1} {reg3}{reg4?PM:AM}"),
  ("october_reg1_reg2", "{reg2} October {reg1}, {s1} {reg3}{reg4?PM:AM}"),
  ("november_reg1_reg2", "{reg2} November {reg1}, {s1} {reg3}{reg4?PM:AM}"),
  ("december_reg1_reg2", "{reg2} December {reg1}, {s1} {reg3}{reg4?PM:AM}"),

and also add:

Code:
  ("weekday_0", "Friday"),   # Genero los strings de los dias de la semana
  ("weekday_1", "Saturday"), # Generating weekdays strings 
  ("weekday_2", "Sunday"),
  ("weekday_3", "Monday"),
  ("weekday_4", "Tuesday"),
  ("weekday_5", "Wednesday"),
  ("weekday_6", "Thursday"),

Or you could use the short day version:

Code:
  ("weekday_0", "Fri"), # Genero los strings de los dias de la semana
  ("weekday_1", "Sat"), # Generating weekdays strings 
  ("weekday_2", "Sun"),
  ("weekday_3", "Mon"),
  ("weekday_4", "Tue"),
  ("weekday_5", "Wed"),
  ("weekday_6", "Thu"),

Here is an image so you can see how it looks:
mb4.jpg

The game starts on Friday because according to a post I found 23 march 1257 was a Friday. The post was:
http://forums.taleworlds.com/index.php/topic,116965.msg2820885.html#msg2820885

Also if anyone knows a better way to do it, please tell me.

Edit: I want to thank  Ikaguia for helping me simplify the code.
 
Hey there.

I followed your link that you posted in my thread, and these instructions helped me add the day of the week in seconds. :smile:

Thanks for the help with this.
 
About adding the hour.

I know how to do that thanks to some of the other posts I've been looking at, but will it put the hour on the same line as the year-date-day? It might get a little crowded, and it would probably look nicer next to the approximation of the time.
 
Adding the hours sounds cool but could you possibly post that here so I could use it, would be grateful.
 
Yes, I thought the same and tried to add it there. But the second line (where it says dusk, noon, etc.) seems to be hardcoded, because I couldn’t find it in the module system. I’m just a newbie at modding so it could be somewhere and I just didn’t found it.

So I just put an h after the hour instead of the full o’clock, and with the short days (mon instead of Monday) ,  it would look like this:
1257 March 3, Fri, 13h.
It’s still overcrowded but at least it’s shorter and the text size won’t get so small.
 
xPearse said:
Adding the hours sounds cool but could you possibly post that here so I could use it, would be grateful.

In scripts add after the week day code de following code:
For 24 hour clock:
Code:
(store_time_of_day, reg3),
or for 12 hour clock:
Code:
(store_mod, reg3, ":num_hours", 12),
(val_add, reg3, 1),

Then in strings add reg3 in the months strings, like this:
Code:
("january_reg1_reg2", "{reg2} January {reg1}, {s2}, {reg3}h"),
Do that for every month string.

The 12 hour I got it from somebody on Michigan J. Frog post: (http://forums.taleworlds.com/index.php/topic,190745.0.html)
I'm not sure the 12 hour works because I can't try it right now but I guess it should work.
 
Right now, for the hour of the day, I'm using this:
Code:
      #Hour of the day code
      (store_mod, reg3, ":num_hours", 24),
      (val_add, reg3, 1),
and
Code:
  ("january_reg1_reg2", "{reg2} January {reg1}, {reg3} O'Clock {s2}"),
  ("february_reg1_reg2", "{reg2} February {reg1}, {reg3} O'Clock {s2}"),
  ("march_reg1_reg2", "{reg2} March {reg1}, {reg3} O'Clock {s2}"),
  ("april_reg1_reg2", "{reg2} April {reg1}, {reg3} O'Clock {s2}"),
  ("may_reg1_reg2", "{reg2} May {reg1}, {reg3} O'Clock {s2}"),
  ("june_reg1_reg2", "{reg2} June {reg1}, {reg3} O'Clock {s2}"),
  ("july_reg1_reg2", "{reg2} July {reg1}, {reg3} O'Clock {s2}"),
  ("august_reg1_reg2", "{reg2} August {reg1}, {reg3} O'Clock {s2}"),
  ("september_reg1_reg2", "{reg2} September {reg1}, {reg3} O'Clock {s2}"),
  ("october_reg1_reg2", "{reg2} October {reg1}, {reg3} O'Clock {s2}"),
  ("november_reg1_reg2", "{reg2} November {reg1}, {reg3} O'Clock {s2}"),
  ("december_reg1_reg2", "{reg2} December {reg1}, {reg3} O'Clock {s2}"),
I know that this works, and when I tried Somebody's day of the week script a while ago, I used the 12 hour clock and it worked.

Edit: Just checked the 12 hour clock, and it works just fine. I prefer the 24 hour clock, and unless there is a way to change between 8 am and 8 pm (which I wouldn't know if there was, I might fiddle with it), I'm just sticking with the 24 hour clock.

Edit 2: About the switching between am and pm, would there be a way to set it that every 12 hours it changes between which set it shows? I don't know if a trigger would be able to take care of this, and I'm not experienced enough to dive into to that to find out, but like I said, I'll fiddle with it.


Ok, so I've been working on the am/pm idea, and I'm getting stuck so far, so I'm putting it up here so I can hopefully get some insight on it.
Code:
#Hour of the day code
      (store_mod, reg3, ":num_hours", 12),
      (try_begin),
        (eq, reg3, 1),
        (str_store_string, s3, "str_am"),
      (else_try),
        (eq, reg3, 13),
        (str_store_string, s3, "str_pm"),
      (try_end),
      #Here starts the weekday code
      #Calculating weekday
      (store_mod, ":week_day", ":num_days", 7),
      #String assignation
      (try_begin),
        (eq, ":week_day", 0),
        (str_store_string, s2, "str_weekday_0"),
      (else_try),
        (eq, ":week_day", 1),
        (str_store_string, s2, "str_weekday_1"),
      (else_try),
        (eq, ":week_day", 2),
        (str_store_string, s2, "str_weekday_2"),
      (else_try),
        (eq, ":week_day", 3),
        (str_store_string, s2, "str_weekday_3"),
      (else_try),
        (eq, ":week_day", 4),
        (str_store_string, s2, "str_weekday_4"),
      (else_try),
        (eq, ":week_day", 5),
        (str_store_string, s2, "str_weekday_5"),
      (else_try),
        (eq, ":week_day", 6),
        (str_store_string, s2, "str_weekday_6"),
      (try_end),
    # Here ends the weekday code
Code:
  #Adds s2 string with the week day
  ("january_reg1_reg2", "January {reg1}, {reg2}, {reg3} {s3} {s2}"),
  ("february_reg1_reg2", "February {reg1}, {reg2}, {reg3} {s3} {s2}"),
  ("march_reg1_reg2", "March {reg1}, {reg2}, {reg3} {s3} {s2}"),
  ("april_reg1_reg2", "April {reg1}, {reg2}, {reg3} {s3} {s2}"),
  ("may_reg1_reg2", "May {reg1}, {reg2}, {reg3} {s3} {s2}"),
  ("june_reg1_reg2", "June {reg1}, {reg2}, {reg3} {s3} {s2}"),
  ("july_reg1_reg2", "July {reg1}, {reg2}, {reg3} {s3} {s2}"),
  ("august_reg1_reg2", "August {reg1}, {reg2}, {reg3} {s3} {s2}"),
  ("september_reg1_reg2", "September {reg1}, {reg2}, {reg3} {s3} {s2}"),
  ("october_reg1_reg2", "October {reg1}, {reg2}, {reg3} {s3} {s2}"),
  ("november_reg1_reg2", "November {reg1}, {reg2}, {reg3} {s3} {s2}"),
  ("december_reg1_reg2", "December {reg1}, {reg2}, {reg3} {s3} {s2}"),
  # Generating weekdays strings
  ("weekday_0", "Friday"),
  ("weekday_1", "Saturday"),
  ("weekday_2", "Sunday"),
  ("weekday_3", "Monday"),
  ("weekday_4", "Tuesday"),
  ("weekday_5", "Wednesday"),
  ("weekday_6", "Thursday"),
  # Generating am/pm strings
  ("str_am", "AM"),
  ("str_pm", "PM"),
 
Ok, I’m sorry for the delay but I wasn't at home and I can't do this at work. But I just got home, try this code.
In scripts:
Code:
      (store_time_of_day, ":timeofday"),
      (try_begin),
      (ge,":timeofday",12),
        (assign, reg4, 1),
        (val_sub, ":timeofday", 12),
      (else_try),
        (assign, reg4, 0),
      (try_end),
      (try_begin),
      (eq, ":timeofday", 0),
        (assign, ":timeofday", 12),
      (try_end),
      (assign, reg3, ":timeofday"),

and in strings:
Code:
  ("jan_reg1_reg2", "{reg2} Jan {reg1}, {s2} {reg3}{reg4?pm:am}"),

I tried it and didn't have any problem.

The problem with your code is that you are assigning a value to s3 at midday and midnight, but s3 is a global string which may be used by a lot of functions.  So between the time you assign a value to it and the next time the game tries to get the date, the value of s3 may have changed and because you are not assigning it a new value, it will just have the value that was assigned the last time it was used. This may be the last time you set it or any other time in between.

Edit:  Another thing that I just realized is that you are dividing by 12 so the remainder will be between 0 and 11. And to set it to pm you are asking for it to be equal to 13, however because it is 0-11 it will never be 13.
 
hey, this:
Code:
    # Aca empieza el codigo de la semana/ Here starts the weekday code
      # Calculo dia de la Semana/ Calculating weekday
      (store_mod, ":week_day", ":num_days", 7),

      # Registros de prueba
      #(assign, reg3, ":num_days"),
      #(assign, reg4, ":week_day"),
      #(assign, reg5, ":num_day_div_7"),
      #(assign, reg6, ":num_day_divmul_7"),
      #(assign, reg7, ":num_day_divmuladd"),
     
      # Asignacion de Strings/ String assignation
      (try_begin),
        (eq, ":week_day", 0),
        (str_store_string, s2, "str_weekday_0"),
      (else_try),
        (eq, ":week_day", 1),
        (str_store_string, s2, "str_weekday_1"),
      (else_try),
        (eq, ":week_day", 2),
        (str_store_string, s2, "str_weekday_2"),
      (else_try),
        (eq, ":week_day", 3),
        (str_store_string, s2, "str_weekday_3"),
      (else_try),
        (eq, ":week_day", 4),
        (str_store_string, s2, "str_weekday_4"),
      (else_try),
        (eq, ":week_day", 5),
        (str_store_string, s2, "str_weekday_5"),
      (else_try),
        (eq, ":week_day", 6),
        (str_store_string, s2, "str_weekday_6"),
      (try_end),
    # Aca termina el codigo de la semana/ Here ends the weekday code
could be replaced with this:
Code:
      (store_mod, ":week_day", ":num_days", 7),
      (val_add, ":week_day", "str_weekday_0"),
      (str_store_string, s2, ":week_day"),
 
¿So the string names are just integers that I can add and subtract to get another integer? I didn't know.
¿Why didn't taleworlds do the same with the months?
 
Heres proof that the am, pm time works. Great work, thanks for this lostreon and ill credit you.



 
So I tried adding this, but it appears to mess up the quest notes - instead of giving me details on the quest, my notes now just say the name of the weekday the quest was given. Lots of other text strings appear thoroughly messed up, too. Does this happen to anyone else when using this code?

It seems that using s2 conflicts with other scripts called at the same time as game_get_date_text, using something else (in my case s6:cool: solves the issue (as expected). Just a FYI for anyone coming across this. Neat little script though.

While it does make it easier to "cheat" your troops (by stopping at a castle or manor just before payday), that's really more of a game design problem, it's just highlighted by displaying the weekday. I'll put something to remedy that on my to-do list, odds are I'll never get around to it though  :lol:
 


Heres what my quest notes look like, I have this added in but see nothing wrong or am I talking about the wrong thing.
 
Actually, that IS wrong  :smile: See where it says Given by: Lord Mirchaud ? Below that should be a summary of the quest - but instead there's just the name of the day you were given the quest.
 
Mekelan said:
So I tried adding this, but it appears to mess up the quest notes - instead of giving me details on the quest, my notes now just say the name of the weekday the quest was given. Lots of other text strings appear thoroughly messed up, too. Does this happen to anyone else when using this code?

It seems that using s2 conflicts with other scripts called at the same time as game_get_date_text, using something else (in my case s6:cool: solves the issue (as expected). Just a FYI for anyone coming across this. Neat little script though.

While it does make it easier to "cheat" your troops (by stopping at a castle or manor just before payday), that's really more of a game design problem, it's just highlighted by displaying the weekday. I'll put something to remedy that on my to-do list, odds are I'll never get around to it though  :lol:

I fixed it, it shouldn’t give any problem now.

I don't actually use it to leave troops in castles, I mostly use it to know when I have to pay so that I can make sure of I have the money with me at the moment. Especially when I use mods in which I can leave the denars in my castle in case I run into a bandit or something.
 
lostreon said:
I fixed it, it shouldn’t give any problem now.

I don't actually use it to leave troops in castles, I mostly use it to know when I have to pay so that I can make sure of I have the money with me at the moment. Especially when I use mods in which I can leave the denars in my castle in case I run into a bandit or something.

Sounds good, and no I don't use it to cheat my troops out of money either, by the time it's practical to be able to zip over to a castle to exploit it, money's usually not an issue anymore anyway :smile:
 
I'm wondering (for those that would attempt to exploit the stationed troops thing) if it would be possible to make a check to see how long the troop has been in your party, to make it so the troops wage is added up each day (x for in party, 1/2 x for stationed) and then you pay the total at the end of the week.

I'm guessing this would be tough to check for individual troops, and make the check stay for that troop, but thought I'd just mention it.
 
Back
Top Bottom