My first Newgrf: Enable power stations to close
Moderator: Graphics Moderators
My first Newgrf: Enable power stations to close
Hello
I have for a long time been somewhat annoyed over power stations not closing after not being served for a long time, causing a map to have a lot of power stations.
After reading this thread, and frosch's manual industries, I decided to try to make something in newgrf to make a power station behave the same way as other similar industries (like factory or steel mill).
I have been using a GRF tool from this site: http://www.otenko.com/grf/ to make this grf. Since this is my first try for a GRF I would like to have some comments to what I have done.
I have changed the Industry production flag (0B) in Action0 to 4, making the power station a processing industry, but to prevent every power station disapear I had to make it produce goods (not the most realistic, but easy to do). To prevent it from making a lot of goods, I also added property 1C with value 00200000. This value did however not work as I expected. From the formula from the TTDPatch Wiki, I would expect 12 items of goods from 100 tons of coal, but I get something around 30 items of goods. Any ideas? (0020h = 32d, output=input*32/256 => 100*32/256=12,5, or am I missing something?)
I have tested this grf with 0.6.3 and r14648, and it seems to be working as intended.
I consider the side effect of having power stations to produce goods is OK, but it might be possible to add a new cargo "energy" to avoid it, but hey, this is my first try!
And the last question:
Is this something that is good enough to add to grfcrawler?
I have for a long time been somewhat annoyed over power stations not closing after not being served for a long time, causing a map to have a lot of power stations.
After reading this thread, and frosch's manual industries, I decided to try to make something in newgrf to make a power station behave the same way as other similar industries (like factory or steel mill).
I have been using a GRF tool from this site: http://www.otenko.com/grf/ to make this grf. Since this is my first try for a GRF I would like to have some comments to what I have done.
I have changed the Industry production flag (0B) in Action0 to 4, making the power station a processing industry, but to prevent every power station disapear I had to make it produce goods (not the most realistic, but easy to do). To prevent it from making a lot of goods, I also added property 1C with value 00200000. This value did however not work as I expected. From the formula from the TTDPatch Wiki, I would expect 12 items of goods from 100 tons of coal, but I get something around 30 items of goods. Any ideas? (0020h = 32d, output=input*32/256 => 100*32/256=12,5, or am I missing something?)
I have tested this grf with 0.6.3 and r14648, and it seems to be working as intended.
I consider the side effect of having power stations to produce goods is OK, but it might be possible to add a new cargo "energy" to avoid it, but hey, this is my first try!
And the last question:
Is this something that is good enough to add to grfcrawler?
- Attachments
-
- EnablePowerStationsToClose.zip
- (8.09 KiB) Downloaded 157 times
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: My first Newgrf: Enable power stations to close
That wouldn´t have been needed.esel wrote:[...] I had to make it produce goods.
regards
Michael
Re: My first Newgrf: Enable power stations to close
Do you care to elaborate?
When I try without producing goods, power stations closes down even if they are serviced.
When I try without producing goods, power stations closes down even if they are serviced.
Re: My first Newgrf: Enable power stations to close
Cool, goods from power stations!
It may need some more work and testing, but I think the final product will be worthy of a place on GRFcrawler.
It may need some more work and testing, but I think the final product will be worthy of a place on GRFcrawler.
Re: My first Newgrf: Enable power stations to close
Not your fault One bug wrt. reading the property from the newgrf is fixed in r14696.esel wrote:Any ideas? (0020h = 32d, output=input*32/256 => 100*32/256=12,5, or am I missing something?)
But there is another problem. When using gradual loading, vehicles only transfer very few cargo to the industry in one go, causing the above computation to be always zero
Without gradual loading it is also only slightly better.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
- andythenorth
- Tycoon
- Posts: 5657
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: My first Newgrf: Enable power stations to close
Hi Esel,esel wrote:Hello
I have for a long time been somewhat annoyed over power stations not closing after not being served for a long time, causing a map to have a lot of power stations.
I've been working on similar code for an industry chain grf I am creating. I don't have it finished yet, but based on my tests, I think it will work. I am using the production callback: http://wiki.ttdpatch.net/tiki-index.php ... Industries
If it works, my code will:
- allow the power station to receive coal
- won't produce any cargo
- will show text in the industry window. Text will change depending how much coal is waiting to be processed. If no cargo is waiting, it will show 'Supply coal to generate electricity'. If cargo is waiting, it will show 'Generating electricity'.
- The industry will close if no cargo is supplied for n months (probably about 18 months, but I need to test it). Industry window text will indicate how many months remain before the industry will close.
I code directly in NFO and use grf-codec to encode the grf. I'd recommend working directly in NFO as you seem to understand the basics.
I'm not planning to work on this code today, but I'll post some NFO source here when I have it working.
cheers,
Andy
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Re: My first Newgrf: Enable power stations to close
If you make a reply like that you leave people with the impression that you know the answer. It's considered polite to make a reply like you did and give the answer at the same time. Right now, your post is as valuable as any random off topic post.michael blunck wrote:That wouldn´t have been needed.esel wrote:[...] I had to make it produce goods.
regards
Michael
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: My first Newgrf: Enable power stations to close
No, wrong.Hyronymus wrote:If you make a reply like that you leave people with the impression that you know the answer. It's considered polite to make a reply like you did and give the answer at the same time. Right now, your post is as valuable as any random off topic post.michael blunck wrote:That wouldn´t have been needed.esel wrote:[...] I had to make it produce goods.
regards
Michael
Apparently the OP was under the false impression that his goal (modifying the power plant to be closed if not delivering any coal during xx months/years) wouldn´t be possible without producing some cargo. By my post I´ve already corrected this false assumption.
Indeed it´s quite easy to achieve this, and I´d have answered his question
in any way, now that he´s asking for more information.esel wrote:Do you care to elaborate?
As usual, the answer can be found by reading the TTDPatch Wiki, newgrf specs section. Meanwhile andythenorth has offered to post some code snippets, so I´ll leave this to him.
Don´t interpret my posts in a false way, even if you´re speaking as a moderator, or was this your private opinion?
regards
Michael
Re: My first Newgrf: Enable power stations to close
Sometimes my private opinion is the same as that from my moderator character. Maybe that has something to do with them being one person, but I'm not quite sure that's indeed the underlying reason.
In the societies I live in it's considered impolite to correct people's (supposed) false assumptions but not helping them any further. It's also considered annoying. Just imagine how it would be if your false assumptions were corrected all the time but noone ever gave you a clue on how to move on.
In the societies I live in it's considered impolite to correct people's (supposed) false assumptions but not helping them any further. It's also considered annoying. Just imagine how it would be if your false assumptions were corrected all the time but noone ever gave you a clue on how to move on.
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: My first Newgrf: Enable power stations to close
Oh please, spare me your moot reflections. I´ve been helping people with coding and drawing "problems" on this forums since a couple of years, and I´ll stick to my method. I.e., I usually don´t post a complete program if there´s no call for it. I rather work by "gradual increasing", giving people the chance to achieve own progress.Hyronymus wrote: [...] In the societies I live in it's considered impolite to correct people's (supposed) false assumptions but not helping them any further. It's also considered annoying. Just imagine how it would be if your false assumptions were corrected all the time but noone ever gave you a clue on how to move on.
Don´t you have something other to do, today?[*]
regards
Michael
[*] @moderators: this is a polite question, not an insulting.
EOD
Re: My first Newgrf: Enable power stations to close
Dang, moot reflections 'r' me . Sorry for stepping on the toes of such a good helper, it's something I overlooked for years.
Back to drinking coffee.
Back to drinking coffee.
Re: My first Newgrf: Enable power stations to close
@esel: Try your grf again in next nightly
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Re: My first Newgrf: Enable power stations to close
frosch: I will try that after I am done decorating for xmas..
Who is online
Users browsing this forum: Google [Bot] and 2 guests