Skip to content

Commit

Permalink
feat: re-execute on rejoin
Browse files Browse the repository at this point in the history
feat: saves settings
  • Loading branch information
keplerHaloxx committed Oct 12, 2024
1 parent 6338b79 commit d41e10f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions client/src/libs/Rayfield.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface Rayfield {
Key: string[]
}
}): Window
LoadConfiguration(): void
}

interface Window {
Expand Down
1 change: 1 addition & 0 deletions client/src/libs/Unc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export declare function saveinstance(
): void
export declare function decompile(script: Instance): string
export declare function messagebox(text: string, title: string, flag: number): number
export declare function queue_on_teleport(script: string): undefined

// Reflection
export declare function loadstring(chunk: string, chunk_name?: string): func
Expand Down
4 changes: 4 additions & 0 deletions client/src/libs/Unc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ function Module.isreadonly(a1)
return isreadonly(a1)
end

function Module.queue_on_teleport(a1)
queue_on_teleport(a1)
end

-- Cache library
Module.cache = {
replace = function(x, y)
Expand Down
21 changes: 17 additions & 4 deletions client/src/main.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import destoryErrorLogging from "utils/destoryErrorLogging"
import Board from "utils/LuaFuncs/board"
import { Highlighter } from "utils/Highlighter"
import findBestMove from "utils/findBestMove"
import { StarterGui } from "@rbxts/services"
import { Players, StarterGui } from "@rbxts/services"
import { queue_on_teleport } from "libs/Unc"

const notiBindableFunc = new Instance("BindableFunction")
notiBindableFunc.OnInvoke = (buttonName: string) => {
Expand All @@ -32,6 +33,11 @@ const window = Rayfield.CreateWindow({
Name: "Chess",
LoadingTitle: "Loading 🔃",
LoadingSubtitle: "By Haloxx",
ConfigurationSaving: {
Enabled: true,
FolderName: "keplerHaloxx-Chess",
FileName: "chess-script-config",
},
})

const board = new Board()
Expand Down Expand Up @@ -123,9 +129,7 @@ task.spawn(() => {
})

mainTab.CreateSection("Bot Options")
mainTab.CreateLabel(
"Maximum amount of time Stockfish has to think"
)
mainTab.CreateLabel("Maximum amount of time Stockfish has to think")
const thinkTimeSlider = mainTab.CreateSlider({
Name: "Max Think Time",
Range: [100, 5_000],
Expand All @@ -135,3 +139,12 @@ const thinkTimeSlider = mainTab.CreateSlider({
Increment: 10,
Callback: (value: number) => {},
})

Rayfield.LoadConfiguration()

// re-excecute script on rejoin
Players.LocalPlayer.OnTeleport.Connect(() => {
queue_on_teleport(
`loadstring(game:HttpGet("https://github.com/keplerHaloxx/roblox-chess-script/releases/latest/download/main.lua"))()`
)
})
2 changes: 0 additions & 2 deletions client/src/utils/findBestMove.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { HttpService, Workspace } from "@rbxts/services"
import HttpGet from "./HttpGet"
import Board from "./LuaFuncs/board"
import rprint from "./rprint"
import { Highlighter } from "./Highlighter"
import getPosFromResult from "./getPosFromResult"

interface MoveJsonData {
Expand Down

0 comments on commit d41e10f

Please sign in to comment.