Skip to content
ColonelThirtyTwo edited this page Jun 5, 2012 · 2 revisions

Hooks

Hooks are a way for you to register for updates that happen around Starfall.

Syntax for Starfall hooks:

hook("hook_identifier", "unique_identifier", hook_func )

This will register hook_func to get called whenever the hook hook_identifier gets triggered.

Server Side Hooks

input

function hook_func( input_changed, value )
    print( input_changed .. value )
end

hook("input", "hook_name", hook_func)

This hook gets called every time one of the wire inputs change.

It passed you the name of the value that got changed and the new value in a return list.

readcell

hook("readcell", "hook_name", hook_func)

This hook gets called whenever a wire high-speed device tries to read from a cell on starfall.

writecell

hook("writecell", "hook_name", hook_func)

This hook gets called whenver a wire high-speed device tries to write to a cell on your starfall chip.

Shared Hooks

think

hook("think", "hook_name", hook_func)

This hook gets called every tick of the server.

sf_used

function hook_func( user )
    print( user:SteamID() )
end

hook("sf_used", "hook_name", hook_func)

This hook gets called when someone presses use on a Starfall entity.

Client Side Hooks

render

hook("render", "hook_name", paint_func)

This function is used for Starfall screens only, It is called every frame on viewer's screens.

In functions called by this hook is the only time you are able to use most functions from the client side Screen library.

umsg

function umsg_receive( data )
    print( data:getString() )
end

hook("umsg", "hook_name", umsg_receive )

This hook is how you receive a umsg on client side when the server instance sends a UMSG.

Clone this wiki locally