Skip to content

Dynamic strings

Operand type for actions that show text with optional runtime substitutions. In ManagedMegalo grammar this appears as <dynamic_string>; on the wire it is stored as c_dynamic_string — a string-table index plus up to two replaceable tokens.

A dynamic string is always a string table symbol or an inline literal, followed by zero, one, or two reference operands that fill % placeholders in that text.

Placeholders

Scan the string left to right for % followed by a known letter. Each match consumes the next action operand after the string. At most two placeholders are allowed; a third is a compile error (Too many replacement tokens!). Unknown %X sequences are ignored and do not consume an operand.

SpecifierOperand typeExample operand
%nNumber (custom variable)score_to_win_round, 1, global.my_counter
%pPlayercurrent_player, killing_player
%tTeamattackers, current_player.team
%oObjectcurrent_object, global.flag
%sTimerglobal.round_timer, sudden_death_timer

%s is not a string (unlike C printf). It inserts a timer — likely “seconds”, since %t already means team. The engine formats the timer’s remaining time into the slot.

Operand order matches placeholder order in the string — not the order of letters in the table above.

megalo
action player_set_objective current_player "+%n" score_to_win_round
action hud_post_message everyone none "%p scored!" scoring_player
action navpoint_set_text current_object "%n s" global.countdown

At runtime the engine substitutes each token into the corresponding % slot (for example "+%n" with score_to_win_round+25).

Persistent vs transient

Some actions treat the dynamic string as persistent — the text must remain valid after the trigger finishes. Those actions reject transient variable references in the token operands (Can't use transient variables when reading a persistent string).

ModeActionsTransient tokens
Persistenthud_widget_set_text, hud_widget_set_value, navpoint_set_text, player_set_objective, player_set_objective_allegiance, player_set_objective_allegiance_iconForbidden
Transienthud_post_message, print_variable, saved_film_insert_markerAllowed

Used by

ActionGrammar
hud_post_message<team_or_player_target> <sound> <dynamic_string>
print_variable<dynamic_string>
hud_widget_set_text<hud_widget_name> <dynamic_string>
hud_widget_set_value<hud_widget_name> <dynamic_string>
navpoint_set_text<object> <dynamic_string>
player_set_objective<player> <dynamic_string>
player_set_objective_allegiance<player> <dynamic_string> <engine_icon_index>
player_set_objective_allegiance_icon<player> <dynamic_string> <engine_icon_index>
saved_film_insert_marker<offset (s)> <label><label> is parsed as a dynamic string

Localization

When the string is a string-table symbol, every language translation must declare the same placeholder types in the same order. Mismatched % tokens across languages produce a compile error. Prefer symbols over inline literals for shipped text — see String literal strictness.

Example

megalo
string_table english
	obj_score "+%n"
	msg_scored "%p scored!"
end

trigger player_scored
	action player_set_objective current_player obj_score score_to_win_round
	action hud_post_message everyone none msg_scored scoring_player
end

See also