diff --git a/msagent.js/src/character.ts b/msagent.js/src/character.ts index 5a897cf..2d98b5d 100644 --- a/msagent.js/src/character.ts +++ b/msagent.js/src/character.ts @@ -50,3 +50,9 @@ function agentCharacterParseACS(buffer: BufferStream): AcsData { export function agentCreateCharacter(data: Uint8Array): Agent { return new Agent(agentCharacterParseACS(new BufferStream(data))); } + +export async function agentCreateCharacterFromUrl(url: string) { + let res = await fetch(url); + let data = await res.arrayBuffer(); + return agentCreateCharacter(new Uint8Array(data)); +} \ No newline at end of file diff --git a/webapp/src/html/testbed.html b/webapp/src/html/testbed.html index 3f6c126..3736c2c 100644 --- a/webapp/src/html/testbed.html +++ b/webapp/src/html/testbed.html @@ -17,5 +17,12 @@ +
+
+
+
+ +
+
diff --git a/webapp/src/ts/testbed.ts b/webapp/src/ts/testbed.ts index 68fe71a..0629116 100644 --- a/webapp/src/ts/testbed.ts +++ b/webapp/src/ts/testbed.ts @@ -24,3 +24,15 @@ document.addEventListener("DOMContentLoaded", async () => { await msagent.agentInit(); console.log("msagent initalized!"); }) + +let form = document.getElementById("acsUrlForm") as HTMLFormElement; +form.addEventListener('submit', e => { + e.preventDefault(); + let url = (document.getElementById("acsUrl") as HTMLInputElement).value; + msagent.agentCreateCharacterFromUrl(url).then(agent => { + w.agents.push(agent); + agent.addToDom(document.body); + agent.show(); + console.log(`Loaded agent from ${url}`); + }); +}); \ No newline at end of file