This page presents all the <Instruction>
s that can be performed in Wyrd.
<Instruction>
s do not return values.
Unless otherwise specified, all <Instruction>
s:
<State>
’s program_counter
by 1.<State>
’s last_instruction_result
to (MUST_CONTINUE)
.Implementing execute(<State>)
to recurse/loop as long as the newly updated
<State>
’s last_instruction_result
is (MUST_CONTINUE)
is acceptable.
Shortcut to each <Instruction>
:
(add_event_option! {name: String} {parameters: <Computation> List})
(add_text_option! <value: Computation>)
(assert! <condition: Computation> <message: Computation>)
(display! <value: Computation>)
(end!)
(initialize! {type: String} <target: Computation>)
(prompt_command! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)
(prompt_float! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)
(prompt_integer! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)
(prompt_string! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)
(remove! <target: Computation>)
(resolve_choice!)
(set_pc! <value: Computation>)
(set_random! <min: Computation> <max: Computation> <target: Computation>)
(set_value! <target: Computation> <value: Computation>)
({extra_instruction: String}! {parameters: <Computation> List})
(add_event_option! {name: String} {parameters: <Computation> List})
Adds an <Option>
based on an <Event>
for the user.
Parameters:
value
is a {String}
indicating the name of the <Event>
.parameters
is a {List}
of <Computation>
that will yield the <Value>
s
required for this option to be chosen when the <Event>
occurs on the next
(resolve_choice!)
.Process:
<Value>
corresponding to each member of parameters
, store them
in a {List}
while keeping the order.<EventOption>
with name name
and the aforementioned
{<Value> List}
as parameters.<EventOption>
to the end of the <State>
’s
available_options
.(add_text_option! <value: Computation>)
Adds an <Option>
based on an <TextValue>
for the user.
Parameters:
value
is a <Computation>
that will yield the <TextValue>
displayed to
the user for this option on the next (resolve_choice!)
.Process:
<Value>
yielded by value
.<TextOption>
corresponding to the aforementioned
<Value>
.<TextOption>
to the end of the <State>
’s
available_options
.(assert! <condition: Computation> <message: Computation>)
Checks if a condition is fulfilled and prints an error message if it is not.
Parameters:
condition
is a <Computation>
corresponding to what needs to be tested.message
is a <Computation>
defining the error message displayed to the
user if the condition is not verified.Process:
<Value>
yielded by condition
.<Value>
as {Boolean}
.TRUE
, the <Instruction>
has completed.<msg: Value>
corresponding to the message
.<State>
’s last_instruction_result
to
(MUST_DISPLAY_ERROR <msg: Value>)
.(display! <value: Computation>)
Displays text to the user.
Parameters:
value
is a <Computation>
corresponding to what has to be displayed.Process:
<msg: Value>
corresponding to value
.<State>
’s last_instruction_result
to
(MUST_DISPLAY <msg: Value>)
.(end!)
Ends the story.
Process:
<State>
’s program_counter
.<State>
’s last_instruction_result
to (MUST_END)
(initialize! {type: String} <target: Computation>)
Adds an element to memory
with a deterministic default value.
Parameters:
type
is a {String}
corresponding to the type that will be used by
target
.target
is <Computation>
that will yield the address to initialize.Process:
<Value>
resulting from target
. This is a <PointerValue>
.<PointerValue>
as a {{String} List}
.<State>
’s memory
so that the element pointed to by the
<PointerValue>
takes the default value for a <Value>
of type type
. Note
that the target
might point to an element that does not exist yet.Note:
Depending on how you choose to ensure the generation of new unallocated
addresses, it may be necessary to update the <State>
to account for the fact
that a new address is now in use. This should only be done for addresses that
were generated by a (get_allocable_address)
computation. This can easily be
tested for by having these prefixed by ".alloc."
as suggested. When using the
recommended way, three outcomes are possible:
target
corresponds to an address in the <State>
’s freed_addresses
collection, in which case that collection is updated so that it no longer
contains it.target
designated the address that would be be generated by the <State>
’s
allocated_data
counter when using a (get_allocable_address)
computation,
in which case the counter is increased.(prompt_command! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)
Asks the user to provide a list of strings as input.
Parameters:
min
is a <Computation>
indicating the minimum size the user {String}
input should be (in characters).max
is a <Computation>
indicating the maximum size the user {String}
input should be (in characters).target
is a <Computation>
indicating where to store the result.message
is a <Computation>
corresponding to the message displayed to the
user for this prompt.Process:
<Value>
corresponding to each of these parameter.<State>
’s memorized_target
to be the <Value>
resulting from
target
.<State>
’s last_instruction_result
to
(MUST_PROMPT_COMMAND <min_val: Value> <max_val: Value> <msg: Value>)
.(prompt_float! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)
Asks the user to provide a float as input.
Parameters:
min
is a <Computation>
indicating the minimum float the user is allowed
to inputmax
is a <Computation>
indicating the maximum float the user is allowed
to inputtarget
is a <Computation>
indicating where to store the result.message
is a <Computation>
corresponding to the message displayed to the
user for this prompt.Process:
<Value>
corresponding to each of these parameter.<State>
’s memorized_target
to be the <Value>
resulting from
target
.<State>
’s last_instruction_result
to
(MUST_PROMPT_FLOAT <min_val: Value> <max_val: Value> <msg: Value>)
.(prompt_integer! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)
Asks the user to provide an integer as input.
Parameters:
min
is a <Computation>
indicating the minimum integer the user is allowed
to inputmax
is a <Computation>
indicating the maximum integer the user is allowed
to inputtarget
is a <Computation>
indicating where to store the result.message
is a <Computation>
corresponding to the message displayed to the
user for this prompt.Process:
<Value>
corresponding to each of these parameter.<State>
’s memorized_target
to be the <Value>
resulting from
target
.<State>
’s last_instruction_result
to
(MUST_PROMPT_INTEGER <min_val: Value> <max_val: Value> <msg: Value>)
.(prompt_string! <min: Computation> <max: Computation> <target: Computation> <message: Computation>)
Asks the user to provide a string as input.
Parameters:
min
is a <Computation>
indicating the minimum size the user {String}
input should be (in characters).max
is a <Computation>
indicating the maximum size the user {String}
input should be (in characters).target
is a <Computation>
indicating where to store the result.message
is a <Computation>
corresponding to the message displayed to the
user for this prompt.Process:
<Value>
corresponding to each of these parameter.<State>
’s memorized_target
to be the <Value>
resulting from
target
.<State>
’s last_instruction_result
to
(MUST_PROMPT_STRING <min_val: Value> <max_val: Value> <msg: Value>)
.(remove! <target: Computation>)
Removes an element from memory.
Parameter:
target
is a <Computation>
indicating where the element to remove is.Process:
<Value>
corresponding to target
.<Value>
as an address.<State>
’s memory
.(get_allocable_address)
computation, add it to the <State>
’s freed_addresses
collection.(resolve_choice!)
Makes the user choose between all previously added options.
Process:
<State>
’s last_instruction_result
to (MUST_PROMPT_CHOICE)
.(set_pc! <value: Computation>)
Sets the program counter to a given value.
Parameter:
value
is a <Computation>
indicating what to set the program counter to.Process:
<Value>
for value
.<Value>
as an {Integer}
.<State>
’s program_counter
to this value.<State>
’s program_counter
.(set_random! <min: Computation> <max: Computation> <target: Computation>)
Replaces the <Value>
at a given address with a random integer. This is not
a computation as some languages will require state updates to keep generating
new random values.
Parameters:
min
is a <Computation>
indicating the minimum integer allowed.
to inputmax
is a <Computation>
indicating the maximum integer allowed.target
is a <Computation>
indicating where to store the result.Process:
<Value>
corresponding to each of these parameter.{Integer}
between min
and max
(included).<State>
’s memory
so that the element at target
is to be the
<Value>
resulting from target
.(set_value! <target: Computation> <value: Computation>)
Sets the value of an element in memory.
Parameters:
target
is a <Computation>
indicating what element to set to the value.value
is a <Computation>
corresponding to the value to give the element.Process:
target
as <addr: Value>
.<State>
’s memory
so that the element at addr
takes the
<Value>
resulting from value
’s computation.({extra_instruction: String}! {parameters: <Computation> List})
Executes non-standard instruction.
Parameters:
extra_instruction
is the name of the extra instruction.parameters
is a list of parameters for this instruction call.Process:
extra_instruction
so that you can add non-standard instructions.