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

Tips and Tricks on Events, Economy, etc.
User avatar
wsherrick
Engineer
Posts: 584
Joined: Sun Nov 12, 2006 12:38 am
Location: New Hope, Pennsylvania

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

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? :!:
Ali Barba

Unread post

: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
Lama
Brakeman
Posts: 178
Joined: Fri Dec 01, 2006 11:06 pm
Location: Fresno, CA

Unread post

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).
User avatar
HighVoltage
Brakeman
Posts: 115
Joined: Sun Nov 12, 2006 11:36 am
Location: Austria
Contact:

Unread post

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...!
With the Railroad, distances are disappearing, material interests are promoted, culture is raised and spread.
Carl Ritter von Ghega
User avatar
Wolverine@MSU
CEO
Posts: 1166
Joined: Fri Nov 10, 2006 2:14 pm
Location: East Lansing, MI

Unread post

D=Date, so LTD is "Lifetime To Date", YTD is "Year To Date".
User avatar
HighVoltage
Brakeman
Posts: 115
Joined: Sun Nov 12, 2006 11:36 am
Location: Austria
Contact:

Unread post

Wolverine@MSU wrote:D=Date, so LTD is "Lifetime To Date", YTD is "Year To Date".
Thanks (0!!0)
With the Railroad, distances are disappearing, material interests are promoted, culture is raised and spread.
Carl Ritter von Ghega
Grandma Ruth
CEO
Posts: 1237
Joined: Mon Nov 13, 2006 7:17 am
Location: West Yorkshire, England
Contact:

Unread post

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!
User avatar
Hawk
The Big Dawg
Posts: 6504
Joined: Fri Nov 10, 2006 10:28 am
Location: North Georgia - USA

Unread post

(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:
Hawk
User avatar
Redband
Watchman
Posts: 95
Joined: Sun Nov 12, 2006 6:01 am
Location: Brighton. Sussex. ENGLAND.

Unread post

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).
All folks as come to Sussex must follow Sussex wyas,
And when they've larned to know us well
There's no place else they'd wish to dwell in all their blessed days.
There ant no place like Sussex until you goes Above,
But Sussex will be Sussex, and Sussex won't be druv.
Post Reply