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?
var 80+3F in NML
Moderator: Graphics Moderators
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: var 80+3F in NML
By using that "var" statement; mentioned a zillion times over here, <searches ...> like this (accessing var 61):supermop wrote: [...] Anyone have any idea how to use this variable?
Code: Select all
switch(FEAT_TRAINS, PARENT, switch_can_attach_unit_rail, [STORE_TEMP(position_in_consist_from_end, 0x10F), var[0x61, 0, 0x0000FFFF, 0xC6]])
regards
Michael
Re: var 80+3F in NML
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.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.
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: Select all
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;
}
Code: Select all
Writing output ...[KTraceback (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
Changing the wording to more closely how I interpret the nml documentation I get something like this:
Code: Select all
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;
}
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.
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: var 80+3F in NML
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.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.
regards
Michael
Re: var 80+3F in NML
For what it's worth, this seems to work as I'd like, though the CC_RED box looks yellow in game:
Code: Select all
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;
}
Who is online
Users browsing this forum: No registered users and 6 guests