95 lines
3.8 KiB
Plaintext
95 lines
3.8 KiB
Plaintext
This was in modding_lua.txt for the past few years. It really needs to be in its own thing.
|
|
This also covers the event system.
|
|
--GM
|
|
|
|
font_mini
|
|
Small ASCII font, for most body text.
|
|
|
|
font_large
|
|
Big ASCII font, for headers and stuff.
|
|
|
|
font_digits
|
|
Big numeric font, for HUD counters.
|
|
|
|
gui_index_mini(i)
|
|
Character lookup helper for the mini font
|
|
|
|
gui_index_digit(i)
|
|
Character lookup helper for the digit font
|
|
|
|
gui_create_fixwidth_font(image, char_width, char_height, indexing_fn, shadow)
|
|
Creates a new fixed width bitmap font.
|
|
|
|
compute_unwrapped(x, y, color, string)
|
|
Computes specific glyphs and positions needed from a string, color, and x/y coordinates.
|
|
|
|
compute_ctab(ctab, x, y)
|
|
Computes specific glyphs and positions from a color table,
|
|
where each line of the table contains a string "msg" and a color "color",
|
|
and will be positioned underneath the previous line.
|
|
|
|
compute_wordwrap(width, x, y, color, string)
|
|
Computes specific glyphs and positions from a word-wrapped string, within the width argument.
|
|
|
|
dimensions(data)
|
|
Get the AABB dimensions of text(l,r,t,b, width, height) given precomputed text data
|
|
|
|
calc_shadow(color)
|
|
Calculate the shadow strength from the percieved luminance of the font; brighter color = darker shadow
|
|
|
|
print(x, y, color, string, buffer=nil)
|
|
Print text with topleft at x, y, color c, string str.
|
|
buffer defines where the text is drawn - to the screen or to an offscreen buffer.
|
|
|
|
print_precomputed(data, offx, offy, buffer=nil)
|
|
Print precomputed text to the given buffer.
|
|
|
|
print_wrap(wp, x, y, c, str, buffer)
|
|
Print text with minimum-space wordwrapping, pixelwidth wp, topleft at x, y, color c, string str
|
|
|
|
alarm{time=1, progress=0, active=true, loop=false, preserve_accumulator=true, on_frame=nil, on_trigger=nil}
|
|
Create an alarm with an abstract time value.
|
|
|
|
time: The target amount of time before the alarm triggers.
|
|
progress: How much time has elapsed(counting from 0 to the target time).
|
|
active: Whether the alarm is presently ticking.
|
|
loop: Whether the alarm loops.
|
|
preserve_accumulator: If the alarm loops, allow the leftover time to carry into the next loop.
|
|
on_frame: A callback run every frame. Recieves the time delta.
|
|
on_trigger: A callback run each time the alarm reaches its target time. Recieves the time delta.
|
|
|
|
gui_create_scene(width, height, shared_rate=1/60)
|
|
Creates a new GUI scene of designated width and height, and a shared update rate in seconds equal to shared_rate.
|
|
|
|
The GUI system is modelled similarly to the Flash AS3 APIs.
|
|
|
|
A GUI scene can contain any number of display objects, ordered in a tree structure.
|
|
Each time the GUI is ticked, it processes an event pipeline. An event is a message containing a type and some attached data.
|
|
When an event reaches a display object with a listener of the same type, the listener's callback is called with the event's data.
|
|
|
|
These events are available:
|
|
GE_DELTA_TIME
|
|
The delta time passed in when listeners are pumped. You can use this to drive tweening over time, for example.
|
|
Callback passes in the dT value.
|
|
GE_SHARED_ALARM
|
|
A tick running at a fixed rate. This is an alternative to delta time for situations where you specifically need a fixed rate,
|
|
for example, an animation that relies on multiplying previous values every step.
|
|
Callback passes in the dT value of the shared alarm timer.
|
|
GE_KEY
|
|
A keypress(up or down) event.
|
|
Callback passes in {key(int), state(bool), modif(int bitmask), uni(int)}
|
|
GE_BUTTON
|
|
A mapped button press(up or down) event. Use this when you expect the button to be reassignable.
|
|
Callback passes in {key(int), button{name(string), desc(string)}, state(bool), modif(int bitmask)}
|
|
GE_MOUSE
|
|
A mouse movement event.
|
|
Callback passes in {x(number), y(number), dx(number), dy(number)}
|
|
GE_MOUSE_BUTTON
|
|
A mouse button press(up or down).
|
|
Callback passes in {button(int), down(bool)}
|
|
|
|
|
|
|
|
#
|
|
|