Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Dec 17, 2018 3:42 pm

All times are UTC




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
 Post subject: var 80+3F in NML
PostPosted: Fri Mar 16, 2018 4:21 pm 
Offline
Tycoon
Tycoon
User avatar

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

In discussion on IRC recently, I have been musing using a callback to vary sprites by cargo age (the amount it has decayed so far according to decay rate of whatever it has traveled in so far). The putative example is hot slag or iron from a blast furnace - that cargo sprites might show some orange fire cycle pixels when 'fresh', but fewer as it cools in transit, based on decay rate.

Andythenorth suggested that var 80+3F would be what to use, but we don't have any idea how to use this in NML (or at all for that matter).

Ideally, I'd be looking for something that could be used in a switch like "cargo_age_in_veh", which I would expect to return some value in days or ticks, so I could test for ranges 0..xx, xx..yy, etc.

Anyone have any idea how to use this variable?

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


Top
   
 Post subject: Re: var 80+3F in NML
PostPosted: Fri Mar 16, 2018 7:44 pm 
Offline
Tycoon
Tycoon

Joined: Wed Apr 27, 2005 7:09 am
Posts: 5238
supermop wrote:
[...] Anyone have any idea how to use this variable?

By using that "var" statement; mentioned a zillion times over here, <searches ...> like this (accessing var 61):

Code:
switch(FEAT_TRAINS, PARENT, switch_can_attach_unit_rail, [STORE_TEMP(position_in_consist_from_end, 0x10F), var[0x61, 0, 0x0000FFFF, 0xC6]])


Problem is it probably won´t give you the desired effect, since usually vars are heavily cached, and refreshed at weird times in recent versions of OTTD.

regards
Michael

_________________
Image


Top
   
 Post subject: Re: var 80+3F in NML
PostPosted: Tue Mar 20, 2018 2:09 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Sun Feb 21, 2010 12:15 am
Posts: 1031
Location: Fitzroy North - 96
michael blunck wrote:
Problem is it probably won´t give you the desired effect, since usually vars are heavily cached, and refreshed at weird times in recent versions of OTTD.


Well you are right - it works, but only updates when the vehicle stops or starts, or loads, or if a random switch triggers it at 32 days.

I am looking to incorporate this in a sprite stack, where the different layers each get their own recolor mapping, as outlined here: https://newgrf-specs.tt-wiki.net/wiki/N ... le_sprites

The problem is, the switches for sprite stacks that I use now only specify recoloring once, and are worded slightly differently than the specs above show. They do work perfectly for what I've used them for so far:
Code:
switch(FEAT_ROADVEHS, SELF, switch_sd4_bus_front, [
   STORE_TEMP((getbits(extra_callback_info1, 8, 8) < 1 ? CB_FLAG_MORE_SPRITES : 0) | PALETTE_USE_DEFAULT, 0x100),
   getbits(extra_callback_info1, 8, 8)
   ]) {
   0:   spriteset_sd_b_front_04;
   1:   switch_d_panto;
}


However, if I add another instance of the argument above, with incremented number and different recoloring, I get a weird python error from nmlc:
Code:
Writing output ...Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
  File "nmlc", line 6, in <module>
  File "nml\main.py", line 425, in run
  File "nml\main.py", line 170, in main
  File "nml\main.py", line 403, in nml
  File "nml\actions\action2var.py", line 93, in write
  File "nml\actions\action2var.py", line 154, in write
  File "nml\output_base.py", line 188, in print_varx
  File "nml\output_base.py", line 328, in print_dwordx
  File "nml\output_base.py", line 321, in print_dword
  File "nml\output_base.py", line 166, in prepare_dword
AssertionError

So I must be off track.

Changing the wording to more closely how I interpret the nml documentation I get something like this:
Code:
switch(FEAT_ROADVEHS, SELF, switch_pickup, [
    STORE_TEMP(CB_FLAG_MORE_SPRITES  | PALETTE_USE_DEFAULT, 0x100),
    STORE_TEMP( PALETTE_CC_BROWN, 0x100),
    getbits(extra_callback_info1, 8, 8)
    ]) {
    0:  spriteset_truck;
    1:  spritegroup_box;
    }

But that then only draws the truck in CC_BROWN (not the actual CC), and doesn't draw the second layer, the box, at all.

The documentation doesn't make it clear to me at all how I should assign a different recoloring to each layer, and I am not sure what sets might have such an example.

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


Top
   
 Post subject: Re: var 80+3F in NML
PostPosted: Tue Mar 20, 2018 6:36 am 
Offline
Tycoon
Tycoon

Joined: Wed Apr 27, 2005 7:09 am
Posts: 5238
supermop wrote:
The documentation doesn't make it clear to me at all how I should assign a different recoloring to each layer, and I am not sure what sets might have such an example.

Well, I can´t help you with an NML example. At least using different recolouring in sprite stacking works as documented in nfo/m4nfo. Here´s an example. I´ll have a go testing it with var3F.

regards
Michael

_________________
Image


Top
   
 Post subject: Re: var 80+3F in NML
PostPosted: Wed Mar 21, 2018 12:40 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sun Feb 21, 2010 12:15 am
Posts: 1031
Location: Fitzroy North - 96
For what it's worth, this seems to work as I'd like, though the CC_RED box looks yellow in game:

Code:
switch(FEAT_ROADVEHS, SELF, switch_pickup_truck, [
    STORE_TEMP( CB_FLAG_MORE_SPRITES | PALETTE_USE_DEFAULT, 0x100),
    ]) {
    default:  spriteset_pickup;
    }
switch(FEAT_ROADVEHS, SELF, switch_pickup_box_3, [
    STORE_TEMP(PALETTE_CC_RED, 0x100),
    ]) {
    default:  spritegroup_pickup_box;
    }
switch(FEAT_ROADVEHS, SELF, switch_pickup_box_2, [
    STORE_TEMP(PALETTE_CC_ORANGE, 0x100),
    ]) {
    default:  spritegroup_pickup_box;
    }
switch(FEAT_ROADVEHS, SELF, switch_pickup_box_1, [
    STORE_TEMP(PALETTE_CC_GREEN, 0x100),
    ]) {
    default:  spritegroup_pickup_box;
    }       

switch (FEAT_ROADVEHS, SELF, switch_pickup_box, var[0xBF,0,0xFF]) {
    0..4:               switch_pickup_box_1;
    5..9:               switch_pickup_box_2;
    default:            switch_pickup_box_3;
    }

switch(FEAT_ROADVEHS, SELF, switch_pickup, [
    getbits(extra_callback_info1, 8, 8)
    ]) {
    0:      switch_pickup_truck;
    1:      switch_pickup_box;
    } 

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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

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.