SPI -Stockpiled Industries - Development thread

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

User avatar
kamnet
Moderator
Moderator
Posts: 8548
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: SPI -Stockpiled Industries - Development thread

Post by kamnet »

What about this? A single tile industry that converts passengers into fresh workers, who then get taken to the industries. The industries then convert fresh workers into tired workers, who then get taken back to the single tile industry that converts tired workers back into passengers. With CargoDist this should help keep everything in balance, right?
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SPI -Stockpiled Industries - Development thread

Post by 3iff »

sevenfm

Some of those ideas sound interesting...any chance you can send me some code you've modified so I can have a look?

I dislike farm supplies/engineering supplies/manufacturing supplies because they are too generic. Now I can expand to extra cargos and am looking at uses for fertiliser, bottles, cardboard (for boxes) and so on.

kamnet

That sounds easily possible but I think I will be removing the manpower feature from SPI. I never use it and the existing code is a bit flaky (rubbish, actually).
On a similar note, I'm sure tourists exist. They could be included somewhere.

The lovely thing about having 16 input/output cargos is that there's so much more that can be done (but there's the danger of it being completely overwhelming)

Thanks for the suggestions, keep them coming.
User avatar
sevenfm
Engineer
Engineer
Posts: 117
Joined: 25 Jul 2016 23:44
Location: Soviet Russia

Re: SPI -Stockpiled Industries - Development thread

Post by sevenfm »

@3iff

I'm afraid my code is a total mess, but here's what I have anyway:
https://drive.google.com/file/d/1p2cDEh ... sp=sharing
edit: I added read permissions to the link, hope it works now

As for my economy changes, I plan to rework it one day so processing industries are built first around towns depending on population, and next primary industries are created using some conditions like distance, number of similar industries already on the map etc. It's kind of counter intuitive but it should work much better in OTTD world I think. And auto built town consumer industries (which replace houses) didn't work well in my experience, when being built in every town, there should be much less of them and maybe even mostly built manually by player.

I hope you don't plan to overcomplicate things with all those new possibilities :-) Really I see a few cases where industry cargo could be expanded but no more then +1/+2 cargo at max.
And one thing I miss from ECS is tourist industries, I really like them. I thought of making town hall produce (basing on town size/transport rate) and receive tourists, to encourage inter city transport, and they could be sent later to tourist centers when they appear.

As for manpower, what if big towns could have a town industry college/university which produces high quality workers which are needed to reach highest level of production for processing industries? Just an idea.
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SPI -Stockpiled Industries - Development thread

Post by 3iff »

Thanks, I'll have a look. I'm sure I can find something useful.

I don't like to make things too complicated, so hopefully I won't stray into that area.

Production levels are at a point where I'm fairly comfortable...I simply cannot cope with 1000's of cargo so I keep levels a bit lower (with an option to make them higher if players like extra cargo).
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SPI -Stockpiled Industries - Development thread

Post by 3iff »

sevenfm.

When I tried your grf, SPIX, I got few if any industries...I eventually worked out what you were doing.

I really like the idea of setting industries dependant on the size of the local town. In fact I have been wishing I could start off with a wilderness, industry free, and have industries appear as towns grow in size. Your concept would allow me to do that and I'm looking to expand SPI2 with just that option.

The idea is to start with a number of small towns where some farms and light industry may appear at game start then by enlarging the existing towns new industries can be attracted to the area.

I just need to get some ActionD registers freed up and I can do it.

Thanks for the idea of how to do it...
User avatar
sevenfm
Engineer
Engineer
Posts: 117
Joined: 25 Jul 2016 23:44
Location: Soviet Russia

Re: SPI -Stockpiled Industries - Development thread

Post by sevenfm »

You can also set some industries to depend on global population and not local, like, to have a port if you have more than certain number of industries on map each of which depend on local town population. Or set certain industries to appear only after town reaches like 5000 people (to have big plant), so you can count them too.
I use town industries (shops etc) as counters for local/global population, but as I said it doesn't work well for several reasons.
I like the idea of starting with a few small industries, like grain mill, or fishing port or sawmill, forge and lime kiln, and when you develop your towns by supplying pass transport and food/goods, you can have bigger and more complex industries like metal fabrication plant or petrol production etc.
I also like the idea of limiting supply/demand industry distances early in the game so the game can be more playable in 1700 or 1800 with horses and sails.
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SPI -Stockpiled Industries - Development thread

Post by 3iff »

sevenfm wrote: 26 Aug 2021 11:43 You can also set some industries to depend on global population and not local, like, to have a port if you have more than certain number of industries on map each of which depend on local town population. Or set certain industries to appear only after town reaches like 5000 people (to have big plant), so you can count them too.
I use town industries (shops etc) as counters for local/global population, but as I said it doesn't work well for several reasons.
I like the idea of starting with a few small industries, like grain mill, or fishing port or sawmill, forge and lime kiln, and when you develop your towns by supplying pass transport and food/goods, you can have bigger and more complex industries like metal fabrication plant or petrol production etc.
I also like the idea of limiting supply/demand industry distances early in the game so the game can be more playable in 1700 or 1800 with horses and sails.
And that's what I'm trying to do at the moment.

I have an option where industries will only build if the local town population is big enough, and it's working.
It's currently on a fairly simple basis (just count the town population) but it could expand to take account of totals of various industries (like your spix sort-of does).

I started a game with a few towns, none larger than 500 pop, no industries (but allowed random builds once I'd started) and spent AGES trying to build them up. I had lots of primary industries and nowhere to take the produce, until a grocers eventually appeared and I could transport fruit. Eventually a town got to 1000 pop and things started to develop.
I now have a few towns at 5000+ and things are starting to go a bit wild!

I'm still experimenting and playtesting so progress is fairly slow, but encouraging.
User avatar
GarryG
Tycoon
Tycoon
Posts: 5850
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: SPI -Stockpiled Industries - Development thread

Post by GarryG »

3iff wrote: 31 Aug 2021 10:25 I have an option where industries will only build if the local town population is big enough, and it's working.
That sound really interesting .. hope get it all working.

A code you gave me many years ago that Industries produce depending what population is what great (I had forgotten all about it till I reading your post) and hope to use in Industry I doing now.

Code: Select all

/* THIS SECTION TELLS THE INDUSTRY TO PRODUCE CARGOS DEPENDING ON TOWN SIZE */

produce(CourierService_produce_256_ticks, 0, 0, 0, LOAD_TEMP(1) + 4, LOAD_TEMP(2) + 4, 0);

// changed title of this switch - added code for 2nd product too.
switch (FEAT_INDUSTRIES, PARENT, CourierService_pop_bonus, [
   STORE_TEMP(((population > 399) + (population > 599) + (population > 899) + (population > 1599) + 
      (population > 2699) + (population > 4999) + (population > 9999) + (population > 10999)), 1),
   STORE_TEMP(((population > 399) + (population > 599) + (population > 899) + (population > 1599) + 
      (population > 2699) + (population > 4999) + (population > 9999) + (population > 10999)), 2), ] ) {
return CourierService_produce_256_ticks;
}

Code: Select all

      item(FEAT_INDUSTRIES, CourierService, 87) {
      
 	graphics {
                produce_256_ticks: CourierService_pop_bonus;
It helps stop Industries producing to much cargo .. just need to test to see if NML 5.3 still allows it.

Cheers

EDITED: 2nd September.

Unfortunately that code when I tried it NML 5.3 came up with this message,

Code: Select all

←[K←[93m nmlc warning: "AuzFarmIndustry.nml", line 396826: Consider using the ne
w produce() syntax for 'builders_yard_produce_256_ticks'←[0m
Not sure yet how it needs coding for 5.3

Cheers
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SPI -Stockpiled Industries - Development thread

Post by 3iff »

I'm guessing that's just a warning...the code should compile anyway.
NML5 and 6 have changed a lot of things. I still have lots of warnings in my current code but it all compiles anyway and works as expected.

Yes. it's just the produce line that now expects cargo codes...something like...

produce (courierservice_produce),
[ // theses are the inputs
],
[ // outputs
GOOD: LOAD_TEMP(1) + 4,
FOOD: LOAD_TEMP(2) + 4,
], 0;

Going from memory but the 4, above might need to be 4;
Such code would produce goods and food without any input cargos (like a port for example).

I'm sure there's some 'proper' code for this syntax somewhere...I can't remember the exact format at the moment.
The old code will work fine but it's probably advisable to update it at some stage.

Anyway, I have the code sorted out for limiting industries in towns only if the town population is sufficient. It's an option, so doesn't have to be used, and the player can ignore such limits and build a steel mill in a town catchment area with just a population of 100 (if they really want to).
User avatar
GarryG
Tycoon
Tycoon
Posts: 5850
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: SPI -Stockpiled Industries - Development thread

Post by GarryG »

3iff wrote: 07 Sep 2021 09:19 I'm guessing that's just a warning...the code should compile anyway.
I think so too .. had simular warning for when we had only 2 or 3 cargoes .. yet they still worked.
3iff wrote: 07 Sep 2021 09:19 produce (courierservice_produce),
[ // theses are the inputs
],
[ // outputs
GOOD: LOAD_TEMP(1) + 4,
FOOD: LOAD_TEMP(2) + 4,
], 0;
That going to be a pain if that what we need to do .. old code could use same for all industries and just change industry name. But be a bit annoying if we need to add the cargos, especially when our Industries will often have many cargoes. So for now I stick to the older code while its working.
3iff wrote: 07 Sep 2021 09:19 I'm sure there's some 'proper' code for this syntax somewhere...I can't remember the exact format at the moment.
The old code will work fine but it's probably advisable to update it at some stage.
Maybe some one will see this post and help us out.
3iff wrote: 07 Sep 2021 09:19 Anyway, I have the code sorted out for limiting industries in towns only if the town population is sufficient. It's an option, so doesn't have to be used, and the player can ignore such limits and build a steel mill in a town catchment area with just a population of 100 (if they really want to).
That idea will add some realism to game.

Wonder if we can limit the number of Industries per town?

Cheers pal
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SPI -Stockpiled Industries - Development thread

Post by 3iff »

Limiting industries per town is easy. (again code is from memory)

industry_count_town(arable_farm) counts the number of arable farms in the local town catchment area. If you want a limit then just refuse a new farm if the current total is 4 (or whatever number you want). You can also link this number to the local town population if you want, so a small town (200) might have up to 2 farms, population 500 can have 3, a town of 10,000 might be limited to 1. Pick whatever numbers you like and just add them to the code that decides if building a new industry is valid according to the conditions you set.

If I remember, I'll try and code up an example just to give you an idea of how it could work.

I've also done some code so that many production industries are in 'families'. Only one member of a family can be built (by the game) in any town. So, flour mill, dairy, stockyard and brewery are all in one family. If a town gets a brewery, it becomes a 'brewery town' and rejects game-generated efforts to build a flour mill, dairy of stockyard in the same catchment area. (Players can ignore this limitation). There are 7 'families' in all so it ensures industries are spread around the map instead of clustering in one major town/city. It seems to work well.
User avatar
sevenfm
Engineer
Engineer
Posts: 117
Joined: 25 Jul 2016 23:44
Location: Soviet Russia

Re: SPI -Stockpiled Industries - Development thread

Post by sevenfm »

Town specialization and industry families sounds cool. Maybe make an exception for really big towns or cities to have no family restrictions, just for fun.
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SPI -Stockpiled Industries - Development thread

Post by 3iff »

As promised, example code for controlling new industries as generated by the game.

// <<< anything beginning with this is a comment line. The compiler ignores it - just in case you didn't know.

// extract the local town population. If you plan to use if for a few checks, then save it in a register first
// This uses the new procedures facility available in NML 0.6.0
switch (FEAT_INDUSTRIES, PARENT, getpop, 0) {
return population;
// return [STORE_TEMP(population, 1);] // use LOAD_TEMP(1) instead of getpop() if you stored the population in temp register 1
}


// This is the switch that handles various check conditions that may disallow a new brewery in this location
// if any check is > 0 (basically equivalent of TRUE) then the build will be disallowed.

switch (FEAT_INDUSTRIES, SELF, brewery_proximity,
[
// do proximity checks to disallow a new brewery if related industries are too close.

(industry_distance(brewery) < 56)
+ (industry_distance(port) < 25)
+ (industry_distance(arable_farm) < 25)
+ (industry_distance(fruit_plantation) < 25)
+ (industry_distance(mixed_farm) < 25)
+ (industry_distance(cereal_farm) < 25)
+ (industry_distance(flour_mill) < 25)

// disallow if another related industry is already in the town catchment area (part of SPI-2)
+ industry_town_count(flour_mill)
+ industry_town_count(dairy)
+ industry_town_count(stockyard)

// disallow if the town population isn't high enough (here it needs to be at least 700) (optional part of SPI-2)
+ (getpop() < 700)

// disallow if the town population is too high (just an example - I don't use this...yet)
// don't build here if the population is over 20,000
+ (getpop() > 20000)

// such code may cause issues if all the towns are very big...none would be small enough to build a new brewery.
// it may be better to link it with the global industry count to ensure that industry building isn't totally blocked.
// the line below would allow a town of 20,000 to build a brewery if the total number of breweries on the map was 0 or 1.
// + (getpop() > 20000) * (industry_count(brewery) > 1)

// disallow if the town catchment area already has 2 breweries (just an example - I don't use this...yet)
+ (industry_town_count(brewery) > 1)

// disallow if the town population already has 1 brewery and population is less than 1000 (just an example - I don't use this...yet)
// (that's to say that for a second brewery to be allowed, the population must be at least 1000)
+ (industry_town_count(brewery) == 1) * (getpop() < 1000)


]) {
0: return CB_RESULT_LOCATION_ALLOW; // all the checks scored 0 (they are all FALSE) so we can build this here
return CB_RESULT_LOCATION_DISALLOW;
}

--------------------------

Of course you can include whichever lines you like and use appropriate values.
You can add you own interlinked conditions (like the last one referring to population of 1000)
just make sure you get the logic right (the sum must be 0 to allow the build, 1+ to disallow)

This may perhaps not be the most efficient code, but it does work.

These limitations only apply for in-game generated industries.
Other code elsewhere will allow the player to build whatever industries they wish and wherever they want.

Oh, and thanks for the question...it may have given me an idea or two.

-------------------------------------------------------------

The whole purpose of the industry families is to prevent one or two large (giant) towns getting all the industry types. This is especially important when limiting industries by population. Without this feature, the first big town gets everything and other towns are marginalised.

It's still a work in progress though - and the player is free to ignore these 'limitations' anyway.
User avatar
GarryG
Tycoon
Tycoon
Posts: 5850
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: SPI -Stockpiled Industries - Development thread

Post by GarryG »

3iff wrote: 21 Sep 2021 09:09 As promised, example code for controlling new industries as generated by the game.
Well done .. this be great on the heavy industries such as steal works and ones that pollute a lot.

Cheers pal
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
User avatar
luk3Z
Traffic Manager
Traffic Manager
Posts: 197
Joined: 25 Dec 2005 17:42
Location: Kielce, Poland (Mars sometimes)

Re: SPI -Stockpiled Industries - Development thread

Post by luk3Z »

BTW why don't add new restrictions to industries like 'dedmand' (as I proposed before) ?
As far I can see it is not posibble now by NML. What are you think about this ?

Image
Find new graphics easier:
GRFCrawler -> http://grfcrawler.tt-forums.net
BaNaNaS -> https://bananas.openttd.org/
32 bit gfx in OTTD (32bpp) -> https://wiki.openttd.org/en/Community/N ... 20graphics
TTDPatch 2.6 -> viewtopic.php?f=19&t=67694
How to subtract tax from income (workaround) -> viewtopic.php?t=89763&start=20
How to ban distance from income -> Simple Cargo Decay Override
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SPI -Stockpiled Industries - Development thread

Post by 3iff »

It looks a bit like a subsidy request. I've not seen this before so I'll have a look at it.
krohmalny
Engineer
Engineer
Posts: 12
Joined: 05 Mar 2022 10:58
Contact:

Re: SPI -Stockpiled Industries - Development thread

Post by krohmalny »

Hello.

I've just run today on your GRF, tested a bit and it works fantastic. :) I have my own TTD (jgr) server where we play on FIRS and I would like to exchange it to SPI on the new map (just after the vacations).

the thing is, that we play on Day Length Factor set to "50", which means that in 24h of real life we have 2 years of progress in the game - so we play on one map for few months. We also use map size of 2048x4096 and length of trains of 15 blocks (29 modern oil wagons).

The problem with SPI in this configuration is, that (set all the production in settings to max) max production of mentioned oil is around 270k per month. In these settings it should be at least 1M to 5M to make our map playable.

So I wanted to ask you if there is easy way, to enlarge the production, for example, 10 times to the current one, so we can achieve 2.7M per month? I may be able to do it myself to not waste your time, if you just give me a hint how to do that. I never done that but I'm IT based and I learn very quickly. :)

Kind regards and thank you very much for fantastic job :)
User avatar
luk3Z
Traffic Manager
Traffic Manager
Posts: 197
Joined: 25 Dec 2005 17:42
Location: Kielce, Poland (Mars sometimes)

Re: SPI -Stockpiled Industries - Development thread

Post by luk3Z »

krohmalny wrote: 21 May 2022 19:21 Hello.

I've just run today on your GRF, tested a bit and it works fantastic. :) I have my own TTD (jgr) server where we play on FIRS and I would like to exchange it to SPI on the new map (just after the vacations).

the thing is, that we play on Day Length Factor set to "50", which means that in 24h of real life we have 2 years of progress in the game - so we play on one map for few months. We also use map size of 2048x4096 and length of trains of 15 blocks (29 modern oil wagons).

The problem with SPI in this configuration is, that (set all the production in settings to max) max production of mentioned oil is around 270k per month. In these settings it should be at least 1M to 5M to make our map playable.

So I wanted to ask you if there is easy way, to enlarge the production, for example, 10 times to the current one, so we can achieve 2.7M per month? I may be able to do it myself to not waste your time, if you just give me a hint how to do that. I never done that but I'm IT based and I learn very quickly. :)

Kind regards and thank you very much for fantastic job :)
JGRPP only:
Did you try to change Industry cargo generation factor (max is x32) ? Change DLF to 32 and check if it is good 1:1 or not. I've not played JGRPP yet.
In the settings window search for string "factor". These changes need some tests.
Find new graphics easier:
GRFCrawler -> http://grfcrawler.tt-forums.net
BaNaNaS -> https://bananas.openttd.org/
32 bit gfx in OTTD (32bpp) -> https://wiki.openttd.org/en/Community/N ... 20graphics
TTDPatch 2.6 -> viewtopic.php?f=19&t=67694
How to subtract tax from income (workaround) -> viewtopic.php?t=89763&start=20
How to ban distance from income -> Simple Cargo Decay Override
krohmalny
Engineer
Engineer
Posts: 12
Joined: 05 Mar 2022 10:58
Contact:

Re: SPI -Stockpiled Industries - Development thread

Post by krohmalny »

luk3Z wrote: 21 May 2022 20:52
krohmalny wrote: 21 May 2022 19:21 Hello.

I've just run today on your GRF, tested a bit and it works fantastic. :) I have my own TTD (jgr) server where we play on FIRS and I would like to exchange it to SPI on the new map (just after the vacations).

the thing is, that we play on Day Length Factor set to "50", which means that in 24h of real life we have 2 years of progress in the game - so we play on one map for few months. We also use map size of 2048x4096 and length of trains of 15 blocks (29 modern oil wagons).

The problem with SPI in this configuration is, that (set all the production in settings to max) max production of mentioned oil is around 270k per month. In these settings it should be at least 1M to 5M to make our map playable.

So I wanted to ask you if there is easy way, to enlarge the production, for example, 10 times to the current one, so we can achieve 2.7M per month? I may be able to do it myself to not waste your time, if you just give me a hint how to do that. I never done that but I'm IT based and I learn very quickly. :)

Kind regards and thank you very much for fantastic job :)
JGRPP only:
Did you try to change Industry cargo generation factor (max is x32) ? Change DLF to 32 and check if it is good 1:1 or not. I've not played JGRPP yet.
In the settings window search for string "factor". These changes need some tests.
THANKS!!!!!

I was not aware of this option (I always go through all the options before map creation so I assume I just forgot about this feature). It worked as I wanted, depending on short testing that I've done now, after few beers. :) But now I have like 5M of oil production on test save and that absolutely works for me. :)
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SPI -Stockpiled Industries - Development thread

Post by 3iff »

And I thought 270k per month was a lot...

Glad you have found a solution to your issue. Hope you're enjoying SPI on your server.
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Google [Bot], le_harv and 14 guests