From 8a7baf793feb4e1f719d2264d2f4d5ffa42a7d1c Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Mon, 25 Feb 2019 11:19:23 -0500 Subject: [PATCH] doing some deep debugging --- DMS.xml | 6 ++--- StoryTest/init.dms | 23 ++++++++++++++++++ WeCanWriteEm.txt | 1 + data.dat | Bin 0 -> 36 bytes test.lua | 59 +++++++++------------------------------------ textadventure.dms | 3 ++- 6 files changed, 40 insertions(+), 52 deletions(-) create mode 100644 StoryTest/init.dms create mode 100644 data.dat diff --git a/DMS.xml b/DMS.xml index 82db8c6..28419f3 100644 --- a/DMS.xml +++ b/DMS.xml @@ -27,9 +27,9 @@ ENABLE DISABLE LOAD ENTRY USING VERSION as if then return and or True False leaking debugging warnings - ceil tan CSIM log10 sinh GOTOE lshift deg MUL QUIT cosh exp rad GOTO SUB log ADD JUMP error POW randomseed floor tanh max atan SKIP acos DIV abs rshif COMPARE print atan2 asin cos sin mod sqrt function getInput sleep getVar setVar + ceil tan CSIM log10 sinh GOTOE lshift deg MUL QUIT cosh exp rad GOTO SUB log ADD JUMP error POW randomseed floor tanh max atan SKIP acos DIV abs rshif COMPARE print atan2 asin cos sin mod sqrt function getInput sleep getVar setVar newThread _VERSION - + filesystem extendedDefine 00:: 01 02:: 03$ 04 05$ 06" 07 08" 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 @@ -44,7 +44,7 @@ - + diff --git a/StoryTest/init.dms b/StoryTest/init.dms new file mode 100644 index 0000000..a21b97f --- /dev/null +++ b/StoryTest/init.dms @@ -0,0 +1,23 @@ +ENTRY INIT +USING filesystem as bin +[INIT]{ + size = bin.fileExist("data.dat") + if size!=True then JUMP("CREATEDATA")|JUMP("HASDATA") +} +[CREATEDATA]{ + "We have no data! Let's create it!" + name = getInput("Please Enter your name: ") + file = bin.new() + file:addBlock(name,16) //Name + file:addBlock(100,4) //Money + file:addBlock("START",16) //Current Label + file:tofile("data.dat") + JUMP("HASDATA") +} +[HASDATA]{ + file = bin.load("data.dat") + name = file:getBlock("s",16) + money = file:getBlock("n",4) + label = file:getBlock("s",16) + "Name: $name$ Money: $money$ Label: $label$" +} \ No newline at end of file diff --git a/WeCanWriteEm.txt b/WeCanWriteEm.txt index e69de29..d707b92 100644 --- a/WeCanWriteEm.txt +++ b/WeCanWriteEm.txt @@ -0,0 +1 @@ +Testing stuff \ No newline at end of file diff --git a/data.dat b/data.dat new file mode 100644 index 0000000000000000000000000000000000000000..d30a13620d04b55260e2099c374551532b1d7ec2 GIT binary patch literal 36 XcmWHlOw40I0x3XtaEN122$C28RNDiM literal 0 HcmV?d00001 diff --git a/test.lua b/test.lua index bdb0a84..2947e49 100644 --- a/test.lua +++ b/test.lua @@ -2,24 +2,23 @@ package.path="?/init.lua;lua/?/init.lua;lua/?.lua;"..package.path local bin = require("bin") local multi = require("multi") require("parseManager") -require("bit") -test=parseManager:load("test.dms") +test=parseManager:load("StoryTest/init.dms") print(test:dump()) --Code would happen here anyway -local runner = function(block,t) - if not t then return nil end +t=test:next() +while t do if t.Type=="text" then io.write(t.text) io.read() - t=self:next() + t=test:next() elseif t.Type=="condition" then - t=self:next() + t=test:next() elseif t.Type=="assignment" then - t=self:next() + t=test:next() elseif t.Type=="label" then - t=self:next() + t=test:next() elseif t.Type=="method" then - t=self:next() + t=test:next() elseif t.Type=="choice" then print(t.text) for i=1,#t.choices do @@ -27,52 +26,16 @@ local runner = function(block,t) end io.write("Choose#: ") cm=tonumber(io.read()) - t=self:next(nil,cm,nil,t) + t=test:next(nil,cm,nil,t) elseif t.Type=="end" then if t.text=="leaking" then -- go directly to the block right under the current block if it exists - t=self:next() + t=test:next() else os.exit() end elseif t.Type=="error" then error(t.text) else - t=self:next() + t=test:next() end - return t end -test.mainRunner = runner -test.active = false -multi:newThread("Parse Manager Main State",function() - local dat = self:mainRunner(nil,self:next()) - while dat do - thread.skip() - dat = self:mainRunner(nil,dat) - end -end) -function test:run() - multi:mainloop() -end -test:define{ - sleep = function(self,n) - thread.sleep(n) - end, - newLightThread = function(self,block) - local state = parseManager:load(self.currentChunk.path) - state.mainENV = self.mainENV - state.mainRunner = runner - multi:newThread("Parse Manager State",function() - local dat = state:mainRunner(nil,state:next()) - while dat do - thread.skip() - dat = state:mainRunner(nil,dat) - end - end) - end -} ---End of injecting ---~ test:run() -multi:newThread("",function() - print("Threading works") -end) -multi:mainloop() diff --git a/textadventure.dms b/textadventure.dms index 7e2d107..fb2546e 100644 --- a/textadventure.dms +++ b/textadventure.dms @@ -13,7 +13,8 @@ ENTRY MAIN in = getInput("Enter Something: ") file = bin.new(in) file:tofile("WeCanWriteEm.txt") - test(1,2) + tt = test(1,2) + "Test: $tt$" "We are here now" "why no work" "?"