Requires GNU m4
To build the script, simply run make in the project directory:
git clone https://github.com/coolDudeRude/stackvm-xonotic
cd stackvm-xonotic && makeSome sample programs are included in the examples folder.
These use DPI (Dynamic Programming Interface). This allows users to write
programs in game. However it can be very slow. There is also an assembler
for the virtual machine (See: vasm)
mainloader.cfg: Sits at the top of the program, loads the main function.math.cfg: Primitive math library containing basic functions.main.cfg: Example program that testsmath.cfgfunctionality.
First copy the examples folder and stackvm.cfg script to your userdir. Then run these command in Xonotic's console:
// This should load the vm and the example program
exec stackvm.cfg
exec examples/main.cfg
To start program execution run:
vm.run
There is no proper debugging interface yet, but you can combine vm.step with the aliases defined below to debug your scripts.
Use vm.step to step through each instruction and use peek and poke aliases to retrieve and change values of local and global variables.
// Retrieve local and global variable value
alias peek_l "load_l \"${1 !}\"; dot"
alias peek_g "load_g \"${1 !}\"; dot"
// Set local and global variable value
alias poke_l "push \"${2 !}\"; store_l \"${1 !}\"; echo \"${1} <- ${2}\""
alias poke_g "push \"${2 !}\"; store_g \"${1 !}\"; echo \"${1} <- ${2}\""