+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: O-Serious (OS) - IN PROGRESS

  1. #1
    Wirererer Dskodk's Avatar
    Join Date
    Sep 2009
    Location
    In a toilet somewhere
    Posts
    161

    Default O-Serious (OS) - IN PROGRESS

    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
    Attached Files Attached Files
    Last edited by Dskodk; 05-20-2010 at 07:11 PM.
    Blink.
    Breathe.
    Think.
    Discuss.
    You are unique.

  2. #2
    Ursus maritimus Drunkie's Avatar
    Join Date
    Feb 2009
    Location
    Canada
    Posts
    5,657
    Blog Entries
    1

    Default Re: O-Serious (OS) - IN PROGRESS

    You should name it Seashell OS.
    xD Kidding...

  3. #3
    Wirererer Dskodk's Avatar
    Join Date
    Sep 2009
    Location
    In a toilet somewhere
    Posts
    161

    Default Re: O-Serious (OS) - IN PROGRESS

    why?
    Blink.
    Breathe.
    Think.
    Discuss.
    You are unique.

  4. #4
    Wirererer Jake's Avatar
    Join Date
    Feb 2010
    Location
    owner():pos()
    Posts
    116

    Default Re: O-Serious (OS) - IN PROGRESS

    why?

    Ok, first thing, no talking about how its a 'shell' not an os, coz it gets really boring.
    You should name it Seashell OS.
    Quote Originally Posted by emspike View Post
    But yeah, you got ninja'd by SVN.

  5. #5
    Wirererer Dskodk's Avatar
    Join Date
    Sep 2009
    Location
    In a toilet somewhere
    Posts
    161

    Default Re: O-Serious (OS) - IN PROGRESS

    Oh... I get it now! =P I've finished the O-Serious Logic Core, and the first post has the code.
    To use it, enter a condition to be checked, e.g.
    Code:
    123 >= 49 | 278 == 114 & 225 < 500 | Hello != Google
    If this condition is correct, the chip will return true.
    In this case, it is false, so the True output will be 0.

    The way I get this, is by splitting up the condition by all of the "&" symbols, then go through a 'for' loop and split up all of those by a "|" symbol, then I check if the condition is true.

    First real progress! Yay!
    Last edited by Dskodk; 04-15-2010 at 08:14 PM.
    Blink.
    Breathe.
    Think.
    Discuss.
    You are unique.

  6. #6
    Wirererer Dskodk's Avatar
    Join Date
    Sep 2009
    Location
    In a toilet somewhere
    Posts
    161

    Default Re: O-Serious (OS) - IN PROGRESS

    Just finished the O-Serious Keyboard Core. First post updated. NOTE: O-Serious is very modular. The boot screen will actually be hiding processes that the chip does to set up everything. So the boot screen will actually be a proper boot screen, showing what O-Serious has done to start up.
    Blink.
    Breathe.
    Think.
    Discuss.
    You are unique.

  7. #7
    Wire Sofaking ktccd's Avatar
    Join Date
    Sep 2009
    Posts
    751

    Default Re: O-Serious (OS) - IN PROGRESS

    Code:
    123 >= 49 | 278 == 114 & 225 < 500 | Hello != Google
    This is false?
    I though | was "or", meaning this will return true if the string hello is not the same as the string google.

    Or is it perhaps that hello and google are variables?

  8. #8
    Lifetime Supporter Nikita's Avatar
    Join Date
    May 2009
    Posts
    769

    Default Re: O-Serious (OS) - IN PROGRESS

    I think the logic part needs some sort of parenthesis... or reverse-polish notation at least. I find current code kinda hard to debug.
    For example, in the above string, how does the OS know if it should do 123 >= 49 first, or 49 | 278? Maybe instead of (123 >= 49) | (278 == 114) it would want to do ((123>=49)|278)==114? Maybe that's just because I don't understand the order of operands there.

  9. #9
    Wire Sofaking ktccd's Avatar
    Join Date
    Sep 2009
    Posts
    751

    Default Re: O-Serious (OS) - IN PROGRESS

    You usually have a priority order
    () goes first
    then ^ I think
    * /
    + -
    >= <= == != && ||
    = += -= *= /= %= (I think %= is correct anyway)

    from highest to lowest ^^.

  10. #10
    Wirererer Dskodk's Avatar
    Join Date
    Sep 2009
    Location
    In a toilet somewhere
    Posts
    161

    Default Re: O-Serious (OS) - IN PROGRESS

    kttcd:
    uh... that's a lot of expression modifiers, and brackets will take a weebit to code, as I have no idea how to find both ( and ) in a string, and return both of their character positions. Also, that will require another for loop, making the code less ops efficient. Oh, I now see where you got them from, BEDMAS!
    Nikita:
    I am very sorry for my dreadful coding habits.
    The code splits the expression string up, by (in order) & , | It then proceeds to go through the expression checkers:
    Code:
            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"}
                else{True = 0 , exit()}
            }
    which return a value, and put it into an array, for further checking. I just realised that I don't need the array, If it doesn't exit, the condition is true.
    Code:
    else{True = 0 , exit()}
    makes sure of that.
    Um, making slow progress, still trying to get the 'echo' command working. It's not writing to the screen properly :O
    Blink.
    Breathe.
    Think.
    Discuss.
    You are unique.

+ Reply to Thread
Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots