Skip to content
/ hatchet Public

A non-scripting language for the Source engine

License

Notifications You must be signed in to change notification settings

leops/hatchet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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, 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:

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:

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:

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:

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: The source code for the Hatchet compiler, written in Rust
  • syntax: Syntax highlighting definitions for the Atom editor

Releases

No releases published

Packages

No packages published

Languages