strats: custom object types can be edited and deleted with undo (code rebuilt, objects follow their type), low-confidence opcodes re-checked (353 high, 2 low left), script view with do-while, while, break, continue, switch and else-if (gotos 11019 -> 400), first script compiler (structured script -> assembly, script stored with the type)
This commit is contained in:
1 parent
b35792a4ed
commit
8b78958306
21 files changed
+2332
-154
No files matched your search
@@ -77,6 +77,51 @@ empty template) opens the type editor:
|
||||
The new script is added to the level's code; the original type is not changed. Custom types are
|
||||
stored in the project (as text) and rebuilt every time it is opened.
|
||||
|
||||
### Editing and deleting your types
|
||||
|
||||
Select an object of a custom type (or pick the type in the Script panel's *Type* list):
|
||||
|
||||
* **Edit type…** (Script panel or the Inspector's *Script* section) opens the type editor with
|
||||
its script. Change it, **Check**, then **Apply**. Objects of the type that are already placed
|
||||
keep their place and run the new script. **Ctrl+Z** undoes the change.
|
||||
* **Delete type…** removes the type. If objects in the level use it, the editor tells you how many
|
||||
and deletes them together with the type (also undoable).
|
||||
|
||||
### Writing a script instead of assembly
|
||||
|
||||
Set **Language** in the type editor to **Script** to write the behaviour in a structured language
|
||||
that looks like the Script view:
|
||||
|
||||
```
|
||||
strat Pulser {
|
||||
alias size = v0
|
||||
setModel(model:5)
|
||||
size = 1.0
|
||||
loop {
|
||||
while (size < 4.0) { // grow to four times the size
|
||||
size = size + 0.05
|
||||
scale(size)
|
||||
yield // wait for the next frame
|
||||
}
|
||||
do { // and shrink back
|
||||
size = size - 0.05
|
||||
scale(size)
|
||||
yield
|
||||
} while (size > 1.0)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* Statements: `x = value`, `x += value`, `if (…) { } else { }`, `while (…) { }`, `loop { }`,
|
||||
`do { } while (…)`, `break`, `continue`, `yield`, `end`, `call name` (for `sub name { … }`).
|
||||
* Any instruction can be called by name with its values in brackets: `turnLeft(4deg)`,
|
||||
`scale(size)`; values that are part of the instruction go in `<>`: `collisionOn<0x8000>()`.
|
||||
* Places: `v0`… (or a name given with `alias`), globals `g12`, properties `self.y`, `player.x`…
|
||||
* Numbers mean the same as in the assembly: write `10.0` for ten (a plain `10` is ten 1/4096
|
||||
steps), angles as `90deg`.
|
||||
* **Check** compiles and verifies; errors name the line. Switching *Language* back to *Assembly*
|
||||
shows the generated instructions. The full reference is in `notes/strat-language.md`.
|
||||
|
||||
Language reference: every instruction is one line, labels end with `:`, comments start with `;`.
|
||||
`push 4deg` / `turnLeft` pushes a number and lets an instruction use it; `jmpYield label` waits
|
||||
for the next frame and jumps. The full syntax and the list of all 434 instructions are in the
|
||||
@@ -137,14 +182,15 @@ circle:
|
||||
|
||||
## Limits
|
||||
|
||||
* Custom types cannot be deleted or edited in place yet – clone the custom type again with the
|
||||
changes and replace the placed objects.
|
||||
* Custom types can't be edited or deleted right after importing object types from another level
|
||||
in the same session – save and reopen the project first.
|
||||
* Big structural changes are up to you: the editor checks that the code is well-formed and that
|
||||
every model/animation/code reference points somewhere valid, not that the object behaves well.
|
||||
* Names of rarely used instructions are educated guesses (the opcode list shows a confidence for
|
||||
each).
|
||||
* Small constants stored as short numbers only accept −8.0 … 7.99 (see *Changing numbers*).
|
||||
* The Script view shows `goto` where the original jumps don't form nested blocks; the Assembly
|
||||
view is always exact.
|
||||
* The Script view shows `while`, `do … while`, `switch`, `break` and `continue` where it can and
|
||||
`goto` where the original jumps don't form nested blocks (a few hundred places in the whole
|
||||
game); the Assembly view is always exact.
|
||||
* In the clone dialog, renaming the type doesn't yet rename the entry label or the name inside
|
||||
the script text – edit those by hand if you want them to match.
|
||||
Reference in new issue
Block a user