Jump to content

Use if variables


Gwizz

Recommended Posts

I reuse so many maps to make a new base map, I forgot how long it takes to build a map from scratch.

Trying to use one variable for more than one operation, requires a lot of paperwork.  Since I tend to take little bites on the computer, in between outside work sessions,  It is a good way to forget exactly what I was working on before.  So paperwork is important. 

I now have a new problem.  Some of my Status events trigger twice and some work normally.

One status event counts one type cargo and triggers a report twice.  The next status event counts 4 types of cargo and triggers a report twice, yet others of the same types, work correctly.

The only thing I see is one test against territory and one test against company.  But some of the other events trigger twice but only give me one Status report and not two identical reports.

Well heck.  back to the paperwork. 

PS: I think I just figured out the problem.  The tests that work correctly are against my company and the ones that report twice test the two AI companies.  :)    Gee, why didn't I see that before.  :P

Maybe I can use company ID to limit the double test?

Link to comment
Share on other sites

Yesterday, I looked for a way to test hauls for only one AI and not the other AI.  I'm almost sure I was able to do this in the past.  I can't find the solution now.  Seemed like a I used math that Would never reach a positive number for one AI and the other AI used normal math.

Coming up short of success, I finally shut down the SP and used 5 locomotives belonging to the San Joaquin Eastern RR to run on some of the SP rails.  Now my status events work correctly and I can start testing the map.

I do need to change the dialogs and some of the history for the S.P. RR to fit the change.

Link to comment
Share on other sites

  • 4 weeks later...

One status event counts one type cargo and triggers a report twice...

The only thing I see is one test against territory and one test against company.

PS: I think I just figured out the problem.  The tests that work correctly are against my company and the ones that report twice test the two AI companies.

Maybe I can use company ID to limit the double test?

Indeed, if testing against multiple *anything*, your events can fire *many* times. It's important to know how the game iterates those things. When you get to selecting more than one (like companies *and* territories), then you're creating a loop nested within a loop. Someone who doesn't know what he's doing can inadvertently cause a load of work that causes a noticeable pause between months.

For territory events, I try as much as possible to use the territory ID box to work on just one at a time. It's my hope that the game shuns looping over all territories if I tell it just one ID to use.

For nested loops (like when selecting "multiple players" and "multiple companies" for the same trigger), it's important for the trigger condition to contain what I call a "join" condition (CompanyID=PlayerControlledCompanyID). Failure to do so can cause unintended consequences as every player / company combo is evaluated and possibly triggered for effect. In relational database programming, this is called a Cartesian product, and accidentally causing one is a rookie mistake.

In your case with status events however, there's a partial solution: Check the box to show viewing player only. You won't be allowed to set any effects, but you will suppress at least some duplication. If any duplication still occurs, try including "(COMPANY)" and/or "(TERRITORY)" in the event text as needed. Then you'll see who's doing what to whom.

Link to comment
Share on other sites

I was able to solve that problem.  Just a little short of memory. My personal memory.

Now I'm re doing a status report that give me two status dialogs, testing against four different cargoes  hauled by two railroads to a large number territories.

I'm almost out of variables to use.  I only need totals from the two railroads.  So I will use two player variables for effects and use a 3rd event to add these two variables and do the math to give me a percent result for the status report.  I think it will work.  It has been a long time since I've done events from scratch.

   

Link to comment
Share on other sites

I was able to solve that problem.  Just a little short of memory. My personal memory.

It looked like you were on to it, but I wanted to add info, especially for anyone who comes in via Google later.

Now I'm re doing a status report that give me two status dialogs, testing against four different cargoes hauled by two railroads to a large number territories.

I'm almost out of variables to use.  I only need totals from the two railroads.

Luckily, you can add a trigger result to a company variable, and each company has its own quartet of four variables. Therefore, allocating just one company variable should enable you to do a separate sum for each company in the game.

Unfortunately, if you want to do that for each cargo separately, then you're pretty much stuck... That's because "annual status report" events don't allow you to set effects, and that precludes the setting of variables, and that prevents you from reusing the same variable in a sum-display-sum-display stack of events running at status time.

So I will use two player variables for effects and use a 3rd event to add these two variables and do the math to give me a percent result for the status report.

In games where players correspond to companies over the time scale of an event, player variables can act like company vars. However, if territories get into the mix, then the nested loops can become burdensome.

If you decide that you want to conserve variables, then you might abandon the status-report frequency selection and do an end-of-year dialog per cargo instead (listing all companies' sums in each). Four dialogs each year might be a little irritating , but just one company variable could perform all sums for all cargoes without multiplying the trigger testing by the number of players.

Link to comment
Share on other sites

On this map the player owns two companies and gets credit for hauls by both railroads. 

 

If you decide that you want to conserve variables, then you might abandon the status-report frequency selection and do an end-of-year dialog per cargo instead (listing all companies' sums in each). Four dialogs each year might be a little irritating , but just one company variable could perform all sums for all cargoes without multiplying the trigger testing by the number of players.

The event that I was redoing, was firing two equal status reports.  (two companies) I wanted only one status report of all the totals, to keep status reports on one page.  My counting events don't have a dialog, so they operate out of sight.  I don't use any player events except as counters which should eliminate problems.

I had planned to double up on some company and territory variables,  But, decided to keep the events as simple as possible.  So I only doubled up on loads hauled to two different territories by making one territory serve both of the old territories.  I've been able to remove 9 events and still do as much with what is left.    8)

I was going to finish the event tonight; But, I'm too tired after I re- cemented the aboutments for a small water wheel.

If I get another sunny day tomorrow I will do the final cement work and check to make sure the wheel still fits.

There always seems to be something that get in the way of My Tycooning.

Link to comment
Share on other sites

  • 3 weeks later...

I built a problem into my variable string. 

I programed some math to happen each month and had it add to a variable.  Each answer added to the last answer which was not intended.  Changed the event to set the variable to the resulting answer and it should now work correctly.

The simplest things can cause a hiccup that spends a lot of my time.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...