News:

Simutrans Forum Archive
A complete record of the old Simutrans Forum.

Shortening dat files with image-templates

Started by Leartin, January 09, 2016, 02:31:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Leartin

The following code is the image definition of one citybuilding:


BackImage[7][0][0][1][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.0
BackImage[7][0][0][0][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.0
BackImage[6][0][0][1][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.1
BackImage[6][0][0][0][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.1
BackImage[5][0][0][1][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.2
BackImage[5][0][0][0][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.2

BackImage[0][0][0][1][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.0
BackImage[0][0][0][0][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.0
BackImage[2][0][0][1][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.0
BackImage[2][0][0][0][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.0
BackImage[4][0][0][1][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.1
BackImage[4][0][0][0][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.1
BackImage[1][0][0][1][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.2
BackImage[1][0][0][0][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.2
BackImage[3][0][0][1][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.2
BackImage[3][0][0][0][0][0]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.2

BackImage[7][0][0][1][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.0
BackImage[7][0][0][0][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.0
BackImage[6][0][0][1][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.1
BackImage[6][0][0][0][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.1
BackImage[5][0][0][1][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.2
BackImage[5][0][0][0][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.2

BackImage[0][0][0][1][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.0
BackImage[0][0][0][0][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.0
BackImage[2][0][0][1][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.0
BackImage[2][0][0][0][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.0
BackImage[4][0][0][1][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.1
BackImage[4][0][0][0][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.1
BackImage[1][0][0][1][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.2
BackImage[1][0][0][0][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.2
BackImage[3][0][0][1][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.2
BackImage[3][0][0][0][0][1]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.2

BackImage[7][0][0][1][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.0
BackImage[7][0][0][0][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.0
BackImage[6][0][0][1][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.1
BackImage[6][0][0][0][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.1
BackImage[5][0][0][1][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.2
BackImage[5][0][0][0][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.2

BackImage[0][0][0][1][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.0
BackImage[0][0][0][0][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.0
BackImage[2][0][0][1][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.0
BackImage[2][0][0][0][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.0
BackImage[4][0][0][1][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.1
BackImage[4][0][0][0][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.1
BackImage[1][0][0][1][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.2
BackImage[1][0][0][0][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.2
BackImage[3][0][0][1][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.2
BackImage[3][0][0][0][0][2]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.2

BackImage[7][0][0][1][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.0
BackImage[7][0][0][0][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.0
BackImage[6][0][0][1][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.1
BackImage[6][0][0][0][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.1
BackImage[5][0][0][1][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.2
BackImage[5][0][0][0][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.2

BackImage[0][0][0][1][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.0
BackImage[0][0][0][0][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.0
BackImage[2][0][0][1][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.0
BackImage[2][0][0][0][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.0
BackImage[4][0][0][1][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.1
BackImage[4][0][0][0][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.1
BackImage[1][0][0][1][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.2
BackImage[1][0][0][0][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.2
BackImage[3][0][0][1][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.2
BackImage[3][0][0][0][0][3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.2


BackImage[7][0][0][1][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.3
BackImage[7][0][0][0][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.3
BackImage[6][0][0][1][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.4
BackImage[6][0][0][0][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.4
BackImage[5][0][0][1][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.0.5
BackImage[5][0][0][0][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1.5

BackImage[0][0][0][1][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.3
BackImage[0][0][0][0][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.3
BackImage[2][0][0][1][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.3
BackImage[2][0][0][0][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.3
BackImage[4][0][0][1][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.4
BackImage[4][0][0][0][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.4
BackImage[1][0][0][1][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.5
BackImage[1][0][0][0][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.5
BackImage[3][0][0][1][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2.5
BackImage[3][0][0][0][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3.5


Frontimage[7][0][0][0][0][0]=images/Stadtgruen_1.0.0
Frontimage[6][0][0][0][0][0]=images/Stadtgruen_1.0.1
Frontimage[5][0][0][0][0][0]=images/Stadtgruen_1.0.2
Frontimage[0][0][0][0][0][0]=images/Stadtgruen_1.0.3
Frontimage[2][0][0][0][0][0]=images/Stadtgruen_1.0.3
Frontimage[4][0][0][0][0][0]=images/Stadtgruen_1.0.4
Frontimage[1][0][0][0][0][0]=images/Stadtgruen_1.0.5
Frontimage[3][0][0][0][0][0]=images/Stadtgruen_1.0.5

Frontimage[7][0][0][0][0][1]=images/Stadtgruen_1.3.0
Frontimage[6][0][0][0][0][1]=images/Stadtgruen_1.3.1
Frontimage[5][0][0][0][0][1]=images/Stadtgruen_1.3.2
Frontimage[0][0][0][0][0][1]=images/Stadtgruen_1.3.3
Frontimage[2][0][0][0][0][1]=images/Stadtgruen_1.3.3
Frontimage[4][0][0][0][0][1]=images/Stadtgruen_1.3.4
Frontimage[1][0][0][0][0][1]=images/Stadtgruen_1.3.5
Frontimage[3][0][0][0][0][1]=images/Stadtgruen_1.3.5

Frontimage[7][0][0][0][0][2]=images/Stadtgruen_1.4.0
Frontimage[6][0][0][0][0][2]=images/Stadtgruen_1.4.1
Frontimage[5][0][0][0][0][2]=images/Stadtgruen_1.4.2
Frontimage[0][0][0][0][0][2]=images/Stadtgruen_1.4.3
Frontimage[2][0][0][0][0][2]=images/Stadtgruen_1.4.3
Frontimage[4][0][0][0][0][2]=images/Stadtgruen_1.4.4
Frontimage[1][0][0][0][0][2]=images/Stadtgruen_1.4.5
Frontimage[3][0][0][0][0][2]=images/Stadtgruen_1.4.5

Frontimage[7][0][0][0][0][3]=images/Stadtgruen_1.2.0
Frontimage[6][0][0][0][0][3]=images/Stadtgruen_1.2.1
Frontimage[5][0][0][0][0][3]=images/Stadtgruen_1.2.2
Frontimage[0][0][0][0][0][3]=images/Stadtgruen_1.2.3
Frontimage[2][0][0][0][0][3]=images/Stadtgruen_1.2.3
Frontimage[4][0][0][0][0][3]=images/Stadtgruen_1.2.4
Frontimage[1][0][0][0][0][3]=images/Stadtgruen_1.2.5
Frontimage[3][0][0][0][0][3]=images/Stadtgruen_1.2.5

Frontimage[7][0][0][0][0][4]=images/smoke_l.0.0,-2,-30
Frontimage[7][0][0][0][1][4]=images/smoke_l.0.1,-2,-30
Frontimage[7][0][0][0][2][4]=images/smoke_l.0.2,-2,-30
Frontimage[6][0][0][0][0][4]=images/smoke_l.0.0,-2,-30
Frontimage[6][0][0][0][1][4]=images/smoke_l.0.1,-2,-30
Frontimage[6][0][0][0][2][4]=images/smoke_l.0.2,-2,-30
Frontimage[5][0][0][0][0][4]=images/smoke_l.0.0,-2,-30
Frontimage[5][0][0][0][1][4]=images/smoke_l.0.1,-2,-30
Frontimage[5][0][0][0][2][4]=images/smoke_l.0.2,-2,-30
Frontimage[0][0][0][0][0][4]=images/smoke_l.0.0,-2,-30
Frontimage[0][0][0][0][1][4]=images/smoke_l.0.1,-2,-30
Frontimage[0][0][0][0][2][4]=images/smoke_l.0.2,-2,-30
Frontimage[2][0][0][0][0][4]=images/smoke_l.0.0,-2,-30
Frontimage[2][0][0][0][1][4]=images/smoke_l.0.1,-2,-30
Frontimage[2][0][0][0][2][4]=images/smoke_l.0.2,-2,-30
Frontimage[4][0][0][0][0][4]=images/smoke_l.0.0,-2,-30
Frontimage[4][0][0][0][1][4]=images/smoke_l.0.1,-2,-30
Frontimage[4][0][0][0][2][4]=images/smoke_l.0.2,-2,-30
Frontimage[1][0][0][0][0][4]=images/smoke_l.0.0,-2,-30
Frontimage[1][0][0][0][1][4]=images/smoke_l.0.1,-2,-30
Frontimage[1][0][0][0][2][4]=images/smoke_l.0.2,-2,-30
Frontimage[3][0][0][0][0][4]=images/smoke_l.0.0,-2,-30
Frontimage[3][0][0][0][1][4]=images/smoke_l.0.1,-2,-30
Frontimage[3][0][0][0][2][4]=images/smoke_l.0.2,-2,-30


It is a 1x1 citybuilding that supports 8 directions and 5 seasons.
Since the building itself does not change throughout the year, while the greenery in front does, AND the greenery is shared by other similar buildings, it is seperated in backimage (building, same image in 4 seasons) and frontimage (greenery, different images in 4 seasons but same in other buildings)
Snow is included in the backimage, but the snowy phase still uses frontimage for a smoke animation raising from the chimney. Smoke images are the same for every building, just repositioned via offset.

Such an amount of code just for one citybuilding is probably unique in that it does not happen in other paksets, but it happens quite often in pak192.comic, and will appear even more often in the future. Writing such a giant dat is easy, since you'd just replace the image names via search&replace, but if you want to change anything about the buildings parameters manually, you have to scroll through all of this, multiple times. It's just tiring.


So what I would like to be able to do is having templates for the image definitions. I'd like to write the image definitions just like above, but with placeholders, and give it a template name. The actual building would then reference said template and tell it which variables to use instead of the placeholders.
Let's imagine the long code above, but you replace "images/res/northsea/C3/1920_Backsteinexpressionismus_1" with the placeholder [[building]], "images/Stadtgruen_1" with [[greenery]], and ",-2,-30" with [[offset]]. you save it as "template1.dat"

In the actual buildings definition, you'd write
[[template1.dat; building=images/res/northsea/C3/1920_Backsteinexpressionismus_1; greenery=images/Stadtgruen_1; offset=,-2,-30]]

Upon packing, makeobj would replace this short snippet with the long one in template1.dat, and fills out the placeholder before actually packing.


My example here is especially long, but even for smaller objects it can be useful. Even a simple building that makes use of 5 seasons requires 5 images, and for that alone it could be advantagous to replace five lines with only one.
If it could be stacked, you'd be able to use [[imagepath.dat]] inside the outsourced image-definition. Thus, you could move or rename the whole image folder with ease by just replacing path written in imagepath.dat.



I understand that one could do this with a seperate program that just runs right before you pak, possibly not even a program but a script for an advanced editor. But still, with the evergrowing possibilities of image definitions, and since string manipulation should not be too hard to do, I'd really like to see it in makeobj.



PS: These citybuildings are enourmous in file size! I know the game is optimized to not load duplicate images, but could it be that makeobj is not and paks the same image several times?

Vladki

#1
Hmm, what about a template more like this:


BackImage[A][0][0][B][0][C]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2*C+B.A


This would force the png to have all rotations in one line, first line the first level, second line second level, third line again first level in next season, and so on.

However max values for A,B,C would have to be defined like:
dims=1,1,8
seasons=5
height=2


Leartin

If something like that is easier to program, I suppose it would already help a lot, but it's way less flexible.
For the example building, it would be very bad: Although 8 rotations need to be defined, there are only 6 different rotation graphics (north and south as well as east and west are the same), plus there are no changes between seasons on the building itself. Not counting height, there are currently 12 images on the actual graphics sheet for the building, with your proposal there would need to be 40.

Dwachs

Quote from: Leartin on January 09, 2016, 02:31:48 PM
PS: These citybuildings are enourmous in file size! I know the game is optimized to not load duplicate images, but could it be that makeobj is not and paks the same image several times?
Makeobj does not recognize duplicate images. Compressing the pak files afterwards should reduce filesize again.
Parsley, sage, rosemary, and maggikraut.

prissi

Simutrans recognise identical images after loading and merges them. So if you reuse the same graphics, they will be saved on the harddisk; but if the pak has the same image images, those will not consume memory nor image pointers.

Ters

Quote from: prissi on January 09, 2016, 09:54:02 PM
Simutrans recognise identical images after loading and merges them. So if you reuse the same graphics, they will be saved on the harddisk; but if the pak has the same image images, those will not consume memory nor image pointers.

Leartin wrote that he knew this. What he wanted was apparently to not save the duplicate images on the harddisk and/or that the duplicate images are only transmitted once when downloading pak files from the Internet.

Leartin

It was a side question about makeobj since the main question was about makeobj. Yes, it would be nice not to use up 2MB of space due to using the same image 4 or even 8 times, but at the same time it is just storage, nothing else. I'm sorry the topic was derailed by that careless comment, it really is mostly about how images get defined.

Maybe requested in a quicker way: Most often the same image parts defined for similar objects, so why not design a template so you only have to write the name of an accordingly aligned image file, rather then defining each image part seperately.

prissi

Since each object is stored seperately it has to be stored completely. Otherwise what would happen if people decide to mix manually objects (as many people did before)?

But the topic derailed. Due to the internal working of makobj I would prefere something like


BackImage[A][0][0][B][0][C]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2*C+B.A


or


BackImage[0-8][0][0][0-1][0][0-5]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.2*C+B.A+2


The latter is probably more flexible and even easier to implement.

Leartin

Obviously shared ressources like the smoke would need to be in every pak, I was more concerned about duplicates of the same image inside one object, like the shown object which uses .2.2 8 times due to seperation of building and greenery in 5 seasons.

I really like the second idea, since it seems you could use it multiple times in the same image definition to be more precise.
For example, the original long dat could be shortened to seven lines given that the images are arranged accordingly:
BackImage[0-1][0][0][0-1][0][0-3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1-B.A
BackImage[0-1][0][0][0-1][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3-B.A
BackImage[2-7][0][0][0-1][0][0-3]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.1-B.A-2
BackImage[2-7][0][0][0-1][0][4]=images/res/northsea/C3/1920_Backsteinexpressionismus_1.3-B.A-2
Frontimage[0-7][0][0][0][0][0-3]=images/Stadtgruen_1.B.A
Frontimage[0-7][0][0][0][0][0-3]=images/Stadtgruen_1.B.A
Frontimage[0-7][0][0][0][0-2][4]=images/smoke_l.0.B,-2,-30

Let me say, this is huge!

Explaination: Rotation 0 and 1 have the same graphic as rotation 2 and 3. thus repeating the first two lines with A-2. 1-B instead of simply B is just so you can have the roof on top of the building in the graphic, not the other way around.


Two minor things though:
I'd think the Variables should be A-F, not based on which parameter is variable, just for consistency. The variable you use for the season should not change based on whether there is a second floor or not, that could be confusing.

There ought to be a similar system for other objects which use non-number parameters, eg. vehicles which use directions.
Something like this:

EmptyImage[S;E;N;W;SW;NE;SE;NW]=image.0.A

Vladki

Perhaps those variables could have more descriptive names (rotation, season, x, y, z,...)

kierongreen

#10
Very much a proof of concept patch. Code probably messy and certainly lacking a few comments...

Syntax:
within square brackets as well as having one number you can now have ranges or several number - eg [0,1,2] or [0-2] or [0,2-4,8] etc. Only limit is that at most 255 numbers can be referenced this way for each set of square brackets.
note that more than one set of square brackets can use this, so Image[0-15][0-4] is also valid

to use these on the right hand side of the = enclose expansions in <>. Then use $0 to refer to the leftmost [] containing a range, $1 for the next and so on. For example <$0-15> or <4-$1>. Note only + and - operators are supported at this point, no brackets!

for example
Image[8-15][0][0][0-4] = image/test.<$0-8>.<$1>

A more realistic example, marker from pak128.Britain recoded to use this


#
# Ground marker for pak128
#
Obj=ground
Name=Marker
copyright=Timothy Baldock
# the front part (obtained by hang%27) for signle slopes
Image[0-8][0]=images/marker.3.<$0>
Image[9-17][0]=images/marker.4.<$0-9>
Image[18-26][0]=images/marker.5.<$0-18>

# backpart (obtained by (hang%3) + ((hang-(hang%9))/3)
Image[27-29][0]=images/marker.0.<$0-27>
Image[30-32][0]=images/marker.1.<$0-30>
Image[33-35][0]=images/marker.2.<$0-33>
Image[36-38][0]=images/marker.0.<$0-36+3>
Image[39-41][0]=images/marker.1.<$0-39+3>
Image[42-44][0]=images/marker.2.<$0-42+3>
Image[45-47][0]=images/marker.0.<$0-45+6>
Image[48-50][0]=images/marker.1.<$0-48+6>
Image[51-53][0]=images/marker.2.<$0-51+6>
--------------------


So, thoughts? Is a more complete set of operators needed?
--
Edit forgot to say limit of up to 10 expansions and 10 square brackets containing ranges on each line. Though this and 255 limit for numbers within ranges is easily extended. Also while in these examples have used expansions in coordinates section of image, nothing stopping being used in filename bit too.
--
Another edit:

What are peoples thoughts about possible boolean comparisons - e.g. instead of:

BackImage[0][0][0][0][0][0]=brick-platform-narrow.1.0
BackImage[0][0][0][0][0][1]=brick-platform-narrow-snow.1.0

having

BackImage[0][0][0][0][0][0-1]=brick-platform-narrow<$0=0?:-snow>.1.0

? Is this going a step too far in obfuscation? Does saving a few lines in a dat file mean that much?

kierongreen

#11
Tidied version (no additional functionality)... (edit, more tidying)

Leartin

Quote from: kierongreen on February 27, 2016, 10:18:09 PM
What are peoples thoughts about possible boolean comparisons - e.g. instead of:

BackImage[0][0][0][0][0][0]=brick-platform-narrow.1.0
BackImage[0][0][0][0][0][1]=brick-platform-narrow-snow.1.0

having

BackImage[0][0][0][0][0][0-1]=brick-platform-narrow<$0=0?:-snow>.1.0

? Is this going a step too far in obfuscation? Does saving a few lines in a dat file mean that much?

I think it would be better to add multiplication functionality. If you had multiplications, you could combine the snow graphic with the non-snow graphic and add "+$?*x" to the position, where x is the width or height of the original graphic sheet, depending on whether you added snow below or to the right.
Multiplication to adress different clusters could be useful whenever three or more variables are used. Say you have a 4*4 building with 4 rotations and 5 seasons. You could simply write:
Backimage[0-3][0-3][0-3][0][0][0-4] = image/thisbuilding.<$0*4+$1>.<$2+$3*4>
Thus having a pattern of the 4*4 graphics as one cluster, with four rows of clusters for different rotation and four columns for different seasons.


Sorry, I can't test the patch since I have no idea how :(

kierongreen

Working on multiplication but it does involve adding brackets which complicates matters... (though once adding in multiplication might as well add in division and modulus).

kierongreen

#14
Ok, add, subtract, divide, multiple, modulo with correct precedence (and brackets) all supported.

Example below (compare with original in pak128.Britain which had 54 lines for these images...):

#
# Ground marker for pak128
#
Obj=ground
Name=Marker
copyright=Timothy Baldock
# the front part (obtained by hang%27) for signle slopes
Image[0-26][0]=images/marker.<$0/9+3>.<$0%9>

# backpart (obtained by (hang%3) + ((hang-(hang%9))/3)
Image[27-53][0]=images/marker.<($0%9)/3>.<$0%3+(($0-27)/9)*3>
--------------------


--

Edit: This doesn't seem controversial so after some more testing and tidying submitted in 7774. Though noticed there's not a nightly build for makeobj and I haven't managed to get my windows compile working again so will rely on people compiling from source themselves.

An_dz

Rather than using angle brackets <> I would suggest using brackets {}

To me angle brackets mean tags and not code. And brackets to me mean repetition.

Not using angle brackets could allow comparators or binary operators, I'm not requesting them, but just in case one day we find any use for them. And also for the sake of using the same de facto standard.

kierongreen

One reason for using angled brackets is that these are forbidden characters in Windows filenames.

Ters

While not strictly forbidden in file name on other platforms, the fact that angle brackets are used for redirecting streams on the command line of every system I have ever encountered, makes them unlikely to be part of any filename anywhere. Ironically, that might also be why they are rarely used for embedded expressions.

kierongreen

Fixed a problem with the loading of tabfiles that caused menuconf.tab to not load correctly (thanks to the auto reporting of errors for picking up on this!)

Leartin

I assume the logic only cares about what is written in the same line of code, so this would be something different, but I throw it out anyways:

Especially with citybuildings, I often have some alternate versions of the same building, which all use the same code, except for different object names and a different row in the image definition. So I wonder if it would be possible to define other ranges within the objects name, and use them not only in the image definition, but for other parameters as well.
For example, say you have one design for a building that spans over several levels. A good example would be a townhall I made for pak192.comic, which has 5 different stages. There names are "tow_copper[01-05]", they use the image "kupferdach<$$0>" and there level is <$$0*10>. (for now, they need 319 lines of code, the patch as it is would reduce this to 65 lines, and with this addition it would be 13 lines)

kierongreen

Anything which is read as a tabfile will be covered. Not just images but basically any line which has one or more [ ] followed by an = on the same line.

To address your point though I don't think it would work as the parameters would be on the right and as you say would extend beyond one line of code. So no, and your suggestion would be much more difficult to implement I think.