Skip to content

Commit 51bbadf

Browse files
committed
fixed queue_on_teleport warning
1 parent a75b1e0 commit 51bbadf

File tree

3 files changed

+60
-37
lines changed

3 files changed

+60
-37
lines changed

client/src/libs/Unc.d.ts

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ export declare function printconsole(
1919
): void
2020

2121
// Enviornment
22-
export declare function getgenv(): {[a: string]: any}
22+
export declare function getgenv(): { [a: string]: any }
2323
export declare function getrenv(): table
2424
export declare function getreg(): table
2525
export declare function getgc(include_tables?: boolean): table
2626
export declare function getinstances(): table
2727
export declare function getnilinstances(): table
2828
export declare function getloadedmodules(): table
2929
export declare function getconnections(signal: RBXScriptSignal): table
30-
export declare function firesignal(signal: RBXScriptSignal, ...args: table): void
30+
export declare function firesignal(
31+
signal: RBXScriptSignal,
32+
...args: table
33+
): void
3134
export declare function fireclickdetector(
3235
detector: ClickDetector,
3336
distance?: number,
@@ -40,7 +43,10 @@ export declare function firetouchinterest(
4043
toggle?: number
4144
): void
4245
export declare function setscriptable(object: Instance, toggle: boolean): void
43-
export declare function gethiddenproperty(object: Instance, property: string): void
46+
export declare function gethiddenproperty(
47+
object: Instance,
48+
property: string
49+
): void
4450
export declare function sethiddenproperty(
4551
object: Instance,
4652
property: string,
@@ -106,7 +112,11 @@ export declare function saveinstance(
106112
}
107113
): void
108114
export declare function decompile(script: Instance): string
109-
export declare function messagebox(text: string, title: string, flag: number): number
115+
export declare function messagebox(
116+
text: string,
117+
title: string,
118+
flag: number
119+
): number
110120
export declare function queue_on_teleport(script: string): undefined
111121

112122
// Reflection
@@ -242,18 +252,18 @@ type DrawingType =
242252
type DrawingTypes<T extends DrawingType> = T extends "Line"
243253
? LineDrawing
244254
: T extends "Text"
245-
? TextDrawing
246-
: T extends "Image"
247-
? ImageDrawing
248-
: T extends "Circle"
249-
? CircleDrawing
250-
: T extends "Square"
251-
? SquareDrawing
252-
: T extends "Quad"
253-
? QuadDrawing
254-
: T extends "Triangle"
255-
? TriangleDrawing
256-
: BaseDrawing
255+
? TextDrawing
256+
: T extends "Image"
257+
? ImageDrawing
258+
: T extends "Circle"
259+
? CircleDrawing
260+
: T extends "Square"
261+
? SquareDrawing
262+
: T extends "Quad"
263+
? QuadDrawing
264+
: T extends "Triangle"
265+
? TriangleDrawing
266+
: BaseDrawing
257267

258268
interface DrawingConstructor {
259269
new <T extends DrawingType>(type: T): DrawingTypes<T>
@@ -292,4 +302,12 @@ export declare const actors: {
292302
getactors(): string
293303
run_on_actor(actor: Actor, script: Script): string
294304
is_parallel(): boolean
295-
}
305+
}
306+
307+
/**
308+
* If any of the functions in `funcs` fail then the function will return false
309+
* @param funcs Any number of parameters that are functions.
310+
*/
311+
export declare function ensure_executor_functions_access(
312+
...funcs: ((...args: any[]) => any)[] // able to take in any type of function
313+
): boolean

client/src/libs/Unc.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ function Module.isreadonly(a1)
286286
end
287287

288288
function Module.queue_on_teleport(a1)
289-
queue_on_teleport(a1)
289+
queue_on_teleport(a1)
290290
end
291291

292292
-- Cache library
@@ -460,4 +460,15 @@ Module.actors = {
460460
end,
461461
}
462462

463+
-- Runs the passed in functions and returns true if the functions were successful and false if not
464+
function Module.ensure_executor_functions_access(...)
465+
local funcs = { ... }
466+
for i = 1, #funcs do
467+
if not funcs[i] then
468+
return false
469+
end
470+
end
471+
return true
472+
end
473+
463474
return Module

client/src/main.client.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import destoryErrorLogging from "utils/destoryErrorLogging"
55
import Board from "utils/LuaFuncs/board"
66
import { Highlighter } from "utils/Highlighter"
77
import findBestMove from "utils/findBestMove"
8-
import { Players, StarterGui } from "@rbxts/services"
9-
import { queue_on_teleport } from "libs/Unc"
8+
import { StarterGui } from "@rbxts/services"
9+
import { ensure_executor_functions_access, queue_on_teleport } from "libs/Unc"
1010

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

8383
const mainTab = window.CreateTab("Main")
8484

85+
if (!ensure_executor_functions_access(queue_on_teleport))
86+
mainTab.CreateParagraph({
87+
Title: "Your executor probably doesn't support queue_on_teleport()",
88+
Content: `Do not worry that is OKAY but you will have to manually re-execute the script on rejoin.`,
89+
})
90+
else
91+
queue_on_teleport(
92+
`loadstring(game:HttpGet("https://github.com/keplerHaloxx/roblox-chess-script/releases/latest/download/main.lua"))()`
93+
)
94+
8595
mainTab.CreateSection("Status")
8696

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

104114
mainTab.CreateSection("Run")
105115

106-
const runButton = mainTab.CreateButton({
116+
mainTab.CreateButton({
107117
Name: "Run",
108118
Callback: bestMove,
109119
})
@@ -145,19 +155,3 @@ const thinkTimeSlider = mainTab.CreateSlider({
145155
})
146156

147157
Rayfield.LoadConfiguration()
148-
149-
// re-excecute script on rejoin
150-
{
151-
const [success, message] = pcall(() => {
152-
queue_on_teleport(
153-
`loadstring(game:HttpGet("https://github.com/keplerHaloxx/roblox-chess-script/releases/latest/download/main.lua"))()`
154-
)
155-
})
156-
if (!success) {
157-
Rayfield.Notify({
158-
Title: "Your executor probably doesn't support queue_on_teleport()",
159-
Content: `That is okay but you will have to manually re-execute the script on rejoin.`,
160-
Image: "",
161-
})
162-
}
163-
}

0 commit comments

Comments
 (0)