Skip to content

Commit

Permalink
finish integrating mtutils
Browse files Browse the repository at this point in the history
  • Loading branch information
perkinslr committed Aug 8, 2022
1 parent d0c51ad commit b27c76f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 35 deletions.
5 changes: 5 additions & 0 deletions library/mtscript/public/InitAthena.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[h: args=(base64.decode(macro.args))]
[h: ns=json.get(args, 0)]
[h: serverName=json.get(args, 1)]

[h: js.evalNS(ns, "initAthena(MTScript.getMTScriptCallingArgs()[0])", serverName)]
6 changes: 1 addition & 5 deletions library/mtscript/public/SetServer.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
[h: args=(base64.decode(macro.args))]
[h: ns=json.get(args, 0)]
[h: serverName=json.get(args, 1)]

[h: js.evalNS(ns, "initAthena(MTScript.getMTScriptCallingArgs()[0])", serverName)]
[h: js.setServer(macro.args)]
30 changes: 0 additions & 30 deletions library/public/athena.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,36 +57,6 @@ catch (e) {
MapTool.chat.broadcast(e.stack)
}

/*
let playerName = MTScript.evalMacro('[r: playerName()]')
let athenaServer = null
let athenaClient
if (isServer) {
load("com.lp-programming.maptool.athena", "/public/athenaServer.js")
athenaServer = new AthenaServer()
athenaClient = new AthenaClient(true, athenaServer)
}
else
{
let link = "macro://GetServer@lib:com.lp-programming.maptool.utils/none/Impersonated?SetServer,com.lp-programming.maptool.athena,"+playerName
MTScript.setVariable("link", link)
MTScript.evalMacro(`[h: execLink(link, 1, "all")]`)
}
function initAthena() {
serverName = MTScript.getMTScriptCallingArgs()[0]
athenaClient = new AthenaClient(false, serverName)
}
*/


function load(namespace, scriptName) {
MTScript.setVariable("namespace", namespace);
MTScript.setVariable("scriptName", scriptName);
Expand Down
4 changes: 4 additions & 0 deletions library/public/setServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function errorWrapper(fn) {
return fn
}

console.log("loading athena");
try {
let serverInfo = JSON.parse(""+MTScript.evalMacro(`[r: getInfo("server")]`))
let isServer = serverInfo['personal server'] || serverInfo['hosting server']
Expand All @@ -28,6 +29,7 @@ try {
}

function setServer(name) {
console.log("setting server name to "+name);
serverName = name
}

Expand All @@ -41,6 +43,7 @@ try {
let target_name = args[2]

if (isServer) {
console.log("responding with server name");
let playerName = MTScript.evalMacro(`[r: getPlayerName()]`)
let link = `macro://${response_macro}@lib:${macro_library}/none/Impersonated?${playerName}`
MTScript.setVariable("link", link)
Expand All @@ -60,6 +63,7 @@ try {
MTScript.registerMacro("sendServer", errorWrapper(sendServer))

if (!isServer) {
console.log("requesting server info");
let playerName = MTScript.evalMacro(`[r: getPlayerName()]`)
let link = "macro://GetServer@lib:com.lp-programming.maptool.athena/none/Impersonated?SetServer,com.lp-programming.maptool.athena," + playerName
MTScript.setVariable("link", link)
Expand Down

0 comments on commit b27c76f

Please sign in to comment.