diff --git a/src/005-passages/interactPassages.js b/src/005-passages/interactPassages.js index f700fc6b333fbb2f918e44938389aa4a3fe5fbde..ae740d0e25b175515a69f2fd84fa8e50e1568db8 100644 --- a/src/005-passages/interactPassages.js +++ b/src/005-passages/interactPassages.js @@ -72,3 +72,12 @@ new App.DomPassage( return App.UI.SlaveInteract.surgeryDegradation(getSlave(V.AS)); }, ["jump-from-safe"] ); + +new App.DomPassage( + "Import Slave", + () => { + V.nextButton = "Continue"; + V.nextLink = "Slave Interact"; + return App.UI.SlaveInteract.importSlave(); + }, ["jump-from-safe"] +); diff --git a/src/npc/importSlave.js b/src/npc/importSlave.js new file mode 100644 index 0000000000000000000000000000000000000000..47ec222b0590896ebcc2540c00bcff9976293054 --- /dev/null +++ b/src/npc/importSlave.js @@ -0,0 +1,21 @@ + +App.UI.SlaveInteract.importSlave = function() { + const el = new DocumentFragment(); + App.UI.DOM.appendNewElement("span", el, `Paste the code into the text box and press enter: `); + el.append( + App.UI.DOM.makeTextBox( + "", + v => { + if (v) { + const slave = eval(`({${v}})`); + slave.ID = generateSlaveID(); + newSlave(slave); + SlaveDatatypeCleanup(slave); + V.AS = slave.ID; + Engine.play("Slave Interact"); + } + } + ) + ); + return el; +}; diff --git a/src/npc/importSlave.tw b/src/npc/importSlave.tw deleted file mode 100644 index 4c635f4e666e49167cbcb6a80c42c95f78fbc6dc..0000000000000000000000000000000000000000 --- a/src/npc/importSlave.tw +++ /dev/null @@ -1,34 +0,0 @@ -:: Import Slave [nobr] - -<<set $nextButton = "Continue", $nextLink = "Slave Interact">> - -//Paste the code into the text box and click Apply// - -<br><br> - -<span id = "import"> -</span> -<<set $tempSlave = "">> -<<textbox "$tempSlave" $tempSlave>> -<<link "Apply">> - <<if (def $tempSlave) && ($tempSlave !== "")>> - <<set $tempSlave = eval('({' + $tempSlave + '})')>> - <<set $tempSlave.ID = generateSlaveID()>> - <<run newSlave($tempSlave)>> - <<replace #import>> - ''Slave imported successfully!'' - <br><br> - <</replace>> - <<unset $tempSlave>> - <<else>> - <<replace #import>> - ''Slave not imported!'' - <br><br> - <</replace>> - <</if>> -<</link>> -<br><br> -<<link "Continue">> - <<set $AS = $tempSlave.ID>> - <<goto "Slave Interact">> -<</link>>