hyTags
HomeHome DocumentationDocumentation

var-set

Sets a variable with the specified name and value.
Parameter
Type
Description
name
String
Name of the variable to set
value
T?
Value to set (if omitted, uses the command block)
type
Type?
Expected type of the value when value is omitted
commands
Commands
Commands that return the value to set
return
void
No return value.
Test Case:Set string variable with explicit value
    <div></div>
    
    <var-set name="greeting" value="hello"></var-set>
    <var-get name="greeting">
    <assert-equal value="hello" type="string">
    
    👆 Try to change something!
  • Test Case:Set number variable from last value
      <div></div>
      
      <number-new value="42">
      <var-set name="count" $value type="number"></var-set>
      <var-get name="count">
      <assert-equal value="42" type="number">
      
      👆 Try to change something!
    • Test Case:Set number variable from last value
        <div></div>
        
        <var-set name="count">
          <number-new value="42">
        </var-set>
        <var-get name="count">
        <assert-equal value="42" type="number">
        
        👆 Try to change something!
      • Test succeeded Test failed