Core helpers of the Flux gamemode package on the global Flux table. They cover console output (Flux.print, Flux.dev_print), the registry of player actions (Flux.register_action), the loaded schema (its folder, name, information and inclusion) and the global UI offset that HUD elements follow on the client. The same file replaces file.Write with a version that creates missing folders.

Summary

Functions

Sets the offset returned by Flux.global_ui_offset.
Prints a debug message to the console, but only in development or when the debug_output_in_production setting is enabled.
Draws one frame of a registered position animation: calls the callback with the current position, then eases the position toward the target.
Draws a spinning cog icon, usually as a loading indicator.
Retrieves whatever was registered for the action with the specified identifier.
Returns the table storing all of the actions, keyed by identifier.
Gets the folder of the currently loaded schema.
Gets the table containing the information about the currently loaded schema.
Gets the name of the currently loaded schema.
Returns the version of the Flux core, as declared in its package metadata.
Returns the global UI offset, which follows the local player's view movement.
Includes all of the plugins inside the folder, files first, then folders.
Includes the files of the currently loaded schema.
Prints a message to the console.
Registers an action that can be assigned to a player.
Creates the state of a position animation unless one with this ID already exists, which makes it safe to call every frame.
Sets the fill percentage of the circular action indicator drawn in the middle of the HUD.
Creates or overwrites the state of a position animation.
Writes a Lua file into lua/_flux/client and marks it for download, so that the clients include it when they load.

Functions

Flux.__set_global_offset__(x, y)

shared internal packages/flow/core/sh_core.lua:161

Internal

This function is internal. It is not part of the public API and may change without notice.

Sets the offset returned by Flux.global_ui_offset.

Parameters

  • x Number
  • y Number

Flux.dev_print(message)

shared packages/flow/core/sh_core.lua:25

Prints a debug message to the console, but only in development or when the debug_output_in_production setting is enabled.

Parameters

  • message String

Flux.draw_animation(id, tx, ty, callback)

client packages/flow/core/cl_core.lua:508

Draws one frame of a registered position animation: calls the callback with the current position, then eases the position toward the target. Raises an error if the animation has not been registered.

Flux.register_animation(anim_id, box_x - max_width, nil, FrameTime() * 8)

Flux.draw_animation(anim_id, box_x, box_y, function(x, y)
  draw.textured_rect(Theme.get_material('gradient'), x, y, box_width, box_height, accent_color)
end)

Parameters

  • id String ID of the animation
  • tx Number target x
  • ty Number target y
  • callback Function draws the contents; called with the current (x, y), where an unanimated axis receives the target value

Flux.draw_rotating_cog(x, y, w, h, color)

client packages/flow/core/cl_core.lua:445

Draws a spinning cog icon, usually as a loading indicator. All cogs drawn in a frame share one rotation, which advances with every call.

Parameters

  • x Number screen x of the center of the cog
  • y Number screen y of the center of the cog
  • w Number width
  • h Number height
  • color Color optional, defaults to Color(255, 255, 255)

Flux.get_action(id)

shared packages/flow/core/sh_core.lua:67

Retrieves whatever was registered for the action with the specified identifier.

Parameters

  • id String identifier of the action

Returns

  • Map/Function the registered value, or nil if there is none

Flux.get_all_actions()

shared packages/flow/core/sh_core.lua:74

Returns the table storing all of the actions, keyed by identifier. This is the storage table itself, not a copy.

Returns

  • Map

Flux.get_schema_folder()

shared packages/flow/core/sh_core.lua:84

Gets the folder of the currently loaded schema.

Returns

  • String the schema folder; the client falls back to 'flux' if it is not known yet

Flux.get_schema_info()

shared packages/flow/core/sh_core.lua:127

Gets the table containing the information about the currently loaded schema. The server reads it from the schema's gamemode .txt file once and caches it; the client uses the copy shared by the server.

Returns

  • Map schema info with the name, author, description, version and folder fields

Flux.get_schema_name()

shared packages/flow/core/sh_core.lua:94

Gets the name of the currently loaded schema.

Returns

  • String the schema name, or 'Unknown' if it cannot be determined

Flux.get_version()

shared packages/flow/shared.lua:32

Returns the version of the Flux core, as declared in its package metadata.

Returns

  • String

Flux.global_ui_offset()

shared packages/flow/core/sh_core.lua:168

Returns the global UI offset, which follows the local player's view movement. HUD elements add it to their position to appear to lag behind the camera.

Returns

  • Number x offset
  • Number y offset

Flux.include_plugins(folder)

shared packages/flow/core/sh_core.lua:119

Includes all of the plugins inside the folder, files first, then folders. Does not handle plugins nested inside of other plugins.

Parameters

  • folder String folder relative to the Lua search paths (lua/, gamemodes/)

Flux.include_schema()

shared packages/flow/core/sh_core.lua:100

Includes the files of the currently loaded schema. On the client, shortly afterward notifies the server and runs the FluxClientSchemaLoaded hook.

Flux.print(message)

shared packages/flow/core/sh_core.lua:14

Prints a message to the console. Tables are printed with PrintTable.

Parameters

  • message Any

Flux.register_action(id, callback)

shared packages/flow/core/sh_core.lua:60

Registers an action that can be assigned to a player. The value is stored as given; note that Player#do_action only runs it if it is a table with a callback function field, which is then called with the player and the action ID.

Parameters

  • id String identifier of the action
  • callback Map/Function optional, defaults to nil handler of the action, see above

Flux.register_animation(id, x, y, delta)

client packages/flow/core/cl_core.lua:489

Creates the state of a position animation unless one with this ID already exists, which makes it safe to call every frame.

Parameters

  • id String unique ID of the animation
  • x Number starting x, or nil to leave the x axis unanimated
  • y Number starting y, or nil to leave the y axis unanimated
  • delta Number fraction of the remaining distance covered on every draw, 0 to 1

See also

Flux.set_circle_percent(percentage, alpha)

client packages/flow/core/cl_core.lua:53

Sets the fill percentage of the circular action indicator drawn in the middle of the HUD. The value is cleared after every draw, so call this each frame while it should be visible.

Parameters

  • percentage Number fill percentage from 0 to 100
  • alpha Number optional, defaults to 255 opacity of the indicator from 0 to 255

Flux.update_animation(id, x, y, delta)

client packages/flow/core/cl_core.lua:477

Creates or overwrites the state of a position animation.

Parameters

  • id String unique ID of the animation
  • x Number current x, or nil to leave the x axis unanimated
  • y Number current y, or nil to leave the y axis unanimated
  • delta Number fraction of the remaining distance covered on every draw, 0 to 1

Returns

  • Map the animation state with the x, y and delta fields

See also

Flux.write_client_file(path, contents)

server packages/flow/hooks/sv_hooks.lua:620

Writes a Lua file into lua/_flux/client and marks it for download, so that the clients include it when they load. The files are included in the order of their names, which is why the gamemode's own start with a number. Packages that generate clientside code call this from their FLWriteClientFiles handler, since the folder is emptied before the files are written.

Parameters

  • path String file name, relative to lua/_flux/client
  • contents String Lua code

Defined in