Skip to content

VScript API #1229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

VScript API #1229

wants to merge 20 commits into from

Conversation

rtldg
Copy link
Collaborator

@rtldg rtldg commented Mar 6, 2025

NOTE: hasn't had a lot of testing in real scripts

Requirements (which are very incompatible with 64-bit):

Before vscript, checkpoints only saved these because maps couldn't do much:

  • targetname
  • classname
  • events (from FireInput & whatever)

(note the lack of player_speedmod disabled-buttons in there! I still need to add that TODO!)

Since you can do a lot of funky stuff with vscript (and a mapper is already asking for vscript checkpoint support), these are the vscript/squirrel API I think should be enough.

And thank gosh I added StringMap cp_cache_t::customdata for this kind of thing a million years ago!

// Timer provided functions:
// - function Timer_SetCheckpointCustomData(player, key, value)
//   Sets a string value.
//   (only usable from Timer_OnCheckpointSave)
// - function Timer_GetCheckpointCustomData(player, key)
//   Returns a string value.
//   (only usable from Timer_OnCheckpointLoadPre & Timer_OnCheckpointLoadPost)
// - function Timer_GetTime(player)
//   Can be used anywhere and returns a float for the player's current run time.
// - function Timer_GetStatus(player)
//   Can be used anywhere and returns an int. 0=stopped, 1=running, 2=paused.
// - function Timer_GetTrack(player)
//   Can be used anywhere and returns an int. 0=main, 1 or higher = a bonus track.

// Functions that maps can implement (with examples):
::Timer_OnStart <- function(player, track)
{
    PlayerReset()
}
::Timer_OnFinish <- function(player, track)
{
    // idk
}
::Timer_OnCheckpointSave <- function(player)
{
    Timer_SetCheckpointCustomData(player, "mystate", "floating")
}
::Timer_OnCheckpointLoadPre <- function(player)
{
    local mystate = Timer_GetCheckpointCustomData(player, "mystate")
    //do something with mystate here lol
}
::Timer_OnCheckpointLoadPost <- function(player)
{
    local mystate = Timer_GetCheckpointCustomData(player, "mystate")
    //do something with mystate here lol
}

TODO:

  • Indicate in OnCheckpointLoad if it's like a Segmented style checkpoint or like a kz checkpoint.
  • Figure out a good way to indicate that a checkpoint is actually from a bot or something idk...
    • Maybe let the mapper find it out in OnCheckpointLoad when parsing the custom data and finding it empty?

@rtldg rtldg changed the title VScript API for checkpoints VScript API Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant