Higher level NFO?

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
Aegir
Tycoon
Tycoon
Posts: 2884
Joined: 09 Feb 2004 10:02
Contact:

Post by Aegir »

Actually, you know what's interesting? Jonty, WhiteHand and I are all active users of GRFMaker, we're all under 18, and we all have zero to minimal programming experiance. Okay, I have a bit more than 'minimal', but anyways, it again shows, using GRFMaker isn't _hard_, but it isn't trivial.

Creating grf files is never (In my oppinion) going to get to the point where it's just 'push a few buttons and ZOMG! ITS TEH .GRF FILE', It's just something you have to put a bit of effort into learning.
Currently working under the name 'reldred' on Github, and Discord.
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.

14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
User avatar
Raichase
Moderizzle
Moderizzle
Posts: 11509
Joined: 15 Dec 2002 00:58
Location: Sydney, Australia. Usually at work in the underground railway station...
Contact:

Post by Raichase »

Had to split the bad part off this topic.

Can we please stick to the topic? Thanks.
Posted by Raichase. Visit my Flickr! Gallery, Blog (get a feed of everyone at once at Planet TT-Forums).
Raichase - Perfect timing, all the time: [13:37] * Now talking in #tycoon
ImageImage
Official TT-Dave Worley Fan Club
Official TT-Andel-in-a-pink-hat Fan Club
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Post by michael blunck »

Anyhow. First step would be to write a specification. BNF anyone?

Then the real discussion may be started. 8)

regards
Michael
Image
User avatar
Ronstar
Traffic Manager
Traffic Manager
Posts: 188
Joined: 29 Oct 2003 01:11
Location: Sheffield, UK

Post by Ronstar »

Just some thoughts from someone who used to be a coder...

The problem I found with the NFO was not all the tedious things you had to make correct, but more the rapid expansion in things that could be done with the code with little or no explanation as to how it works or what function it serves.

I was getting by okay with simple stuff like new vehicles, wagon over-rides, partial loading graphics, rear-vehicle looking different, etc., but suddenly there came a burst of a whole new bunch of things.

What, in essence, seemed to strike me is that there was basically an 'in-crowd' of coders who were trying to do a lot of things inside the code that was impossible, and the developers responded by adding it in. Which is fine... Except only really the developers who'd implemented it and the in-crowd who'd ask for it knew what it was all about.

In the end, I had enough stuff to get done in my life without learning the nuances of a proto language that ultimately only existed to tweak a single game from years back.

I'd be quite interested in re-learning NFO coding. Even now after nearly two years I can look at my old code and know how it worked and what it did. But there's very little by way of demonstration to help people ease into the ever expanding functions. Just descriptions on syntax... For things which serve *what* purpose exactly?

Ronnie
Any TT, TTD or OTTD sprites I have ever posted to this forum or elsewhere may be used as-is or in edited form free of charge for any purpose without credit in perpetuity.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Ronstar wrote:For things which serve *what* purpose exactly?
There are parts of the NFO format for which I, too, am wondering if that question has an answer. But I trust that it does, and I proceed to file those parts under "Things to deal with later".
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Patchman
Tycoon
Tycoon
Posts: 7575
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post by Patchman »

There are several things that I added because they were cool, easy to do and might potentially be useful (like procedure calls), but for which I didn't see an immediate use.

Still, most things do get used eventually... but you're right, most of the specs describe how things work, not what they're useful for. But I'm not in a position to fix that, since I only make sure they work as advertised, making them useful is up to the grf coders...
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
RK
Transport Coordinator
Transport Coordinator
Posts: 264
Joined: 13 Oct 2003 10:43
Location: Dortmund, Germany

Post by RK »

I am sorry to digg this topic out, but I changed my opinion.
Yes, it is not that hard to work with the NFO code if you understand it. But that changed nothing to the fact, that the Code structures are unclear and hard to read when you look over it after months.
I suggest to to put an XML-layer on top. There tons of libraries available, so no parser engine is needed. It's very common, easy to learn and human readable.
Locomotion uses it as well. OK, NFO is more powerful, but XML is very flexible.

just my 2¢
User avatar
Red*Star
Transport Coordinator
Transport Coordinator
Posts: 355
Joined: 12 Nov 2005 19:46
Location: Germany
Contact:

Post by Red*Star »

I think the major problem with nfo (as far as I've understood it so far) is the lack of re-usability.
If you program with a high-level programming language, especially object-oriented, you can divide your project in many many kind and smart pieces (in OO that are the classes), that may be re-used in other projects or even the same project at another point, which increases efficiency (you "don't have to invent the wheel again and again").

The only question is how to implement something like this for nfo language. I have had the idea of a "compiler" that converts directly from a high level nfo language to grf files - or maybe a two-step-compiler: High level -> nfo text file -> grf file (where the last step is done by the already existing grfcodec).

The following was a very rough and quick mockup of a possible description language made by me in the beginning of this year. I neither know if it's useful, nor do I know if it really fulfills my own specification - as stated above: 'reusability' - but I nevertheless will put it here, maybe it inspires someone to overthink the problem more in detail, or at least it shows that a framework set on top of nfo does not make sense at all.

Code: Select all

// this is a comment, it will be ignored on compiling

name
	"my set"
description
	"my desc"
grfid
	"TW" & 0x0305
spritelist
	myfirstsprite = sprite(
			"sprites/train.pcx",
			pos(98, 8),
			compressed,
			size(18, 8),
			relative(-3, -10) )
	mysecondsprite = sprite(
			... )
	// this list could be autogenerated by a program that checks the pcx
	// file for "blue boxes" and creates proper sprite definitions

spritesets
	mygreatloco = set( nameofsprite1, ..., nameofspriteN )
actions
	mylocomotive = create_rail_vehicle()
	mybus = create_road_vehicle()
	myship = create_ship()
	myboeing747 = create_plane()
	mystation = create_station()
	mygoldengatebridge = create_bridge()
	myhomesweethome = create_house()
	myindustry = create_industry()
	myufo = create_object()
	
	mycargo = create_cargo()
	
	mylocomotive.add_sprites(mygreatloco)
	mylocomotive.set_props(weight, power, maxvelocity, color, ...)

	loco1 = mylocomotive.clone()
	loco2 = mylocomotive.clone()

	loco1.set_velocity(x)
	loco2.set_velocity(y)


	// this is how a callback could be implemented:
	if ( simulation.get_year > 1950 )
		mylocomotive.use_sprites(mygreatlocowithRedColor)
	else
		mylocomotive.use_sprites(...)
	etc....
	
	
	// how to change game internal variables:
	myvars = new global_variables()
	if ( simulation.get_year > 1950 )
		game.use(myvars)
	else
		...

        // or maybe instead:
	global_variables.inflation.set(100%)	// set a hyperinflation period ^^

Like sun is to the dark soil,
so is true enlightenment to the soil's friends.

N.F.S. Grundtvig
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Post by michael blunck »

I have a strong feeling that RK digged the wrong thread.

The more interesting discussion had been here.

regards
Michael
Image
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5631
Joined: 13 Sep 2004 13:21
Location: The Moon

Post by PikkaBird »

Red*Star wrote:I think the major problem with nfo (as far as I've understood it so far) is the lack of re-usability.
I dunno, I find my nfo is pretty reusable. It's all standardised action 0s and blocks of action 2s that do particular things (and have a lot of comments to remind me exactly what they do!). When I make a new vehicle that doesn't have to do anything that I haven't done before, I copy and paste what I need, change a few values, and bosh it's done. :)
RK
Transport Coordinator
Transport Coordinator
Posts: 264
Joined: 13 Oct 2003 10:43
Location: Dortmund, Germany

Post by RK »

I don't think NFO needs an OO abstraction. That would lead into a lot work.

michael blunck wrote:I have a strong feeling that RK digged the wrong thread.

The more interesting discussion had been here.

regards
Michael
I am sorry for that. Maybe I can bring that discussion to life again.
PPT
Engineer
Engineer
Posts: 109
Joined: 31 May 2007 07:25

Post by PPT »

I don't know much about this, but expecting artists to deal with programming code doesn't seem like a good idea.

There should be templates or an overlay or something.
User avatar
chipetke
Engineer
Engineer
Posts: 40
Joined: 08 Sep 2004 00:36
Location: Hungary
Contact:

Post by chipetke »

RK wrote:...
I suggest to to put an XML-layer on top. There tons of libraries available, so no parser engine is needed. It's very common, easy to learn and human readable.
Locomotion uses it as well. OK, NFO is more powerful, but XML is very flexible. ...
Actually I made some preliminary XML specs for NFO coding, it's somewhere in my docs folder.. I can dig it up if someone is interested...
Linux is like a wigwam: no Gates, no Windows, Apache inside...
Author of Hungarian signal set Current version: 0.2b, Semaphore drawing in progress.
User avatar
Red*Star
Transport Coordinator
Transport Coordinator
Posts: 355
Joined: 12 Nov 2005 19:46
Location: Germany
Contact:

Post by Red*Star »

PikkaBird wrote:
Red*Star wrote:I think the major problem with nfo (as far as I've understood it so far) is the lack of re-usability.
I dunno, I find my nfo is pretty reusable. It's all standardised action 0s and blocks of action 2s that do particular things (and have a lot of comments to remind me exactly what they do!). When I make a new vehicle that doesn't have to do anything that I haven't done before, I copy and paste what I need, change a few values, and bosh it's done. :)
Maybe I still understand the nfo language not good enough to see where things could be reused. The only thing that got me to think about a higher-level nfo was that I regularly get confused by this assembler-like nfo language, or assembler in general :lol:, but well, that's my problem of course.
RK wrote:I don't think NFO needs an OO abstraction. That would lead into a lot work.
Of course it would be ^^. But I haven't said that it has to be explicitly OO. OO isn't even possible, because OO is a /programming/ paradigma, and nfo coding is not programming.
Like sun is to the dark soil,
so is true enlightenment to the soil's friends.

N.F.S. Grundtvig
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Red*Star wrote:and nfo coding is not programming.
And where exactly did you get that idea?
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Post by Csaboka »

Red*Star wrote:nfo coding is not programming.
I wouldn't say that. Not all of NFO coding can be called programming, but handling non-trivial action2 chains (for callbacks, variational graphics and animations) is indeed programming, I've learnt that while coding the three TTRS versions. And if you don't believe me, ask George whether coding the complex behaviour of his industries is programming or just putting some sprites together...

I agree with your main point, though. OO would be overkill for NFO.
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
User avatar
Red*Star
Transport Coordinator
Transport Coordinator
Posts: 355
Joined: 12 Nov 2005 19:46
Location: Germany
Contact:

Post by Red*Star »

DaleStan wrote:
Red*Star wrote:and nfo coding is not programming.
And where exactly did you get that idea?
Here: [1]
wikipedia wrote:Computer programming (often shortened to programming or coding) is the process of writing, testing, and maintaining the source code of computer programs.
I know, it's kinda grey area, because you also could understood [O]TTD[Patch] as a kind of "interpreter" for "the nfo language". It's not that clear a I stated above, and I does not meant to do harm to any of you coders, out there ;). I think Csaboka hit the point quite right.


[1] http://en.wikipedia.org/wiki/Computer_programming
Like sun is to the dark soil,
so is true enlightenment to the soil's friends.

N.F.S. Grundtvig
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Post by michael blunck »

Even producing something like this

Code: Select all

1001100011110010110001111110100010001101010
0100011000111110111110100100010000000010000
101001010000101010100101000101010 ...
would be filed under "programming".

regards
Michael
Image
RK
Transport Coordinator
Transport Coordinator
Posts: 264
Joined: 13 Oct 2003 10:43
Location: Dortmund, Germany

Post by RK »

NFO is my personal definition of Brainfuck. :lol:
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Post by AndersI »

I definitely prefer WhiteSpace

(Now, why didn't that url come out right??)

http://tinyurl.com/ywp8kq
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Brickblock1 and 21 guests