Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Oct 24, 2018 6:11 am

All times are UTC




Post new topic  Reply to topic  [ 153 posts ]  Go to page Previous 14 5 6 7 8
Author Message
PostPosted: Fri Jan 19, 2018 10:40 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Jan 18, 2014 6:10 pm
Posts: 1083
Is there any easy check of the nearby tile object class?
If I understand correctly, nearby_tile_object_type gives ID of particular object, whereas nearby_tile_class is true if any object exist here.
How to check if nearby tile contain any object from given object class?

_________________
My experimental openTTD server: 149.156.194.203:3979 non-standard client, now testing: JGRPP http://tiny.pl/ggnch
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, preindustrial houses, wired, ECS industry extension.
Addicted to freeciv longturn.


Top
   
PostPosted: Thu Mar 01, 2018 5:35 pm 
Offline
Engineer
Engineer

Joined: Sat Feb 18, 2017 5:47 pm
Posts: 116
I'm atm creating a RVs set, which has RVs, that can be refitted to use trailers.
So the RVs can run either without a trailer, or with at least one trailer.
The latter requires the RV to be an articulated RV.

Now the question: Is there a possibility, that the RV runs as un-articulated RV, when no trailer is attached?

_________________
GRFs for NotRoadTypes: Country Roads | Supplemental Unsurfaced Road Vehicle Set


Top
   
PostPosted: Sun Apr 01, 2018 12:41 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Sun Feb 21, 2010 12:15 am
Posts: 1031
Location: Fitzroy North - 96
Hi all,

I am adding a truck with a long (9/8) trailer to my RV set, which I am coding as 3*3/8, with special curve sprites to appear rigid in corners. Rather than have the cargo loading sprites show up as gradually filling up from front to back, I want to define a specific effect: each segment gets one cargo sprite, in increments of 20% loads, then each gets a 2nd sprite only after the first 'row' is full. I would know how to do this if only there were variables for cargo_count and cargo_capacity that applied to the whole consist rather than just the vehicle part in question. is such a thing possible in nml?
Code:
switch (FEAT_ROADVEHS, SELF, car_top_front, (((cargo_count)/(cargo_capacity))*100) ){
    0..20:      spriteset_x_null;
    default:    car_top_load;
}
switch (FEAT_ROADVEHS, SELF, car_top_mid, (((cargo_count)/(cargo_capacity))*100) ){
    0..40:      spriteset_x_null;
    default:    car_top_load;
}
switch (FEAT_ROADVEHS, SELF, car_top_end, (((cargo_count)/(cargo_capacity))*100) ){
    0..60:      spriteset_x_null;
    default:    car_top_load;
}

where cargo_count etc is actually something like cargo_count_consist and cargo_capacity_consist, or some other variable that is just 'total load percentage of whole vehicle'

Separately, I have a very dumb question about other_veh_curve_info. I want to check the curvature relative to the segment two units ahead, rather than just next or previous. Other_veh_curve_info does exactly what I want, but I don't know where I put the offset argument...

I assume it would be something like this?:
Code:
switch (FEAT_ROADVEHS, SELF, truck_low_mid, other_veh_curve_info, -2 ){
    -1:         truck_low_l1;
    0:          truck_low_0;
    1:          truck_low_r1;
    default:    truck_low_0;
}

_________________
Image
Trolleybi! Trucks and Buses -- Docklands -- Unspooled -- MLSS


Top
   
PostPosted: Sun Apr 01, 2018 12:23 pm 
Offline
Director
Director
User avatar

Joined: Mon Apr 17, 2017 4:52 pm
Posts: 620
Location: Western Ile-de-France Region
For the first part I guess you could use parent in the switch, not sure about the second part


Top
   
PostPosted: Sun Apr 01, 2018 2:51 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sun Feb 21, 2010 12:15 am
Posts: 1031
Location: Fitzroy North - 96
I believe I will use PARENT for now - it will mean that the truck 'cab' will have to have all of the cargo capacity, but should be fine

_________________
Image
Trolleybi! Trucks and Buses -- Docklands -- Unspooled -- MLSS


Top
   
PostPosted: Sun Apr 01, 2018 5:04 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Jan 18, 2014 6:10 pm
Posts: 1083
How often running costs callback is calculated?
I want to make these costs depending on vehicle load, but I'm afraid that if it would decrease overall computer performance...

_________________
My experimental openTTD server: 149.156.194.203:3979 non-standard client, now testing: JGRPP http://tiny.pl/ggnch
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, preindustrial houses, wired, ECS industry extension.
Addicted to freeciv longturn.


Top
   
PostPosted: Sun Apr 01, 2018 5:25 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sun Feb 21, 2010 12:15 am
Posts: 1031
Location: Fitzroy North - 96
supermop wrote:

Separately, I have a very dumb question about other_veh_curve_info. I want to check the curvature relative to the segment two units ahead, rather than just next or previous. Other_veh_curve_info does exactly what I want, but I don't know where I put the offset argument...

I assume it would be something like this?:
Code:
switch (FEAT_ROADVEHS, SELF, truck_low_mid, other_veh_curve_info, -2 ){
    -1:         truck_low_l1;
    0:          truck_low_0;
    1:          truck_low_r1;
    default:    truck_low_0;
}


Ok that doesn't work - NMLC gives the error "ERROR: "moprv65.nml", line 31617: Unrecognized identifier 'other_veh_curve_info' encountered"

_________________
Image
Trolleybi! Trucks and Buses -- Docklands -- Unspooled -- MLSS


Top
   
PostPosted: Sun Apr 01, 2018 9:01 pm 
Offline
Tycoon
Tycoon

Joined: Tue Feb 22, 2011 6:34 pm
Posts: 2652
supermop wrote:
supermop wrote:

Separately, I have a very dumb question about other_veh_curve_info. I want to check the curvature relative to the segment two units ahead, rather than just next or previous. Other_veh_curve_info does exactly what I want, but I don't know where I put the offset argument...

I assume it would be something like this?:
Code:
switch (FEAT_ROADVEHS, SELF, truck_low_mid, other_veh_curve_info, -2 ){
    -1:         truck_low_l1;
    0:          truck_low_0;
    1:          truck_low_r1;
    default:    truck_low_0;
}


Ok that doesn't work - NMLC gives the error "ERROR: "moprv65.nml", line 31617: Unrecognized identifier 'other_veh_curve_info' encountered"

I can't even find something like other_veh_curve_info in the documentation. I did look in the NFO-specs, using that, it should be possible to check the curvature of any vehicle in the chain. There is some magic needed with temporary variables and stuff, you might get some inspiration from this code.

_________________
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML


Top
   
PostPosted: Sun Apr 01, 2018 9:55 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sun Feb 21, 2010 12:15 am
Posts: 1031
Location: Fitzroy North - 96
Transportman wrote:
supermop wrote:
supermop wrote:

Separately, I have a very dumb question about other_veh_curve_info. I want to check the curvature relative to the segment two units ahead, rather than just next or previous. Other_veh_curve_info does exactly what I want, but I don't know where I put the offset argument...

I assume it would be something like this?:
Code:
switch (FEAT_ROADVEHS, SELF, truck_low_mid, other_veh_curve_info, -2 ){
    -1:         truck_low_l1;
    0:          truck_low_0;
    1:          truck_low_r1;
    default:    truck_low_0;
}


Ok that doesn't work - NMLC gives the error "ERROR: "moprv65.nml", line 31617: Unrecognized identifier 'other_veh_curve_info' encountered"

I can't even find something like other_veh_curve_info in the documentation. I did look in the NFO-specs, using that, it should be possible to check the curvature of any vehicle in the chain. There is some magic needed with temporary variables and stuff, you might get some inspiration from this code.


other_veh_curve_info is found in the nml specs here: https://newgrf-specs.tt-wiki.net/wiki/N ... offset_1-0 under "Variables that require an argument".

The 'argument' I need to give is the offset to the other vehicle part, but the specs do not state how arguments for variables are defined... putting the value in ( ) after the variable gives an error, "'other_veh_curve_info' is not defined as a function.", and putting it following the variable after a comma gives "Switch-block requires 4 parameters, encountered 5"

_________________
Image
Trolleybi! Trucks and Buses -- Docklands -- Unspooled -- MLSS


Top
   
PostPosted: Mon Apr 02, 2018 1:44 am 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 7166
just posting this here for future reference:
the problem here was a misspelling, it's "curv_info", not "curve_info"

the correct syntax would be: "other_veh_curv_info(-2)"

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
PostPosted: Sat Apr 07, 2018 12:12 pm 
Offline
Engineer
Engineer
User avatar

Joined: Wed Jul 01, 2015 3:03 pm
Posts: 83
I have three questions: one are pnml files created through the compiler? Next, what is the easy way to determine spriteset offsets? Like the [x, x, y, y] offsets. I find that's the hardes part of coding, as the other ones is kinda like Java syntax. Last, why doesn't nml come with something like grfcodec which decodes grf files? It only has an encoder.


Top
   
PostPosted: Sun Apr 08, 2018 7:04 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4673
Location: home
TrainLover wrote:
I have three questions: one are pnml files created through the compiler?
No, it's the actual source code.
The compiler takes a single NML file, but if you make many similar entities, that is not very convenient. As a result, people made a file for each entity (a .pnml file), and added cpp (the C pre-processor) as pre-processing step, which can merge all those small files into 1 nml file that the compiler takes. For bonus, you also get the C macro processor in that way, for generating unique labels, and replace hard-coded numbers by a readable name etc.

TrainLover wrote:
Next, what is the easy way to determine spriteset offsets? Like the [x, x, y, y] offsets. I find that's the hardes part of coding, as the other ones is kinda like Java syntax.
No experience myself, but afaik people make graphics templates for each length vehicle, with fixed position for each view. That way, the offsets are always the same, just the name of the used graphics file changes. Figure out the offset once, and it works for all vehicles by copy/pasting that. Better, by using the macro-processor from above, or use templates from nmlc itself, the copies are generated each time, so if you ever need to change a template, everything changes along with it automagically without need to update all your pasted code.

TrainLover wrote:
Last, why doesn't nml come with something like grfcodec which decodes grf files? It only has an encoder.
grfcodec doesn't do much, it's mostly a transformation from numbers written in text (so you can edit them in an editor) to binary values. There is some minor stuff like computing a few lengths etc, but there is a simple 1-to-1 mapping between number in the input to binary value in the output. As you can imagine, doing the reverse isn't terribly difficult either then. In addition at the time when grfcodec was written, there was a need to be able to examine and modify the existing grfs, so converting back and forth between both forms was a fundamental requirement for grfcodec.

For nml, the story is different. Its aim is to simplify coding a grf, like a high-level language, much like Java which is so much simpler to write than byte-code. At the same time, the gap between nml source code and actual grf binary values has increased. Nml for example allows mostly arbitrary expressions, which doesn't exist in grf, so nml generates heaps of grf code for a single line nml. In addition, some grf code doesn't exist in nml at all. Grf action C and advanced uses of action 6 cannot be expressed in nml, there is simply no way to write down an action C in nml.
This means some grfs cannot faithfully be decoded at all to nml, since it may contain grf code that has no equivalent in nml. If you limit it to the subset that can be expressed, you've got the problem of a heap of grf code at one side, which needs to be recognized as some (unknown) lines of nml, which is far from trivial (there is no simple 1-to-1 mapping here, like in grfcodec). This is a decompiler problem, which is somewhat solvable, but a lot of work, and the results are not that good.

A second consideration is that source code is far more useful than anything decompiled and is generally readily available. For example, you get the collection of .pnml files, neatly organized in directories with all the vehicles in their templates etc, or you get a bunch of Python code with tables of properties that are easy to edit. Since most projects are open source anyway, it's far easier and with better results to just ask for the original commented source code from the author, than trying to reverse-engineer a grf.

_________________
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.


Top
   
PostPosted: Thu Apr 12, 2018 1:08 pm 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 7166
TrainLover wrote:
Next, what is the easy way to determine spriteset offsets? Like the [x, x, y, y] offsets.


it may be a bit tricky to explain by text, but i'll try:
  1. Enable NewGRF developer tools in the game
  2. Press Ctrl+B to enable showing of bounding boxes (requires NewGRF developer tools)
    (small clarification: bounding boxes have nothing to do with how big your sprites are, it's an internal method to determine what sprites should be in front)
  3. of this bounding box, there is one corner that is not visible, this is the most relevant corner
  4. use that invisible corner as the anchor point for your offsets
  5. now go to the sprite picker in the ?-Menu (requires NewGRF developer tools)
  6. there you can click on your sprite and temporarily modify the offsets until they look right
  7. put these new offsets in your grf file to make them permanent
  8. as said before, now try to make a template, so every item in your GRF uses the same offsets.

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 153 posts ]  Go to page Previous 14 5 6 7 8

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.