I use a player called "Gloria" on a big screen to show the players a ship viewscreen like in StarTrek.
I want to send a series of pings for the players to see where a radio transmission is coming from. It does not work.
In fact, I cannot seem to make a ping appear via the API at all!
Here's my code:
*on("ready", () => {
on("chat:message", (msg) => {
if (msg.type === "api" && msg.content === "!distress") {
startPinging();
}
});
const pingInterval = 5000; // Time between pings in milliseconds (5 seconds)
const duration = 55000; // Total duration in milliseconds (55 seconds)
const numPings = Math.floor(duration / pingInterval); // Number of pings to send
const graphicName = "GRID-1";
const bar3Value = "planet";
const startPinging = () => {
const graphic = findObjs({
_type: "graphic",
name: graphicName,
bar3_value: bar3Value
})[0];
if (!graphic) {
log(`No graphic found with name '${graphicName}' and bar3 value '${bar3Value}'`);
return;
}
const pageId = graphic.get("pageid");
const left = graphic.get("left");
const top = graphic.get("top");
for (let i = 0; i < numPings; i++) {
setTimeout(() => {
sendPing(left, top, pageId, '-Nj_Dg6a5ikbFyo8uxEM', false);
}, i * pingInterval);
}
};
});