Bracket float text
Terminal game58 lines of .st263 lines of generated Rust
2.500000 7
On this page
The .st files#
intent.st
structop {
type_app {
exec = {
lang = "Rust"
}
}
lib_provider {
core = {
source = "StructOp/core"
version = "@latest"
}
Screen = {
source = "StructOp/game"
version = "@latest"
}
}
}main.st
# A Float and an Int given whole to a game's text (no ${}). With StructOp/rust 2.2.1 the program is generated as
# before 2.2.2 (the number is passed to the terminal as it is: 2.5); with 2.2.2 it is written as ${} writes it
# (2.500000), as the C build writes it.
ability "value" "f" {
type = Float
initial = 2.5
}
data "value" "f" {
of = ability.value.f
}
ability "value" "n" {
type = Int
initial = 7
}
data "value" "n" {
of = ability.value.n
}
ability "game" "Show" {
title = "Numbers"
on_tick = [ability.clear.Screen, ability.text.F, ability.text.N]
}
ability "clear" "Screen" {
}
ability "text" "F" {
x = 1
y = 1
message = data.value.f.current
}
ability "text" "N" {
x = 1
y = 2
message = data.value.n.current
}Input, plan and generated Rust#
input.txt · typed input (3 lines)
input.txt · typed input (3 lines)
structop plan
structop plan
# program.app will be created
+ program.app (.structop/build/app)
+ ability.value.f
+ ability.value.n
+ ability.game.Show
+ ability.clear.Screen
+ ability.text.F
+ ability.text.N
Plan: 1 to add, 0 to change, 0 to destroy.Generated main.rs
To inspect this generated file, select Rust in intent.st, initialize the project and export its source.
Export locally
structop init
structop apply -source -no-runTry it
cd bracket-float-text # a folder holding the .st files above
structop init
structop plan
structop apply < input.txt