Ok, first thing, no talking about how its a 'shell' not an os, coz it gets really boring.
O-Serious is a shell/os in E2 that will have really cool functions, such as 'if', CD support, and a proper file system for a HDD and CD's, called SFS (Serious File System). I have completely figured out how to do all of the above and more, I will be posting progress as I work through making O-Serious. If you have any ideas as to what I can add, please post them. My basic goal is to make a mix between Assembler and E2, in E2. Pointless, i know, but so is everything else in Gmod. Everything in O-Serious is wirelinked to the main chip, to save thinking about how to wire everything.
Completed Stuff:
File functions
Basic commands (echo, 12+78, ect)
Console screen writing functions
Logic Core - Code below
Variable setting (Var = Data)
My own Stack Handlers
User input
Advanced variable setting (e.g. Var = Data + Data)
Planned Stuff: (In proposed order)
SFS (Serious File System)
If functions
Community posted functions
Code for Logic Core:
Code:
@name O-Serious Logic Core
@inputs Condition:string
@outputs True Link:wirelink
@persist [Pipes And Andc Checknames E]:array [C Check]:table
@trigger Condition
if(first() | duped()){
C["if_equal",string] = "=="
C["if_n_equal",string] = "!="
C["if_greater",string] = ">"
C["if_lesser",string] = "<"
C["if_greater_e",string] = ">="
C["if_lesser_e",string] = "<="
}
#Dev test equation: "if @sec >= 30 then" will be sent to here looking like "21 >= 30" to check
And = Condition:explode("&")#Get rid of all the &'s in the formula, and split it up
for(I = 1 , And:count()){ #Go through all of the
#Looks like 1:
Pipes = And[I,string]:explode("|")
for(J = 1 , Pipes:count()){ # Go through all of the pipes
E = Pipes[J,string]:explode(" ")
Var1 = E[1,string]
Var1n = Var1:toNumber()
Cond = E[2,string]
Var2 = E[3,string]
Var2n = Var2:toNumber()
if(Cond == C["if_equal",string]){ # Equal
if(Var1 == Var2){Check[J + "P",number] = 1 , Checknames[J,string] = J + "P"}
else{True = 0 , exit()}
}
elseif(Cond == C["if_n_equal",string]){ # Not Equal
if(Var1 != Var2){Check[J + "P",number] = 1 , Checknames[J,string] = J + "P"}
else{True = 0 , exit()}
}
elseif(Cond == C["if_greater",string]){ # Greater
if(Var1n > Var2n) {Check[J + "P",number] = 1 , Checknames[J,string] = J + "P"}
else{True = 0 , exit()}
}
elseif(Cond == C["if_lesser",string]){ # Lesser
if(Var1n < Var2n) {Check[J + "P",number] = 1 , Checknames[J,string] = J + "P"}
else{True = 0 , exit()}
}
elseif(Cond == C["if_greater_e",string]){ # Greater or Equal
if(Var1n >= Var2n) {Check[J + "P",number] = 1 , Checknames[J,string] = J + "P"}
else{True = 0 , exit()}
}
elseif(Cond == C["if_lesser_e",string]){ # Lesser or Equal
if(Var1n <= Var2n) {Check[J + "P",number] = 1 , Checknames[J,string] = J + "P"}
}
}
#Ands, oh boy...
for(K = 1 , Checknames:count()){
if(Check[Checknames[K,string],number] == 1){
True = 1
}
else{True = 0 , exit()}
}
} Actual code
Code:
@name O-Serious
@inputs C:wirelink Char True
@outputs Condition:string
######## Basic pesists
@persist Command:string [W]:array Scroll WFI Varset WAIT InputStr:string Load Loads:string
######## Stack Persists
@persist [Stack FileData Proc]:array
######## Filesystem Persists
@persist [Datafile]:array [T]:table
@trigger all
#The file loading stuff:
runOnFile(1)
if(fileClk()){
if(Load){
W:pushString(":090:Finished: " + Loads)
Load = !Load
T[Loads,string] = fileRead(T["_prexif",string] + Loads)
Loads = ""
}
}
# O-Serious/O-Serious
if(first() | duped()){ #First thingies
T["_prefix",string] = "/oserious/"
T["_file",string] = "os.txt"
T["_loadcolor",string] = ":090:"
T["_frequency",string] = "100"
T["_version",string] = "0.1b"
T["_prtcolor",string] = ":909:"
T["_comcolor",string] = "99"
Scroll = 1
C[2038] = Scroll
W:pushString(T["_loadcolor",string] + "=":repeat(30))
W:pushString(T["_loadcolor",string] + "O-Serious (O-S) V" + T["_version",string])
Command = ""
WFI = 1
}
if(WFI){
if(Char & ~Char & Char!=145 & Char!=144 & Char!=154 & Char!=158 & Char!=127 & Char!=148 & Char!=9 & Char!=127 & Char!=13) {
Command += toChar(Char)
C:writeString(Command + " ",0,17,T["_comcolor",string]:toNumber(),0)
}
elseif(Char == 13){
Stack:pushString(Command)
#W:pushString(T[":" + "_prtcolor",string] + ":" + Command)
W:pushString(T["_prtcolor",string] + Command)
T[InputStr,string] = Command
Command = ""
WFI = 0
}
elseif(Char == 127 & Command:length()>=0) {
Command = Command:left(Command:length()-1)
C:writeString(Command + " ",0,17,T["_comcolor",string]:toNumber(),0)
}
}
#The Stack Handlers
if(clk("readstack")){
for(I = 1 , Stack:count()){#Getting rid of comments
Proc = Stack:shiftString():explode(" ")
FnS = Proc[1,string]:sub(1,2)
if(FnS != "//"){#If not a comment, Continue with the code,
break
}
else{#Skip, and pop on!
Stack:shift()
}
}
Com = Proc[1,string]
Proc:remove(1)
All = Proc:concat(" ")
#Here we make sure that the command isn't 'if' so we can be sure that we are setting a variable, not checking conditions.
if(Proc[1,string] == "="){
Alla = All:explode(" ")
Alla:remove(1)
All = Alla:concat(" ")
T[Com,string] = All
}
if(!Varset){
for(I = 1 , Proc:count()){
Strng = Proc[I,string]
First = Strng:sub(1,1)
After = Strng:sub(2,Strng:length())
RmString = T[After,string]
if(First == "@"){#Variable Replacing
Proc[I,string] = RmString
}
}
}
#Here is where you put the commands,
#Com is what you check for the command,
#Variables have already been replaced
#All other arguments are under Proc[X,string]
#Easy Writing!
#If you want to write to the screen,
#Use W:pushString("STRING")
#For color, put :XYZ: infront,
#X being
if(Com == "echo" | Com == "prt" | Com == "print"){
W:pushString(Proc:concat(" "))
}
elseif(Com == "cls" | Com == "clear"){
W = array()
C[2041] = 1
}
elseif(Com == "load" | Com == "toserver"){
W:pushString(":090:Loading file to OS memory...")
fileLoad(T["_prefix",string] + All + ".txt")
Load = 1
Loads = All
}
elseif(Com == "run" | Com == "exec"){
W:pushString("Executing: " + All)
SeriousData = T[All,string]:explode(";")
for(I = 1 , SeriousData:count()){
Stack:pushString(SeriousData[I,string])
}
}
elseif(Com == "input"){
WFI = 1
Inputstr = All
}
P = 0
Command = ""
}
if(Stack:count()>0) {
# Delay is capped to 120 seconds by default.
Time = clamp(WAIT,5,120000) WAIT = 0
if(!WFI) { timer("readstack",Time)}
Command = ""
}
else{WFI = 1}
if(W:count()>0 & !clk("readstack") & !clk("Char")){
while(W:count()>0) {
Print = W[1,string]
if(Print:index(1) == ":" & Print:index(5) == ":") {
Color = Print:sub(2,4):toNumber()
Print = Print:right(Print:length()-5):trim()
}
else{ Color = 999 }
Lines = ceil(Print:length()/30)
for(I=0,!Lines+Lines-1) {
C:writeString(Print:sub(I*31):trim(),0,17,Color,0) W:remove(1)
C[2038] = Scroll
}
}
Command = ""
} Usage:
Variable Setting:
To set variables, simply write the variable you want to set,
then the '=' sign, then input the data, simple.
Basic stuff:
Help: Starts the interactive helpdesk service
Echo: Prints to the screen
Prt: See 'Echo'
Print: See 'Echo'
Cls: Clears the screen
Input: Sets the argument to user input
File stuff:
Load: Loads a Serious Script file to the server, then immediatly to the OS memory, under the file name. (Without '/oserious/' or '.txt')
Toserver: See 'Load'
Run: Runs a Serious Script file
Exec: see 'Run'
Log: Logs the input to the file: data/e2files/oserious/log.txt
Global Variables:
Gread: Sets the memory slot at the first argument to the global variable afterwards.
Readg: see 'Gread'
Gset: Sets the global variable at the first argument to everything afterwards
SetG: see 'Gset'Attachment 7344
Bookmarks