Page 1 of 1

How do you write events that count and sum up numbers?

Posted: Mon Dec 04, 2006 3:01 am
by wsherrick
I have yet another question(s). I am attempting to write an event that occurs late in the scenario. This event should award the player with a large cash amount if he is successful in hauling X cars of oil. There is no time constraint in the event, but it might be fun to throw that in. The question is: Since this event occurs about 22 years into the scenario, there is no way to automactically know where the player's railroad has been built or how many cars of oil the railroad has already moved when the event kicks in; so, do I have to keep track of the cars moved from the start of the game and how do I set it up to count the cars thus trigger the effect? As always, many thanks.
P.S. What is the proper way to set up a random variable event? :!:

Posted: Mon Dec 04, 2006 4:26 am
by Ali Barba
:D Should be straight forward, set up the event to count the loads of oil, but not to take action until at least 22 years have passed. So the event would be game years elapsed since start >=22 and loads of oil hauled >= to whatever amount you have decided. You can also set it to count loads to a particular station if you like.
Don't forget to put in the cash payment LOL (when the conditions are met)
Now if I solve my problem..........lol Ali

Posted: Fri Jan 26, 2007 3:22 pm
by Lama
Just saw this post, and thought I'd give my 2c, even if it's been up a while:

"Loads hauled LTD" will return all loads ever hauled, including those hauled within the first 21 years. The condition "GYESS>=22" only means that the effect won't be triggered during the first 21 years.

To count only loads hauled in and after year 22, use two company variables.

Event 1
If CompanyLTDOilHauled>CV1 and GameYearsElapsed<=21,
Then CV1 +1
This event will make sure that CV1 "stores" the number of all loads of oil hauled, ever.

Event 2
If CompanyLTDOilHauled>CV1 and GameYearsElapsed>21,
Then CV1 +1 and CV2 +1
So only after we enter year 21, does hauling another load of oil register in Company Variable 2. Your event will check against CV2 when checking whether the player has hauled enough oil since year 22.

Both events 1 and 2 have to be triggered weekly. This allows the game to count 48 loads per year (1 game year = 48 weeks). If you expect the player to haul more, or if you want the load count to not lag behind several weeks, make two or more identical copies of both events 1 and 2 (1a-d, 2a-d).

Posted: Mon Jun 25, 2007 1:05 pm
by HighVoltage
excuse me, I just wonder what the 'D' in LTD means....LT means LifeTime, I could remember so far, just as YT only counts the current year, right!?

...and Lama (or anyone who can confirm this):
The event trigger above checks each week if there is a difference (=more hauled loads of oil) than the week before. If not, then nothing happens. If there's one more load of oil, the event will be triggered and 1 is added to CV1. The next time (next week) the event checks the number of hauls it will turn out that CV1 has the same value as 'CompanyOilHauledLifeTimeD', nothing will happen, nothing is added to CV1.
If there were more loads, 1 will be added to CV1 every week until the value is the same again. (now that self-explains why only 48 loads of oil can be counted in one year with one event - it can happen that the actual number of loads differe from CV1 on a certain 'day' (week/month) in the game, but at the end of the year the number should be the same! (of course, only if there were hauled 48 loads at max in the current year)).
Am I right?! (well, to be honest, now that I have written (and not only read the post above) this I'm almost sure about this anyway) :D
I have an issue with a similar task in my map, so maybe this could be the solution...!

Posted: Mon Jun 25, 2007 2:07 pm
by Wolverine@MSU
D=Date, so LTD is "Lifetime To Date", YTD is "Year To Date".

Posted: Mon Jun 25, 2007 4:02 pm
by HighVoltage
Wolverine@MSU wrote:D=Date, so LTD is "Lifetime To Date", YTD is "Year To Date".
Thanks (0!!0)

Posted: Tue Jun 26, 2007 7:39 am
by Grandma Ruth
This is from Lama's post:
"Event 2
If CompanyLTDOilHauled>CV1 and GameYearsElapsed>21,
Then CV1 +1 and CV2 +1
So only after we enter year 21, does hauling another load of oil register in Company Variable 2. Your event will check against CV2 when checking whether the player has hauled enough oil since year 22."
(Sorry I don't know how to do a proper quote)

To get a more accurate total, can you add the yearly totals? So you'd have an event each year that was "CV2 + [YTDCompanyOilHauled]" ??

(I don't know if it can be done - don't really understand how to use the mathematical functions with the variables. One day when I've time I might experiment a bit.)

Just a thought!

Posted: Tue Jun 26, 2007 7:53 am
by Hawk
(Sorry I don't know how to do a proper quote)

Check your post now. It shows how to do a quote. :wink:

When you want to include a quote, just hit the 'Quote' button, then paste your text and hit the 'Quote' button again. It will come out as in the above post of yours that I edited.
You can also paste your text, highlight it, then hit the 'Quote' button. :wink:

Posted: Tue Jun 26, 2007 8:23 am
by Redband
Sorry to be off-topic.

May I suggest that people who do not know how to post quotes/links etc, go into their profile and click on 'BBCode is ON'. They will find a complete explanation of how to do these things (by using this method to post a quote you can include the name of the person you are quoting).