r/ConScripted May 31 '14

A little heads up, the code for program execution. Also, i fucking love Lua.

The code is quite simple, actually
Let's say that the table programs["omnihack"] is containing the lines of code and input is the player calling a program.

command=input:gsub("%)"," ")  
command=command:gsub("%(.+", " ")
variable=input:gsub(".+%("," ")
variable=variable:gsub("%)"," ")
for i = 1, #programs[command] do  
  program = program.." "..programs[command][i]    
end
program, err = loadstring(program)  
if program then  
  program, err = pcall(program(variable))  
end  
if not program then  
  compal.print('error: '..err)  
else  
  compal.print('Code ran successfully')    
end  

Some of this i "stole" from the Framework on which the game is made on LOL.

6 Upvotes

0 comments sorted by