How do you script in events occurring on specific days?

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: How do you script in events occurring on specific days?
Warrior
Member # 6682
Profile #0
Hello everyone. It seems like it would be real easy but I have had no luck in telling BoA to execute events on a given day..

For example, say I want on Day 30 for a message alert to appear saying "Month: Nuwmont." Day 30 would arrive and no message will appear on the text window.

I have been writing statements such as:

beginstate LOAD_SCEN_STATE;
force_start_day(-1);
what_day_of_year();

if (what_day_of_year() == 30)
print_str("Month:Nuwmont");
break;

The above and variations thereof have given me little success.

On another unrelated note.. Is there something wrong with the "print_big_str_color" call? The other versions of print_str seem to work just fine for me, save for that one.

[ Sunday, June 11, 2006 08:56: Message edited by: Lancer ]

--------------------
Lancer
Posts: 73 | Registered: Friday, January 13 2006 08:00
Off With Their Heads
Member # 4045
Profile Homepage #1
Put the second half of your code ("if (what_day_of_year() == 30)" and "print_str("Month:Nuwmont");") in the scenario's START_STATE.

Also, it's worth taking a look at Spidweb's Bugs page, which lists the problem with the call you're talking about ("The call print_big_str_color is actually called print_big_str_num").

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Warrior
Member # 6682
Profile #2
Oooh... that documentation on bugs is helpful, Thank you!

By Kelandon's suggestion I put the second half of the code in the START_SCEN_STATE.

The following is exactly what I have:

beginstate LOAD_SCEN_STATE;
force_start_day(-1);
what_day_of_year();
break;

beginstate START_SCEN_STATE;
if (what_day_of_year() == 2)
print_str("Month:Nuwmont");
break;
-----------------------------------------------

So, on "Day 3" there is supposed to be a text string that displays as "Month:Nuwmont.."
Oddly, I am still not getting anything to show up on the text window.

I am assuming that the program knows to display this as soon as it is Day 3, or on the first tick of Day 3?

[ Sunday, June 11, 2006 10:30: Message edited by: Lancer ]

--------------------
Lancer
Posts: 73 | Registered: Friday, January 13 2006 08:00
Off With Their Heads
Member # 4045
Profile Homepage #3
quote:
Originally written by Lancer:

By Kelandon's suggestion I put the second half of the code in the START_SCEN_STATE.
Uh, not quite. The scenario's START_STATE, not the scenario's START_SCEN_STATE. Two different things. And come to think of it, the first half of the code should be in the START_SCEN_STATE, and the second half should be in the START_STATE. And you really don't need the second line of the first half (the what_day_of_year).

quote:
So, on "Day 3" there is supposed to be a text string that displays as "Month:Nuwmont.."
I don't know how you figure. The code says, "if (what_day_of_year() == 2)" — if the day of the year is 2, then it does the print_str. Note that this will print the string all during the second day.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Warrior
Member # 6682
Profile #4
Ok.. I've made some ammends and it is still not working.. Logically, I don't understand why:

beginstate START_SCEN_STATE;
force_start_day(-1);
break;

beginstate START_STATE;
if (what_day_of_year() == 2)
print_str("Month:Nuwmont");
break;

[quote=Kelandon]
I don't know how you figure. The code says, "if (what_day_of_year() == 2)" — if the day of the year is 2, then it does the print_str. Note that this will print the string all during the second day.[/quote]I just thought that since BoA nearly always starts with "zero" being the first in most circumstances, that what_day_of_year(0) would correspond to Day 1 and what_day_of_year(1) would be Day 2 so on...

[ Sunday, June 11, 2006 10:59: Message edited by: Lancer ]

--------------------
Lancer
Posts: 73 | Registered: Friday, January 13 2006 08:00
Off With Their Heads
Member # 4045
Profile Homepage #5
Eliminate the force_start_day and see what happens.

You could be right about the first day being day 0, but that would be very odd (given what the calendar shows). I haven't mucked with time much.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Warrior
Member # 6682
Profile #6
Eliminating the force_start_day(-1) call just brings back the standard calendar...

The strange thing, Kelandon, is that if I were to use the following code, the print_str works just like I expect it to...

beginstate START_STATE;
print_str("Month:Nuwmont");
break;

In this case, of course, the text string "Month:Nuwmont" is displayed every tick onto infinity...

However, as soon as I put in that "if" statement, it stops doing what I want it to do. It doesn't like something about that if statement... It doesn't understand it or I don't know what..

beginstate START_STATE;
if (what_day_of_year() == 2)
print_str("Month:Nuwmont");
break;

[ Sunday, June 11, 2006 11:15: Message edited by: Lancer ]

--------------------
Lancer
Posts: 73 | Registered: Friday, January 13 2006 08:00
Off With Their Heads
Member # 4045
Profile Homepage #7
Yes, but does it work if you eliminate the force_start_day? It's possible that using force_start_day(-1) screws up the call what_day_of_year and makes it always 0 or something.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Warrior
Member # 6682
Profile #8
quote:
Originally written by Kelandon:

Yes, but does it work if you eliminate the force_start_day? It's possible that using force_start_day(-1) screws up the call what_day_of_year and makes it always 0 or something.
It just doesn't like me for some reason..lol. I did try eliminating the force_start_day call but it didn't seem to have any bearing on the what_day_of_year call. I still get the same problem.

Is it possible that the "Passage of Time" calls just don't like if/while type statements for some reason? Or is there something syntactically fundamental that I've missed?

--------------------
Lancer
Posts: 73 | Registered: Friday, January 13 2006 08:00
Off With Their Heads
Member # 4045
Profile Homepage #9
Try putting this in the scenario's START_STATE:

print_num(what_day_of_year());

This should tell you what the value of the call is every turn.

By the way, these are all basic debugging techniques that you'll want to keep in mind whenever anything doesn't work the way that you expect in Avernumscript: isolate the problematic call, test the call as best you can, and return it to the context that you had it in originally.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Lifecrafter
Member # 6193
Profile Homepage #10
Kel was on the right track, using the call force_start_day() causes it to return zero for the day of the year. If you want to use this call then you must use what_day_of_scenario() to find out the day.
And, oddly enough, a quick test shows that day 1 does return 0. I put in a call if(day_of_scenario() == 2), and it only works on day 3.

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
Warrior
Member # 6682
Profile #11
Thanks Kelandon!!!!

Along with the print_num(short num) debugging trick I learned (as you had said) that force_start_day keeps num at 0 if used along with the what_day_of_year_call...

So, instead, I used the what_day_of_scenario call instead and it works!

Thanks again. I am definitely going to make a note of that!

--------------------
Lancer
Posts: 73 | Registered: Friday, January 13 2006 08:00
Warrior
Member # 6682
Profile #12
Thanks Lazarus, I just figured it out right before you posted!

--------------------
Lancer
Posts: 73 | Registered: Friday, January 13 2006 08:00
Off With Their Heads
Member # 4045
Profile Homepage #13
quote:
Originally written by Lazarus.:

And, oddly enough, a quick test shows that day 1 does return 0. I put in a call if(day_of_scenario() == 2), and it only works on day 3.
Now that I've referred back to the docs, this makes sense to me. Apparently, what_day_of_scenario gives "how many days have passed since the current scenario began" — that is, on day 1, zero days have passed since the start of the scenario (since BoA rounds down).

However, the weird behavior above seems as though it ought to be documented — it's not too hard to guess that the day of the year will be non-functional if the dates are off, but it should be stated explicitly, especially if the other call does work. I'll put this in the bugs thread at some point.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Warrior
Member # 6682
Profile #14
So, the question that remains is the following: Is there any way to print the string "Month:Nuwmont" only on the first tick of the day called rather than after every tick?

[ Sunday, June 11, 2006 12:23: Message edited by: Lancer ]

--------------------
Lancer
Posts: 73 | Registered: Friday, January 13 2006 08:00
Infiltrator
Member # 5576
Profile Homepage #15
Yes; use a SDF to keep track of whether the message has been displayed. If it already has, don't display it again.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
...b10010b...
Member # 869
Profile Homepage #16
If you expect some players to spend more than a year in the scenario, you'll want to reset the SDF after the month is over (probably by setting it back to 0 in the code for the start of the next month).

--------------------
The Empire Always Loses: This Time For Sure!
Posts: 9973 | Registered: Saturday, March 30 2002 08:00