This script can build industry during gameplay, in certain square of the map.
I use such feature for real-world based scenario, thanks to the industry newgrfs which give opportunity to disable in-game random industry placement.
Instead of this, signs can be placed in scenario editor, formatted as follows, with data separated by :
Code: Select all
{label}Optional_Name:yyyy:id:range
Optional_Name is a signature displayed on the map, if industry was successfully founded (in case of log_level 3, every attempt to build is signed, log_level 1 does not sign any).
yyyy is the construction year. At the start of the game, script is trying to build all industries 50 years prior current date.
id is an industry identifier.
range is square size, within randomly chosen tile is used to found industry. 0 define tile exactly.
If industry was not founded successfully, script attempt to found it again every month, with another random tile (additionally random range is incremented).
At the beginning of new year, bunch of attempts is repeated and if industry is still not founded, is dropped from the list.
Here is example of Scenario Editor with signs ({label} was defined as >>> string): You can notice three signs, two for power stations (id = 1) and one for steel mill (id = 8 ).
(newgrf used is manpower clone of opengfx+industries, therefore you can see both of them in arctic climate)
Game started in 1918, "EC Pruszkow" was founded within first month, "EC Siekierki" will be founded later, whereas "Huta Warszawa" randomly appears near the another river bank at the beginning of 1954 (sign placement was badly chosen, but finally it succeed): The idea of randomly chosen placement (restricted to the given square) is to place industry close to its real location, but give some level of randomness,
otherwise strictly determined scenario can be boring.
Additionally such approach give opportunity to avoid obstacles like player infrastructure placed before industry scheduled placement.
Script code, including modified tilelabels library (removed bug with sign shorter than label length) is attached here: Code is rather dirty and not optimised, I'm not familiar with squirrel.
There is one known flaw: you must know industry id.
It is not a issue in case of standard industry, or newgrf industry overrides standard one, but in case of totally new industry sets (FIRS, ECS)
internal industry ids are different than those defined by newgrf (see discussion "how to use DoCommandP)
Probably, instead of industry_id, industry name (for example 'Steel Mill' instead of 8 ) should be used and queried to find appropriate id.
Any help and remarks are very appreciated.
PS. debug_level 3 is setted as default for testing purposes.