Skip to content

4. Global tags

rafa97sam edited this page Sep 27, 2023 · 39 revisions

Macros | Filters | Auxiliaries | Elements | Aspect/Design | Utilities

Macros

IF/ELSE | LOOP |

If

You can use if <condition_expression> to disable certain parts of the script (set variables won't work here because its evaluation takes place when parsing the text)

category
if 1 == 0
header Don't show this
expr 'x'
end

if 1 == 1
header Show this
expr '✓'
end

header Checkmarks :)
if 1 == 0
expr 'x'
end
if 1 == 1
expr '✓'
end

header Checkmarks with else :)
if 1 == 0
expr 'x'
else
expr '✓'
end


Var

You can have a variable changing it's value throughout the script by using the keyword var <name> <const_value> and accessing it via var(<name>). It's scoped to category/header. Doesn't work with if because it is evaluated after parsing the text.

category
header Level
var self Actual Lvl
expa var(self)

header
var self Level plus 5
expa var(self)
expr Level+5

header
var self Level plus 10
expa var(self)
expr Level + 10


Loop

In some special cases it's useful to generate multiple categories and headers with related properties at once. This can be achieved via a loop: loop <loop_vars> for <loop_array> + end keyword pair. Category and header definitions enclosed by the loop will be repeated once for each element in the array, where the loop variable placeholders __<loop_var>__ will take the value specified in the array at the index of iteration. The substitution happens at the parsing phase so <loop_vars> work in if.

set CategoryNames with all as ['Category A', 'Category B']
set HeaderNames with all as ['Header A', 'Header B']
set Values with all as [ 100, 200, 300, 400 ]

loop category, header for [[0, 0], [0, 1], [1, 0], [1, 1]]
if __header__ == 0
category
expa CategoryNames[__category__]
end
header
expa HeaderNames[__header__]
expr Values[__category__ * 2 + __header__]
end
# FIRST ITERATION: <loop_vars> "category" and "header" both = 0
# The code is interpreted as:
if 0 == 0
category
expa CategoryNames[0]
end
header
expa HeaderNames[0]
expr Values[0*2 + 0]

⚠️ If you extend definitions inside a loop (ex.perc:header Level) and they contain __<loop_var_name>__ placeholders, they won't be substituted. You must use var(<loop_var_name>) in the definition for that.




Filters

Conditional parsing | Discard |

Conditional parsing

Indicates whether options should be used or not depending on the type of the table.
You can use it to create single script that will work in all types of tables.

if Group
# Will be set for group tables
else
# Will be set for me & players tables
end

if not Players
# Will be set for me & group tables
end

if Player
# Will be set for me tables
end

Can also use different headers/colors for light/dark/custom modes

if theme == 'light'
  something
else
  something
end

Discard

[Me,Players] Excludes files that match the provided expression

discard Level<438



Auxiliaries

Constants | Constant Expressions | Local Variables | Table Variables | Custom Functions

Constants

const keyword allows you to define custom constants or override the default ones.

# Create new constant red_color with value red
const red_color red

# Change default green to white in hex
const green ffffff

Constant Expressions

constexpr keyword allows you to define custom constants evaluated from non-capture dependent expressions

# Create new constant that is an array
constexpr colors ['red','green','blue']

# Create new constant that is evaluated from a viable expression
set getTransparency with S as { 0: '00', 10: '66', 15: 'B3', 25: 'FF' }[S]
constexpr greenaline 'green' + getTransparency(15)

Local variables

Creates a local variable. These are calculated individually for each player object.

# Get intelligence resistance for the current player
set bigBrainReduction as Intelligence/2

#Use Variable within a header
header Int Resist
expr bigBrainReduction

You can also create a embedded local variable directly within a header using $! <variableName> { <expression> }.

header Int Resist
expr $! bigBrainReduction {Intelligence/2}
header Int Recover
expr bigBrainReduction*2

Table variables

Creates a table variable. These are calculated only once for the whole table: all players in [Players,Guild] vs all player instances in [Me].

# Get maximum level of all players
set Maximum Level with all as max(map(this, Level))

# Use variable within a header
header Max Level
expr Maximum Level

You can also create a embedded table variable directly within a header by using $ <variableName> { <expression> }.

# Anonymous table variable
header Max Level
expr ${ max(map(this, Level)) }

# Named table variable
header Max Level
expr $ myVariable { max(map(this, Level)) }

# Reuse table variable
header Max Level 2
expr myVariable

Custom functions

Creates a function. Every function has to have at least one parameter.

# Returns player level + 5
set New Level with P as Level(P) + 5

# Use function within a header
header My Level
expr New Level(player)



Elements

Table | Statistics | Details Row | Members | Element Ordering

Table

It refers to the main table defined by the categories and headers in the applied template. It's always shown by default.


Statistics

Creates a statistic row. If used, it will replace the original Min, Average, Max rows.

statistics Own Minimum as min(this)

Details row

Creates a row outside of the table with a specified expression

show Maximum Level as max(map(this, Level))

Members

[Guild] Shows list with classes and members that joined or left.

members on

Layout

Allows you to change the layout of the table. You can change the order of the elements or duplicate them if necessary.

# Default configuration
layout table statistics members rows
# Example with a line (|) and empty row (_) separating statistics from table
layout statistics | _ table members rows



Aspect/Design

Lined Rows | Scaling | Font | Alternating Rows | Large Rows | Row height | Theme Dark | Theme Custom | Width Policy

Lined rows

Shows lines between each table row

# Disable lines
lined off

# Show thin lines
lined on
# or
lined thin

# Show thick lines
lined thick

Scale

Scales the width of all headers. Default value is 100.

# Scale headers down to 80% of their original width
scale 80

Font

Sets the font of the table. You can use any css font string as an argument.

# Scale font down to 80% of its original size
font 80%

Opaque

Adds a default background to every other row (i.e. alternating row coloring)

opaque on

Large rows

Increases the height of all rows

large rows on

Row height

Sets the height of all rows (if above the required minimum)

row height 20

Theme Dark

Dark theme for your table. Turns the whole table default background blackish and default text color white:

theme dark

Theme Custom

Customize color theme for your table. You can set the table default background and default text colorcodes:

theme text:cyan background:99999999

Width Policy

You can make the table either use the exact specified widths or adjust itself to content by toggling <strict|relaxed> respectively. <relaxed> is the default behavior.

width policy strict



Utilities

Index | Outdated | Simulator | Performance |

Indexed rows

You can add an index on the start of the row. They can also be static (will not change when sorting).

# Disable indexes
indexed off

# Enable indexes
indexed on

# Enable indexes (ignores sorting)
indexed static

Customizing the index column is possible by hijacking the order, name and style of the first header specified. The displayed text though is kept the normal row number index be it <static> or <on> (dynamic).

# Highlight own chars index in red
indexed static
indexed custom header 
left category #necessary otherwise the default left category 1st header is used
header \#2.0
expr Own
expc this? 'red':'green'

Outdated

[Players] Highlights player names in red if they are not present in the latest file.

outdated on

Simulator

Simulator target (Guild, Players): Sets simulator to 1vAll mode. The argument is the player id of a player that will be attacked by all players.

simulator target w27_net_p100

Simulator source (Guild, Players): Sets simulator to 1vAll mode. The argument is the player id of a player that will attack all players.

simulator source w27_net_p100

Iteration Count (Guild): Sets simulator iteration count. Use with caution.

# Set simulator to 100 iterations per fight in guild table
simulator 100

Note: for Players table the same thing is achieved with the x: <number_of_fights> filter


Performance

[Players] Limits the number of displayed rows at once for performance reasons.

# Shows only top 5 players
performance 5