It is currently 28 Mar 2024, 13:08

WELCOME TO SIMUSCAPE!


Please Sign in or Register to enable all features, remove restrictions and gain additional access!
For information on how to bypass the CAPTCHA or to contact Team Simuscape, Continue Here!


Post a new topicPost a reply Page 1 of 2   [ 26 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: Action0 Global Settings
PostPosted: 27 Jul 2017, 05:45 
Browser
Browser
User avatar

Joined: 04 Mar 2012, 10:10
Posts: 229
I'm trying to jump back into NFO, and I'm afraid I've forgotten everything that I've barely learned!

I want to experiment with created a NewGRF that adds a new currency. And to do so I need to use Action0/Global Settings. I'm absolutely failing on how to write code at all.

Does any of this look right?

Code:
    0 * 4    05 00 00 00
    1 * 118    08 06 "KF" 09 01 "Simoleon Currency" 00 "Custom currency based on the video games SimCity and The Sims. Code by Kevin Fields (kamnet)." 00
    2 * 15    00 08 00 01 0A "Simoleons" 00
    3 * 6    00 08 00 01 0B 03
    4 * 6    00 08 00 01 0C ","
    5 * 6    00 08 01 01 0D "§"


Top
 Offline Profile  
 
PostPosted: 29 Jul 2017, 17:14 
Master Mentor
User avatar

Joined: 27 Feb 2012, 22:45
Posts: 1880
Location: Canada
Sorry for the delay. 'Twas the monthly "Juggling Of The Bills/Empty Larder Replenishment" event.

Something I do to help organize my nfo coding is lay out the syntax:

Code:
<Sprite-number> * <Length> 00 <Feature> <Num-props> <Num-info> <Id> (<Property <New-info>)...
breaking it up into its segments:

Code:
<Sprite-number> * <Length> 00
<Feature>
<Num-props>
<Num-info>
<Id>
(<Property <New-info>)...

Everything looks good, except for property 0A:
"This property allows changing currency names that are displayed in the Currency drop-down in the Game Options window. This property is a textID, and if you need to supply your own text, it must be a DCxx one."
You will need an Action4 to define the text and then reference the Action4 <offset> in your Action0.
Code:
2 * 7    00 08 00 01 0A DC 00


Let me know how this works out. :)

_________________
Visit SimuSchool - Tutorials, Questions and Answers
TTDPatch Nightlies Downloads are back
Thrive


Top
 Offline Profile  
 
PostPosted: 29 Jul 2017, 23:35 
Browser
Browser
User avatar

Joined: 04 Mar 2012, 10:10
Posts: 229
wallyweb wrote:
You will need an Action4 to define the text and then reference the Action4 <offset> in your Action0.


Ah. The wiki doesn't explain that sufficiently. Okay, so adding my action 4, I get this error:

//!!Error (44): Invalid feature byte.
2 * 16 04 48 01 02 DC 00 "Simoleons" 00

Feature byte 48 is to change original strings, which I'm guessing is what I need to change since the currency isn't any of the other listed features (vehicles, houses, objects, etc.). What did I miss?


Top
 Offline Profile  
 
PostPosted: 30 Jul 2017, 01:19 
Master Mentor
User avatar

Joined: 27 Feb 2012, 22:45
Posts: 1880
Location: Canada
Remove DC from your Action4.
Also, I goofed in the Actiion0.
The offset needs to be in little endian, so use 00 DC instead of DC 00.

Now we have another issue, this with feature 48 text IDs:

Quote:
to change/translate TTD strings using action4 feature 48. (This is not supported by OpenTTD, nor will it ever.)

If the changes I noted above do not work, this is why. :cry:

_________________
Visit SimuSchool - Tutorials, Questions and Answers
TTDPatch Nightlies Downloads are back
Thrive


Top
 Offline Profile  
 
PostPosted: 30 Jul 2017, 01:49 
Browser
Browser
User avatar

Joined: 04 Mar 2012, 10:10
Posts: 229
wallyweb wrote:
Remove DC from your Action4.


Nforenum is still giving an error of "Invalid feature byte" on this line.


Top
 Offline Profile  
 
PostPosted: 30 Jul 2017, 05:35 
Master Mentor
User avatar

Joined: 27 Feb 2012, 22:45
Posts: 1880
Location: Canada
OK ... nforenum errors are occasionally safe to ignore.

Here's another change, this time to the <grf-id> value in your Action8. Change it from 06 to 08.

and some changes to your Action4:

Code:
2 * 16 //<Sprite-number> * <Length>
 04
 48 //<feature>
 FF //<language-id> FF covers all languages.
 01 //<num-ent> You only have one entry
 00 DC //<offset> My bad again. The DC goes back in, but in little endian.
 "Simoleons" 00 //<text>


So now you should have
Code:
2 * 16 04 48 FF 01 00 DC "Simoleons" 00


If that error 44 is still there, encode it anyways and test the GRF in game.

_________________
Visit SimuSchool - Tutorials, Questions and Answers
TTDPatch Nightlies Downloads are back
Thrive


Top
 Offline Profile  
 
PostPosted: 30 Jul 2017, 05:54 
Browser
Browser
User avatar

Joined: 04 Mar 2012, 10:10
Posts: 229
wallyweb wrote:
Here's another change, this time to the <grf-id> value in your Action8. Change it from 06 to 08.


I wondered if I should be using a newer NFO version. But now I gotta go download and install the latest versions of grfcodec and nforenum. LOL. Be right back.


Top
 Offline Profile  
 
PostPosted: 01 Aug 2017, 05:25 
Browser
Browser
User avatar

Joined: 04 Mar 2012, 10:10
Posts: 229
Good news! This compiles clean now!

Code:
// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Escapes: 2+ 2- 2< 2> 2u< 2u> 2/ 2% 2u/ 2u% 2* 2& 2| 2^ 2sto = 2s 2rst = 2r 2psto 2ror = 2rot 2cmp 2ucmp 2<< 2u>> 2>>
// Escapes: 71 70 7= 7! 7< 7> 7G 7g 7gG 7GG 7gg 7c 7C
// Escapes: D= = DR D+ = DF D- = DC Du* = DM D* = DnF Du<< = DnC D<< = DO D& D| Du/ D/ Du% D%
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
    0 * 4    06 00 00 00
    1 * 16    14 "CINFO"
                 "BPALS" 01 00 "A"
                 00
             00

    2 * 118    08 07 "KF" 09 01 "Simoleon Currency" 00 "Custom currency based on the video games SimCity and The Sims. Code by Kevin Fields (kamnet)." 00

    // Let's name our currency
    3 * 22    04 48 FF 01 00 DC "Simoleons (SIM)" 00

   // Feature 0A: Reference currency name here
    4 * 8    00 08 01 01 00 0A \wxDC00

    // Feature 0C: Set the value separator
    5 * 7    00 08 01 01 00 0C ","

    // Feature 0D: set the currency symbol as §
    6 * 7    00 08 01 01 00 0D 15


Bad news, I get the following error when loaded in a game: "A fatal NewGRF error has occurred: Read past pseudo-sprite (sprite 5)."

Now when setting the symbol as "§" nforenum changed that from "§" to 15. So I'm assuming I screwed something up?


Top
 Offline Profile  
 
PostPosted: 01 Aug 2017, 05:30 
Browser
Browser
User avatar

Joined: 04 Mar 2012, 10:10
Posts: 229
I've tried changing the symbol to "%" as well. Still getting an error.


Top
 Offline Profile  
 
PostPosted: 01 Aug 2017, 06:41 
Master Mentor
User avatar

Joined: 27 Feb 2012, 22:45
Posts: 1880
Location: Canada
Code:
    // Feature 0C: Set the value separator
    5 * 7    00 08 01 01 00 0C ","

Drop the ",". You only need the hex.
You need to use the hex value for the symbols.
2E for "." or 2C for ","

<Sprite-number> * <Length> 00
08 // <Feature>
01 // <Num-props>
01 // <Num-info>
00 // <Id>
0C // (<Property
xx XX // <New-info>)... This is a word value (W). In little endian xx = Low byte XX = High byte.

The low byte of this word specifies the thousands separator to be used for this currency ( usually dot "." or comma ","). The high byte should be zero if the currency symbol should be in front of the number ($123,456) and should be 1 if the currency symbol should be shown after the number (123,456$). The symbol placement can be overridden by the TTDPatch settings.

_________________
Visit SimuSchool - Tutorials, Questions and Answers
TTDPatch Nightlies Downloads are back
Thrive


Top
 Offline Profile  
 
PostPosted: 01 Aug 2017, 08:48 
Browser
Browser
User avatar

Joined: 04 Mar 2012, 10:10
Posts: 229
Hm. Even using hex, nforenum likes to change it back to ",". Still, converting it to the high and low bytes for both 0C and 0D fixed it. It compiles clean. It loads without errors.

Doesn't work at all. Custom name doesn't show up in list of currencies, names and symbols do not show.

MEH. :x


Top
 Offline Profile  
 
PostPosted: 01 Aug 2017, 13:34 
Master Mentor
User avatar

Joined: 27 Feb 2012, 22:45
Posts: 1880
Location: Canada
ECHO wrote:
MEH. :x

Ok. I'll have to dig into this a little deeper. I have a busy real life day ahead of me so it might be tomorrow before I can get into this. Stay tuned.

_________________
Visit SimuSchool - Tutorials, Questions and Answers
TTDPatch Nightlies Downloads are back
Thrive


Top
 Offline Profile  
 
PostPosted: 01 Aug 2017, 16:03 
Browser
Browser
User avatar

Joined: 04 Mar 2012, 10:10
Posts: 229
wallyweb wrote:
ECHO wrote:
MEH. :x

Ok. I'll have to dig into this a little deeper. I have a busy real life day ahead of me so it might be tomorrow before I can get into this. Stay tuned.


No worries, old friend! We each take care of our business! :)


Top
 Offline Profile  
 
PostPosted: 07 Aug 2017, 01:22 
Browser
Browser
User avatar

Joined: 04 Mar 2012, 10:10
Posts: 229
Here's the current code, compiles clean but doesn't work:
Code:
// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Escapes: 2+ 2- 2< 2> 2u< 2u> 2/ 2% 2u/ 2u% 2* 2& 2| 2^ 2sto = 2s 2rst = 2r 2psto 2ror = 2rot 2cmp 2ucmp 2<< 2u>> 2>>
// Escapes: 71 70 7= 7! 7< 7> 7G 7g 7gG 7GG 7gg 7c 7C
// Escapes: D= = DR D+ = DF D- = DC Du* = DM D* = DnF Du<< = DnC D<< = DO D& D| Du/ D/ Du% D%
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
    0 * 4    06 00 00 00
    1 * 16    14 "CINFO"
                 "BPALS" 01 00 "A"
                 00
             00

    2 * 121    08 07 "KF" 09 01 "Simoleon Currency" 00 "V2 Custom currency based on the video games SimCity and The Sims. Code by Kevin Fields (kamnet)." 00

    // Let's name our currency
    3 * 22    04 48 FF 01 00 DC "Simoleons (SIM)" 00

   // Feature 0A: Reference currency name here
    4 * 8    00 08 01 01 00 0A \wxDC00

    // Feature 0C: Set the value separator
    5 * 8    00 08 01 01 00 0C "," 00

    // Feature 0D: set the currency symbol as ???
    6 * 10    00 08 01 01 00 0D "J" 00 00 00


Top
 Offline Profile  
 
PostPosted: 07 Aug 2017, 11:41 
Master Mentor
User avatar

Joined: 27 Feb 2012, 22:45
Posts: 1880
Location: Canada
kamnet wrote:
Here's the current code, compiles clean but doesn't work:
I'm having a thought ... Do you have a working TTDPatch install? If yes, test it there.

_________________
Visit SimuSchool - Tutorials, Questions and Answers
TTDPatch Nightlies Downloads are back
Thrive


Top
 Offline Profile  
 
PostPosted: 09 Aug 2017, 01:35 
Browser
Browser
User avatar

Joined: 04 Mar 2012, 10:10
Posts: 229
wallyweb wrote:
kamnet wrote:
Here's the current code, compiles clean but doesn't work:
I'm having a thought ... Do you have a working TTDPatch install? If yes, test it there.


No, I don't have TTDPatch or even TTD proper.


Top
 Offline Profile  
 
PostPosted: 09 Aug 2017, 04:07 
Master Mentor
User avatar

Joined: 27 Feb 2012, 22:45
Posts: 1880
Location: Canada
kamnet wrote:
wallyweb wrote:
kamnet wrote:
Here's the current code, compiles clean but doesn't work:
I'm having a thought ... Do you have a working TTDPatch install? If yes, test it there.


No, I don't have TTDPatch or even TTD proper.
Not a problem. Today I just finished migrating from my old PC to a not-so-old-but-somewhat-faster PC. Tomorrow I will compile your code and give it a run. 8-)

_________________
Visit SimuSchool - Tutorials, Questions and Answers
TTDPatch Nightlies Downloads are back
Thrive


Top
 Offline Profile  
 
PostPosted: 14 Aug 2017, 08:37 
Master Mentor
User avatar

Joined: 27 Feb 2012, 22:45
Posts: 1880
Location: Canada
Partial good news ... I got the name working in both TTDP and OTTD.
Question ...
The game default is to do calculations in pounds. 100,000 pounds = US$200,000. This is set with property 0B. Do you want the SIM 1 for 1 to the pound? That would be the easiest.

_________________
Visit SimuSchool - Tutorials, Questions and Answers
TTDPatch Nightlies Downloads are back
Thrive


Top
 Offline Profile  
 
PostPosted: 14 Aug 2017, 08:58 
Browser
Browser
User avatar

Joined: 04 Mar 2012, 10:10
Posts: 229
wallyweb wrote:
Partial good news ... I got the name working in both TTDP and OTTD.
Question ...
The game default is to do calculations in pounds. 100,000 pounds = US$200,000. This is set with property 0B. Do you want the SIM 1 for 1 to the pound? That would be the easiest.


My intent with this is to not only define new names but currency rates as well. I actually want to push the specs to see how flexible it is.


Top
 Offline Profile  
 
PostPosted: 14 Aug 2017, 13:02 
Master Mentor
User avatar

Joined: 27 Feb 2012, 22:45
Posts: 1880
Location: Canada
kamnet wrote:
My intent with this is to not only define new names but currency rates as well. I actually want to push the specs to see how flexible it is.
OK ... I'll be doing some experimenting. Seeing as how the pound is the standard, I will not be touching that one.
GRFSpecs wrote:
TTD always uses British pounds for internal calculations.
This might take a while.

_________________
Visit SimuSchool - Tutorials, Questions and Answers
TTDPatch Nightlies Downloads are back
Thrive


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 2   [ 26 posts ]
Go to page 1, 2  Next


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


Status SimuscapeTerms of UseAbout Simuscape

Design by SAC © 2012-2015, Sweden • Powered by phpBB • Based on twilightBB by Daniel St. Jules