An open API service indexing awesome lists of open source software.

https://github.com/leops/hatchet

A non-scripting language for the Source engine
https://github.com/leops/hatchet

programming-language scripting-language source-engine

Last synced: 4 months ago
JSON representation

A non-scripting language for the Source engine

Awesome Lists containing this project

README

          

# The Hatchet Language
A non-scripting language for the Source engine

# Concept
Hatchet is a metalanguage designed to apply compile-time transformations to source code
(specifically, to the code of a VMF file generated by the Hammer editor).

Like [Focus](https://github.com/leops/focus/), it's aimed at solving some usability issues commonly
encountered with the Source engine's I/O system, and its programming interface in Hammer. However,
it goes in completely different direction by empowering the user through the capabilities of a
programming language instead of a visually compelling interface.

It's also different from the VScript system implemented in the engine, as Hatchet scripts are
executed as a step of the compilation process, and not at runtime. Both languages can be used to
solve some problems like the setup of complicated choreographed sequences, but each of them covers
mostly different use cases.

# Syntax
The most common construct of the Hatchet language is the subscriber definition, used to define an
event connection:
```hatchet
floor_button_1.OnPressed {
motor_wheel.Open()
ramp_rotator.Open()
button_1_texturetoggle.SetTextureIndex(1)
}
```

Sinces Hatchet is a domain-specific language, it provides a simple syntax to define Source specific
entities:
```hatchet
relay paintdropper_1_trigger_to_start {
paint_sprayer_1.Start()
}

auto {
@glados.RunScriptCode("sp_a3_speed_ramp_entrance()")
paintdropper_1_trigger_to_start()
}
```

Like any programming language Hatchet allows the definition of variable and loops:
```hatchet
let buttons = [{
button: button1_btn,
indic: button1_indic,
}, {
button: button2_btn,
indic: button2_indic,
}, {
button: button3_btn,
indic: button3_indic,
}]

for btn in buttons {
btn.button:relay_activated.OnTrigger {
btn.indic:indicator_timer_start_rl()
laser:counter.Add()
}

btn.button:relay_deactivated.OnTrigger {
laser:counter.Subtract()
}
}
```

It also lets you interact directly with the entities in the map, by manually editing their properties
or using built-in functions:
```hatchet
for i in range(0, 10) {
let mesh = clone(mesh_template)
mesh.origin.x = rand(-3175, 3175)
mesh.origin.y = rand(-3175, 3175)
mesh.origin.z = rand(-3175, 3175)
}

remove(mesh_template)
```

# Modules
* [lang](https://github.com/leops/hatchet/blob/master/lang/): The source code for the Hatchet
compiler, written in Rust
* [syntax](https://github.com/leops/hatchet/blob/master/syntax/): Syntax highlighting definitions
for the Atom editor