How Can I Check If A Script Is Running
-
I want to make a if function which checks if a Script of mine is running. How can I do this?
-
@yletzter Like checking if a module is enabled or not?
-
@ali00035 yes I want a script which turns another IF running
-
mhm, here is something that checks the state of the scaffold module, prints "Ok" if it returns true
var Scaffold = moduleManager.getModule("Scaffold"); if (Scaffold.getState()) { Chat.print("Ok"); }
im on mobile rn
-
@ali00035 thank but is there a way to make a timeout on this? I already know how I can use timeouts (timeout(750, function () CODE) but I dont know how I can timeout a IF
-
Are you using Core?
-
@ali00035 yes
-
@ali00035
I tried this but it isnt working. I want that after 750ms the IF is runned
-
Uh, instead of the timeout function, you can use MSTimer
Here is a simple code:
var Timer = new MSTimer(); if (KOTL_A.getState()) { if (Timer.hasTimePassed(750)) { Chat.print("lol"); } }
fuck quickedit
-
@ali00035 I have no Idea what the MSTimer is... could you maybe tell me the finished code?
-
@yletzter Edited the post
-
@yletzter MSTimer stands for Mili-Second Timer
-
@yletzter this trick only works in instances like
function () X = true
and does the same thing as
function () { return X = true }
It is unique to Nashorn.
In this case you need to write
function () { if (module.state) print("xd") }
or
function () module.state && print("xd")
But if you check for it in onLoad then all scripts should already be loaded and you don't have to timeout.