Skip to content

fantasy

os

Type

string


desktop

Type

string

Description

This value will always be Windows on FC2 Windows. On Linux, it will return your DE.


solution

Type

string


version

Type

string


current_directory

Type

string

Description

You can use this instead of sessions.directory if you plan to make your script cross-platform. However, the best practice for that is to use the file:current_directory() function as it takes into consideration for separators. This string value does not.


session

Type

session


log

Type

function

Description

This accepts the format string syntax, which is similar to Python's str.format.

You can pass a class as an argument and it will automatically get the value. Passing the color class will output the RGBA and hex value for example. This should also work with entity, vector and address. This also applies to fantasy.fmt.

Parameters

  • string text

Example

Lua
-- testing fmt and fantasy.log
local fmt = {}

function fmt.on_loaded( _, session )

    -- a simple and basic log entry and output to console
    fantasy.log( "Basic string" )

    -- a formatted log entry and output to console with index specification (optional)
    fantasy.log( "Hello! My name is {0} with {1} forum posts.", session["username"], session["posts"] )

    -- testing types
    local random_address = address.new( 0xDEADBEEF )
    local random_table = { 1, 2, 3, 4, 5 }
    local random_boolean = true
    fantasy.log( "{}", random_table )
    fantasy.log( "{}", random_address.address )
    fantasy.log( "{}", random_boolean )
    fantasy.log( "{:.2f}", 12.345678 ) -- this should round in console to 12.35
    fantasy.log( "{}", fmt.on_loaded )

    -- format and assign to a string with no index specification
    local welcome_message = fantasy.fmt( "Welcome {} to fantasy.{}", session["username"], string.lower( fantasy.solution ) )

    -- create notification using fantasy.fmt;
    fantasy.notification( "fmt-test", welcome_message )

    -- this should throw an exception instead of simply crashing your FC2 solution
    fantasy.log( "Hello! {} {} {} {} {}", 1000) -- this will throw an exception because you requested 5 specifiers but only included 1.

end

return fmt

fmt

Type

function

Description

This accepts the format string syntax, which is similar to Python's str.format. See log function above for an example.

Parameters

  • string

Returns

  • string

wait

Type

function

Description

Stops the current worker from continuing until a key is pressed in console.


exit

Type

function

Description

Closes the FC2 solution.


python

Type

function

Description

Executes a Python script.

Parameters

  • string file

load

Type

function

Description

Wrapper for getSolution in the Web API. After, launches the fantasy.cat solution with optional arguments.

Parameters

  • string solution
  • string output file name
  • string args

sleep

Type

function

Description

Sets the current callback to sleep for X amount of ms.

Parameters

  • number ms

calibrate

Type

function

Description

Sets the calibration flag of an FC2 solution to true. Overlays will not work unless this calibration flag has been set.

Returns

  • boolean

uncalibrate

Type

function

Description

Sets the calibration flag of an FC2 solution to false.


is_calibrated

Type

function

Description

Checks if the process is calibrated.

Returns

  • boolean

time

Type

function

Description

Current time in ms.

Returns

  • number

terminal

Type

function

Description

Executes a command in terminal/console and returns the result.

By enabling no_logger, you can prevent this method from displaying the terminal command in the logger. This can be useful for scripts that call fantasy.terminal consistently in the worker.

Parameters

  • string command
  • boolean multithread (optional)
  • boolean no_logger (optional)

Returns

  • string|nil

terminalu

Type

function

Description

Executes a command in terminal/console and returns the result. This function differs from terminal as this one executes as a non-root user. This function only works for Linux.

Parameters

  • string command
  • boolean multithread (optional)

Returns

  • string|nil

terminalr

Type

function

Description

Executes a command in terminal/console but doesn't wait to read the result. Both terminal and terminalu will only finish after the command output has been read. This function does not do that.

Parameters

  • string command
  • boolean multithread (optional)

Returns

  • string|nil

is_streamer_mode

Type

function

Returns

  • boolean

ipc

Type

function

Description

This will automatically install ZombieFC2 or FC2K depending on the protection level of the member.


timestamp

Type

function

Description

Converts timestamp to localtime and then returns it as a string.

Parameters

  • number unix_timestamp

Returns

  • string

set_worker

Type

function

Description

This does not change the worker speed of an individual script. Read more about this here (click me).

Parameters

  • number milliseconds

get_worker

Type

function

Returns

  • table
    • number speed
    • number ms
    • number tick

get_callback

Type

function

Description

Gets the last callback the Lua module triggered.

Returns

  • string

notification

Type

function

Description

This will create a notification based on your OS. Make sure you have a notification daemon installed on your Linux distro. On Windows, assure you have your Toast notifications enabled.

Parameters

  • string title
  • string message

Example

Lua
fantasy.notification( "FC2 ROBOT", "Hello World" )

overlay

Type

function

Description

This will make the overlay module request to copy another window and create an overlay for it.

Parameters

  • string target_window

Example

Lua
fantasy.overlay( "Team Fortress 2" )

protection

Type

function

Description

This will force set the protection mode for the user. This can reset if Sessions is recalibrated.

The number parameter accepts the following:

1: Standard Protection

2: Zombie

3: Kernel

Minimum mode cannot be activated with this function. Attempting to use any other values will create unwanted results.

Parameters

  • number

set_global

Type

function

Description

See guide (click me).

Passing an FC2 class through this method is not recommended. All values may not be passed properly, and there will be instability. Some classes such as address and entity contain a userdata value called address. You can pass that value as a global, then reinitialize the class by using address:new (or entity:new in the other case).

This method does not work in the on_loaded callback. Rather, FC2 will block you from executing it. Use on_scripts_loaded instead.

Parameters

  • number/string/table/nil/userdata

is_wayland

Type

function

Returns

  • boolean

skip_render_tick

Type

function

Description

This will make FC2 skip the next rendering tick. This is useful if you don't want FC2 to draw anything on your screen for this specific on_worker tick.


cryptography

Type

function

Returns

  • module

scripts

Type

function

Returns

  • module

input

Type

function

Returns

  • module

configuration

Type

function

Returns

  • module

steam

Type

function

Returns

  • module

file

Type

function

Returns

  • module

engine.entity_list

Type

function

Returns

  • module

engine.bsp

Type

function

Returns

  • module

engine.process

Type

function

Returns

  • module

engine.source

Type

function

Returns

  • module

engine.render

Type

function

Returns

  • module

engine.kernel

Type

function

Returns

  • module

engine.w2s

Type

function

Parameters

  • vector

Returns

  • vector

constelia

Type

function

Returns

  • module

http

Type

function

Returns

  • module

engine.zombie

Type

function

Returns

  • module

achievements

Type

function

Returns

  • module

window

Type

function

Parameters

  • string window_name/window_class

Returns

  • module