Skip to content

Commit

Permalink
fixed queue_on_teleport warning
Browse files Browse the repository at this point in the history
  • Loading branch information
keplerHaloxx committed Nov 24, 2024
1 parent a75b1e0 commit 51bbadf
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 37 deletions.
52 changes: 35 additions & 17 deletions client/src/libs/Unc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ export declare function printconsole(
): void

// Enviornment
export declare function getgenv(): {[a: string]: any}
export declare function getgenv(): { [a: string]: any }
export declare function getrenv(): table
export declare function getreg(): table
export declare function getgc(include_tables?: boolean): table
export declare function getinstances(): table
export declare function getnilinstances(): table
export declare function getloadedmodules(): table
export declare function getconnections(signal: RBXScriptSignal): table
export declare function firesignal(signal: RBXScriptSignal, ...args: table): void
export declare function firesignal(
signal: RBXScriptSignal,
...args: table
): void
export declare function fireclickdetector(
detector: ClickDetector,
distance?: number,
Expand All @@ -40,7 +43,10 @@ export declare function firetouchinterest(
toggle?: number
): void
export declare function setscriptable(object: Instance, toggle: boolean): void
export declare function gethiddenproperty(object: Instance, property: string): void
export declare function gethiddenproperty(
object: Instance,
property: string
): void
export declare function sethiddenproperty(
object: Instance,
property: string,
Expand Down Expand Up @@ -106,7 +112,11 @@ 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 messagebox(
text: string,
title: string,
flag: number
): number
export declare function queue_on_teleport(script: string): undefined

// Reflection
Expand Down Expand Up @@ -242,18 +252,18 @@ type DrawingType =
type DrawingTypes<T extends DrawingType> = T extends "Line"
? LineDrawing
: T extends "Text"
? TextDrawing
: T extends "Image"
? ImageDrawing
: T extends "Circle"
? CircleDrawing
: T extends "Square"
? SquareDrawing
: T extends "Quad"
? QuadDrawing
: T extends "Triangle"
? TriangleDrawing
: BaseDrawing
? TextDrawing
: T extends "Image"
? ImageDrawing
: T extends "Circle"
? CircleDrawing
: T extends "Square"
? SquareDrawing
: T extends "Quad"
? QuadDrawing
: T extends "Triangle"
? TriangleDrawing
: BaseDrawing

interface DrawingConstructor {
new <T extends DrawingType>(type: T): DrawingTypes<T>
Expand Down Expand Up @@ -292,4 +302,12 @@ export declare const actors: {
getactors(): string
run_on_actor(actor: Actor, script: Script): string
is_parallel(): boolean
}
}

/**
* If any of the functions in `funcs` fail then the function will return false
* @param funcs Any number of parameters that are functions.
*/
export declare function ensure_executor_functions_access(
...funcs: ((...args: any[]) => any)[] // able to take in any type of function
): boolean
13 changes: 12 additions & 1 deletion client/src/libs/Unc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function Module.isreadonly(a1)
end

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

-- Cache library
Expand Down Expand Up @@ -460,4 +460,15 @@ Module.actors = {
end,
}

-- Runs the passed in functions and returns true if the functions were successful and false if not
function Module.ensure_executor_functions_access(...)
local funcs = { ... }
for i = 1, #funcs do
if not funcs[i] then
return false
end
end
return true
end

return Module
32 changes: 13 additions & 19 deletions client/src/main.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import destoryErrorLogging from "utils/destoryErrorLogging"
import Board from "utils/LuaFuncs/board"
import { Highlighter } from "utils/Highlighter"
import findBestMove from "utils/findBestMove"
import { Players, StarterGui } from "@rbxts/services"
import { queue_on_teleport } from "libs/Unc"
import { StarterGui } from "@rbxts/services"
import { ensure_executor_functions_access, queue_on_teleport } from "libs/Unc"

const notiBindableFunc = new Instance("BindableFunction")
notiBindableFunc.OnInvoke = (buttonName: string) => {
Expand Down Expand Up @@ -82,6 +82,16 @@ function bestMove() {

const mainTab = window.CreateTab("Main")

if (!ensure_executor_functions_access(queue_on_teleport))
mainTab.CreateParagraph({
Title: "Your executor probably doesn't support queue_on_teleport()",
Content: `Do not worry that is OKAY but you will have to manually re-execute the script on rejoin.`,
})
else
queue_on_teleport(
`loadstring(game:HttpGet("https://github.com/keplerHaloxx/roblox-chess-script/releases/latest/download/main.lua"))()`
)

mainTab.CreateSection("Status")

let botStatus = ""
Expand All @@ -103,7 +113,7 @@ const setBotOutputContent = (content: string) =>

mainTab.CreateSection("Run")

const runButton = mainTab.CreateButton({
mainTab.CreateButton({
Name: "Run",
Callback: bestMove,
})
Expand Down Expand Up @@ -145,19 +155,3 @@ const thinkTimeSlider = mainTab.CreateSlider({
})

Rayfield.LoadConfiguration()

// re-excecute script on rejoin
{
const [success, message] = pcall(() => {
queue_on_teleport(
`loadstring(game:HttpGet("https://github.com/keplerHaloxx/roblox-chess-script/releases/latest/download/main.lua"))()`
)
})
if (!success) {
Rayfield.Notify({
Title: "Your executor probably doesn't support queue_on_teleport()",
Content: `That is okay but you will have to manually re-execute the script on rejoin.`,
Image: "",
})
}
}

0 comments on commit 51bbadf

Please sign in to comment.