Fireye/disco-tools
1
2
Fork
You've already forked disco-tools
0
6 API
Fireye edited this page 2026年03月03日 22:16:28 -07:00
Table of Contents

API Reference

Autoloads

Disco Autoload

Global singleton and overall state manager.

Properties

state : StateRes

Global State object

entities : Dictionary[String, EntityRes]

Mirrors state.entities

missions: Dictionary[String, MissionRes]

Mirrors state.missions

events: Dictionary[String, EventRes]

Mirrors state.events

playerChecks : Dictionary[String, CheckRes]

Mirrors state.playerChecks

rollResult : bool

Automatically set to the result of the most recent roll.

Constants

SAVE_PATH : String

Defines the default path of the saved state. "user://disco_state.save"

INIT_PATH : String

Defines the default path of the initial saved state. "user://disco_state.save"

Enums

EEventStatus

Defines Event status state

  • NOT_OFFERED: Event not encountered yet
  • SUCCESS: Event succeeded, passed, or occured
  • FAILURE: Event Failed.
  • OTHER: Event status defined by statusString

EMissionStatus

Defines Mission status state

  • NOT_OFFERED: Mission not encountered yet
  • IN_PROGRESS: Mission started, but not finished
  • SUCCESS: Mission finished and succeeded
  • FAILURE: Mission Failed.
  • DENIED: Mission denied by player
  • OTHER: Mission status defined by statusString

Methods

resetState() -> void

Resets state to the initial set state on _ready, via INIT_PATH

save_state(path: String = SAVE_PATH) -> void

Saves State to path.

load_state(path: String = SAVE_PATH) -> void

Loads state from path into state.

boolEntityCheck(entity: String, check: String) -> bool

Gets a check from a specific NPC by name, and returns true if to_bool() is true

boolPlayerCheck(check: String) -> bool

Gets a check from playerChecks, and returns true if to_bool() is true

boolEventStatus(event: String, status:EEventStatus = EEventStatus.SUCCESS, statusStr: String = "") -> bool

Returns true if the given event status is equal to the status parameter.

If the statusString parameter is set, ignores the status and rather returns true if the event's statusString equals the statusStr parameter.

boolMissionStatus(mission: String, status:EMissionStatus = EMissionStatus.SUCCESS, statusStr: String = "") -> bool:

Returns true if the given mission status is equal to the status parameter.

If the statusString parameter is set, ignores the status and rather returns true if the mission's statusString equals the statusStr parameter.

async rollPlayer(check:String) -> bool

Rolls a check from playerChecks and returns the value. Also sets rollResult to the result.

async rollEntity(entity: String, check:String) -> bool

Rolls a check from a specific NPC by name and returns the value. Also sets rollResult to the result.

async roll(check: CheckRes) -> bool

Instantiate roll handler and execute a roll, awaiting the result. Automatically assigns the result to rollResult, then returns it as well.

rollOddsPlayer(check:String) -> int:

Gets the percent chance of success of a given check as an int from 0-100, given a check from playerChecks.

rollOddsEntity(entity: String, check:String) -> int:

Gets the percent chance of success of a given check as an int from 0-100, given a check from a provided entity.

getRollOdds(check: CheckRes) -> int

Gets the percent chance of success of a given check as an int from 0-100

DiscoDevTools Autoload

Handles plugin devtools.

Properties

DEV_force_checks: enum

Defines forced check behavior.

  • OFF: Checks roll as normal
  • SUCCESS: All checks will succeed
  • FAIL: All checks will fail

DEV_force_check_state: DEV_force_checks

Variable that stores the current force_check value.

Resources

DiscoRes

Empty organizational superclass for the resources contained within this plugin

StateRes

Central storage object for Disco state, accessed and set by users from disco_tools.tscn

Properties

rollResult: bool

Result from the most recent roll. True if that roll succeeded.

rollHandler: PackedScene

Complete roll handler scene. See ~/Systems/Default/default_handler.tscn and ~/Systems/Default/DefaultHandler.gd for an example implementation.

If you do not wish to make a Custom system, simply use ~/Systems/Default/default_handler.tscn here and DefaultCheckRes for all checks going forward.

events : Dictionary[String, EventRes]

Backing dictionary for eventList. Keys are automatically assigned from object names. Source of truth.

eventList : Array[EventRes]

User-facing EventRes input.

missions : Dictionary[String, MissionRes]

Backing dictionary for missionList. Keys are automatically assigned from object names. Source of truth.

missionList: Array[MissionRes]

User-facing MissionRes input.

entities: Dictionary[String, EntityRes]

Backing dictionary for entityList. Keys are automatically assigned from object names. Source of truth.

entityList: Array[EntityRes]

User-facing EntityRes input.

playerChecks: Dictionary[String, CheckRes]

Backing dictionary for playerCheckList. Keys are automatically assigned from object names. Source of truth.

playerCheckList: Array[CheckRes]

User-facing CheckRes input.

CheckRes

Empty base class for checks.

If you do not wish to make a Custom system, simply use DefaultCheckRes for all checks going forward. Otherwise, custom classes should inherit from CheckRes.

@abstract to_bool() -> bool

Returns true if the check was succeeded

EntityRes

TODO

EventRes

TODO

MissionRes

TODO

Systems

Default System

Example system implementation.

DefaultCheckRes

TODO

DefaultModRes

TODO

DefaultHandler

TODO

default_handler (scene)

TODO

UI

DevUI

Development UI that allows live-toggle of the DEV_force_check_state value.

Disco Tools is a free and open source plugin provided under MIT License by Kai Koehler and its wonderful Contributors. You can help make it better by reporting bugs and issues, improving the documentation, submitting patches for existing issues, or donating to my kofi