Advertisement
Marlingaming

CCSPS IRON 3.0.0 - Program Reader

Jun 15th, 2023 (edited)
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. local arg = {...}
  2. --references
  3. local Calls = {"onCreation","onStart","onInteract","onKeyPress","onMessage"}
  4. local Functs = {"entity.create","entity.delete","entity.edit"}
  5. --variables
  6. local entities = {}
  7. local callbacks ={}
  8. local functions = {}
  9.  
  10. local Pass = {}
  11.  
  12. local function CheckFormula(formula)
  13. local Res = false
  14. if formula == "n" then Res = true end
  15. return Res
  16. end
  17.  
  18. local function RunEvent(event)
  19.  
  20. local Type = string.sub(event,1,string.find(event,"%.")-1)
  21.  
  22. local Op = string.sub(event, string.find(event,"%.")+1,string.find(event,"%<")-1)
  23. local ARGS = {}
  24. local I = 1
  25. local ag = {}
  26. repeat
  27. if I == 1 then ARGS[I] = string.find(event,"%<") elseif string.find(event,"%,",ARGS[I-1]+1) ~= nil then ARGS[I] = string.find(event,"%,",ARGS[I-1]+1) else ARGS[I] = string.find(event,"%>",ARGS[I-1]+1) end
  28. I = I + 1
  29. until string.find(event,"%,",ARGS[I-1]+1) == nil
  30.  
  31. for i = 2, #ARGS do
  32. ag[#ag][i] = string.sub(event,ARGS[i-1]+1,ARGS[i]-1)
  33. end
  34.  
  35. os.queueEvent("application","request",ag[1],ag[2],ag[3])
  36. end
  37.  
  38. local function runFunct(name)
  39. for i = 1, #functions do
  40. if functions[i][1] == name then if CheckFormula(functions[i][2]) == true then RunEvents(functions[i][3]) end end
  41. end
  42. end
  43.  
  44. local function ReadFunction(line)
  45.  
  46. local Call = string.sub(line, string.find(line,"%."),string.find(line,"%(")-1)
  47. local ARGS = {}
  48. local I = 1
  49.  
  50.  
  51. repeat
  52. if I == 1 then ARGS[I] = string.find(line,"%(") else ARGS[I] = string.find(line,"%,",ARGS[I-1]+1) end
  53. I = I + 1
  54. until string.find(line,"%,",ARGS[I-1]+1) == nil
  55. functions[#functions+1] = {}
  56. functions[#functions][1] = Call
  57. for i = 2, #ARGS do
  58. functions[#functions][i] = string.sub(line,ARGS[i-1]+1,ARGS[i]-1)
  59. end
  60.  
  61. end
  62.  
  63. local function ReadCallBack(line)
  64. local Call = string.sub(line,1,string.find(line,"%(")-1)
  65. local ARGS = {}
  66. local I = 1
  67.  
  68.  
  69. repeat
  70. if I == 1 then ARGS[I] = string.find(line,"%(") else ARGS[I] = string.find(line,"%,",ARGS[I-1]+1) end
  71. I = I + 1
  72. until string.find(line,"%,",ARGS[I-1]+1) == nil
  73. if Call == "onCreation" then--minimizable,fullscreen,title
  74. callbacks[#callbacks+1] = {"onCreation",ARGS[1],ARGS[2],ARGS[3]}
  75. elseif Call == "onStart" then--background,entitypath
  76. callbacks[#callbacks+1] = {"onStart",ARGS[1],ARGS[2]}
  77. elseif Call == "onInteract" then
  78.  
  79. elseif Call == "onKeyPress" then
  80.  
  81. elseif Call == "onMessage" then
  82.  
  83. end
  84. for i = 2, #ARGS do
  85. callbacks[#callbacks][i] = string.sub(line,ARGS[i-1]+1,ARGS[i]-1)
  86. end
  87. end
  88.  
  89. local function ReadEntity(line)
  90. local ARGS = {}
  91. local I = 1
  92. repeat
  93. if I == 1 then ARGS[I] = string.find(line,"%[") else ARGS[I] = string.find(line,"%,",ARGS[I-1]+1) end
  94. I = I + 1
  95. until string.find(line,"%,",ARGS[I-1]+1) == nil
  96. entities[#entities+1] = ARGS
  97. end
  98.  
  99. function ReadScript()
  100. local file = fs.open(arg[1],"r")
  101. local Line
  102. repeat
  103. Line = file.readLine()
  104. if Line ~= "==end==" then
  105. for i = 1, #Calls do
  106. if string.find(Line,Calls[i]) ~= nil then ReadCallBack(Line) end
  107. end
  108. if string.find(Line,"entity.add") ~= nil then ReadEntity(Line) end
  109. if string.find(Line,"funct.") ~= nil then ReadFunction(Line) end
  110. end
  111. until Line == "==end=="
  112. file.close()
  113. end
  114.  
  115. function Execute()
  116. if arg[2] == "call" then
  117. for i = 1, #callbacks do
  118. if arg[3] == callbacks[i][1] then os.queueEvent("application","read",callbacks[i][2],callbacks[i][3],callbacks[i][4],callbacks[i][5]) if arg[3] == "onStart" then os.queueEvent("application","data",entities) elseif arg[3] == "onInteraction" then runFunct(callbacks[i][3]) end end
  119. end
  120. end
  121. end
  122.  
  123. ReadScript()
  124. Execute()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement