Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- path = arg[1]
- if(path == nil) then
- print("#param 1 : filePath")
- return
- end
- if(fs.exists(path) == false) then
- print("file "..path.." is not exist!")
- return
- end
- inf = io.open(path,"r") -- the source_code filename
- str = ""
- local str = inf.read(inf,"*all")
- inf.close(inf)
- fPort = peripheral.find("focal_port")
- lastIndex = 0
- index = -1
- leftBrackIndex = nil
- hexMap = { -- add pattern table to this table
- ["me"] = {["startDir"]="EAST",["angles"]="qaq"},
- ["{"] = {["startDir"]="WEST",["angles"]="qqq"},
- ["}"] = {["startDir"]="EAST",["angles"]="eee"},
- ["pos"] = {["startDir"]="EAST",["angles"]="aa"},
- ["sight"] = {["startDir"]="EAST",["angles"]="wa"},
- ["unpack"] = {["startDir"]="NORTH_WEST",["angles"]="qwaeawq"}
- }
- hexlist = {} -- the final table use to output
- while ( index ~= nil) do
- index = string.find(str,"\n", index + 2);
- if( index ~= nil) then
- cut = string.sub(str,lastIndex, index-1);
- else
- cut = string.sub(str,lastIndex, index);
- end
- cut = string.gsub(cut,"\n","")
- cut = string.gsub(cut," ","")
- lastIndex = index
- if(hexMap[cut] ~= nil) then
- table.insert(hexlist,hexMap[cut])
- else
- print(cut.." is illegal syntax")
- return
- end
- end
- -- out put final hexlist
- if(fPort ~= nil) then
- fPort.writeIota(hexlist)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement