Skip to content
Jamiras edited this page Aug 21, 2021 · 6 revisions

always_true()

Defines the clause "1==1". It is typically only used to move a PauseIf/ResetIf to an alt group:

byte(0x1234) == 8 && (always_true() || (never(byte(0x2345) == 12) && unless(byte(0x3456) == 6)))

This allows the achievement (core group) to trigger while the never is paused by the unless.

always_false()

Defines the clause "0==1". It is typically used for constructing alt chains, as a variable must have an initial value:

trigger = always_false()
for test in tests
    trigger = trigger || test
achievement(..., trigger = trigger)

If more than two alt groups exist, the always_false group will be removed from the final achievement code

format(format_string, parameters...)

Builds a string by inserting parameters into placeholders in the format_string.

For example:

stage_names = {
    1: "Downtown"
}
stage_1_label = format("Stage {0} - {1}", 1, stage_names[1])

Would set stage_1_label to "Stage 1 - Downtown"

length(object)

Returns the number of elements in a dictionary or array, or the number of characters in a string.

range(start, stop, step=1)

Returns an array containing integers starting at start and continuing until stop.

If step is specified, the second item will be start+step, the third will be start+step*2, and so on until a value greater than stop would be generated. That value will be ignored.

any_of(inputs, predicate)

Returns an expression that will evaluate true if any of the inputs matches the predicate.

inputs is an array or a dictionary. If a dictionary is provided, the keys will be passed to the predicate.

predicate is a function that accepts a single input and returns an expression constructed from that input. The expressions returned by predicate are joined with ||s.

all_of(inputs, predicate)

Returns an expression that will evaluate true if all of the inputs matches the predicate.

inputs is an array or a dictionary. If a dictionary is provided, the keys will be passed to the predicate.

predicate is a function that accepts a single input and returns an expression constructed from that input. The expressions returned by predicate are joined with &&s.

none_of(inputs, predicate)

Returns an expression that will evaluate true if all of the inputs do not match the predicate.

inputs is an array or a dictionary. If a dictionary is provided, the keys will be passed to the predicate.

predicate is a function that accepts a single input and returns an expression constructed from that input. The expressions returned by predicate are negated (!) and then joined with &&s.

sum_of(inputs, predicate)

Returns an expression that will calculate the sum of the inputs modified by the predicate.

inputs is an array or a dictionary. If a dictionary is provided, the keys will be passed to the predicate.

predicate is a function that accepts a single input and returns an expression constructed from that input. The expressions returned by predicate are added together with +.