M30W Programming Forum

M30W is a text-based version of Scratch

You are not logged in.

Announcement

This is the development forum for M30W (also known as Emerald, do not confuse with Emerald Programming Language).
Our Non-development forums are available here

M30W(Emerald) 0.3 is out! (Download) Requires Python 2.6 or higher.
Opal 0.3(A better command line M30W) is out! (Download) Requires Python 2.6 or higher.
M30W 0.3.6 GUI barebones (Download) Requires Python 2.6 or higher and wxPython
Diamond-2 RED2 GUI Barebones (Fancy M30W editor) s out! (Download) Requires .NET Framework 3.5 or higher, does not require Python
M30W++ GUI barebones (Java M30W) Alpha 1 is out! (Download) Requires Java.


Gershmer.net, our hosting, will close in February 2011. We have not fully decided what to do with our hosting after that, but we will tell you when we decide.

Adverts

Adverts

#26 2009-12-05 02:06:56

The-Whiz
Opal Creator
Registered: 2009-11-29
Posts: 48

Re: Opal

Gershmer wrote:

Okay then. I'll have the site updated in a bit.

OK... Thanks.


Creator of Opal

Offline

 

2009-12-05 02:06:56

AdBot
Advertisements

#27 2009-12-05 09:23:01

markyparky56
Hi...
From: Scotland
Registered: 2009-10-08
Posts: 910
Website

Re: Opal

ok, i did a test run and found a few small glitches, heres the avi file i did with hypercam.

http://www.gershmer.net/emeraldteam/mar … estrun.avi


I am A M30Wr.
I always get the last word.

Offline

 

#28 2009-12-05 14:22:23

Gershmer
Admin
From: Newton Centre, Massachusetts
Registered: 2009-10-08
Posts: 515
Website

Re: Opal

Opal 0.2 with one extra line of text
I added an extra line at start-up that says "type 'help' for commands"


http://card.ly/images/vcard-green-small.png

Offline

 

#29 2009-12-05 14:36:55

The-Whiz
Opal Creator
Registered: 2009-11-29
Posts: 48

Re: Opal

markyparky56 wrote:

ok, i did a test run and found a few small glitches, heres the avi file i did with hypercam.

http://www.gershmer.net/emeraldteam/mar … estrun.avi

It does look like a glitch... But it happens because you're adding to the current program...

I'll work on 0.3 now, and try to fix that...


Creator of Opal

Offline

 

#30 2009-12-05 16:22:20

markyparky56
Hi...
From: Scotland
Registered: 2009-10-08
Posts: 910
Website

Re: Opal

its kinda unavoidable since its done with command line, and you cant edit the previous commands.


I am A M30Wr.
I always get the last word.

Offline

 

#31 2009-12-05 16:49:42

The-Whiz
Opal Creator
Registered: 2009-11-29
Posts: 48

Re: Opal

markyparky56 wrote:

its kinda unavoidable since its done with command line, and you cant edit the previous commands.

I'm working on fixing it...


Creator of Opal

Offline

 

#32 2009-12-05 18:44:03

The-Whiz
Opal Creator
Registered: 2009-11-29
Posts: 48

Re: Opal

Opal 0.3 is out! (Download)


Creator of Opal

Offline

 

#33 2009-12-05 19:19:36

Gershmer
Admin
From: Newton Centre, Massachusetts
Registered: 2009-10-08
Posts: 515
Website

Re: Opal

The-Whiz wrote:

Opal 0.3 is out! (Download)

Whiz, you continue to amaze me.

Changelog wrote:

+ New program function
+ Saving and loading programs
+ Deleting lines
+ Editing lines
+ Inserting lines


http://card.ly/images/vcard-green-small.png

Offline

 

#34 2009-12-05 19:26:06

The-Whiz
Opal Creator
Registered: 2009-11-29
Posts: 48

Re: Opal

Gershmer wrote:

The-Whiz wrote:

Opal 0.3 is out! (Download)

Whiz, you continue to amaze me.

Changelog wrote:

+ New program function
+ Saving and loading programs
+ Deleting lines
+ Editing lines
+ Inserting lines

Thanks. :)


Creator of Opal

Offline

 

#35 2009-12-05 19:38:21

The-Whiz
Opal Creator
Registered: 2009-11-29
Posts: 48

Re: Opal

Oops, I forgot to change the title to Opal 0.3... It still says 0.2.


Creator of Opal

Offline

 

#36 2009-12-05 19:39:05

Gershmer
Admin
From: Newton Centre, Massachusetts
Registered: 2009-10-08
Posts: 515
Website

Re: Opal

The-Whiz wrote:

Oops, I forgot to change the title to Opal 0.3... It still says 0.2.

I noticed... :o


http://card.ly/images/vcard-green-small.png

Offline

 

#37 2009-12-05 19:48:23

Magnie
> I am Ninja! <
From: Polaris, the planet
Registered: 2009-10-08
Posts: 321
Website

Re: Opal

Can you post the code? I kinda like copying and pasting more than downloading. ;)


- I speak IF Common -
  ~ Magnie Mozios ~

Offline

 

#38 2009-12-05 19:53:29

The-Whiz
Opal Creator
Registered: 2009-11-29
Posts: 48

Re: Opal

Code:

# Start Program
# This section imports the modules Opal needs to function
import time
import random
import cPickle
# This is the opening sequence
print "Opal v0.3"
print "A text-based programming language"
print "Based on 'Emerald' by the Emerald Team"
print "Type 'help' for command list"
print "*Opal is sponsored by the Emerald Team*"
place_holder = raw_input("Hit enter to initiate Opal")
# This sets the variables and lists to default
valid_commands = ['print', 'wait', 'input', 'calc', 'set', 'save', 'load', 'delete line', 'edit line', 'insert line at']
commands = []
commands2 = []
variables = ['calc_value', 'random', 'random_min', 'random_max']
variablevalues = [0, 0, 1, 10]
operators = ['+', '-', '*', '/']
exitsure = 'n'
running_opal = 1
# This is the main loop
while running_opal == 1:
    command = raw_input(">>> ")
    # The print command
    if command[0] == valid_commands[0][0] and command[1] == valid_commands[0][1] and command[2] == valid_commands[0][2] and command[3] == valid_commands[0][3] and command[4] == valid_commands[0][4]:
        if command[6] == "'" or command[6] == '"':
            i = 7
            to_print = ''
            while i < len(command) - 1:
                to_print = to_print + command[i]
                i = i + 1
            commands.append('print')
            commands2.append(to_print)
        else:
            i = 6
            to_print = ''
            while i < len(command):
                to_print = to_print + command[i]
                i = i + 1
            commands.append('print')
            commands2.append('v(' + to_print + ')')
        # The wait command
    elif command[0] == valid_commands[1][0] and command[1] == valid_commands[1][1] and command[2] == valid_commands[1][2] and command[3] == valid_commands[1][3]:
        i = 5
        to_wait = ''
        while i < len(command) - 8:
            to_wait = to_wait + command[i]
            i = i + 1
        commands.append('wait')
        commands2.append(to_wait)
    # The input command
    elif command[0] == valid_commands[2][0] and command[1] == valid_commands[2][1] and command[2] == valid_commands[2][2] and command[3] == valid_commands[2][3] and command[4] == valid_commands[2][4]:
        i = 6
        to_input = ''
        while i < len(command):
            to_input = to_input + command[i]
            i = i + 1
        commands.append('input')
        commands2.append(to_input)
    # The calculator function
    elif command[0] == valid_commands[3][0] and command[1] == valid_commands[3][1] and command[2] == valid_commands[3][2] and command[3] == valid_commands[3][3]:
        commands.append('calc')
        commands2.append(command[4:len(command)])
    # The set command
    elif command[0] == valid_commands[4][0] and command[1] == valid_commands[4][1] and command[2] == valid_commands[4][2]:
        commands.append('set')
        commands2.append(command[4:len(command)])
    # The save command
    elif command[0] == valid_commands[5][0] and command[1] == valid_commands[5][1] and command[2] == valid_commands[5][2] and command[3] == valid_commands[5][3]:
        file_edit = command[5:] + ".opal"
        FILE = open(file_edit,"w")
        cPickle.dump(commands, FILE)
        cPickle.dump(commands2, FILE)
        FILE.close()
        print "Save successful!"
    # The load command
    elif command[0] == valid_commands[6][0] and command[1] == valid_commands[6][1] and command[2] == valid_commands[6][2] and command[3] == valid_commands[6][3]:
        file_edit = command[5:] + ".opal"
        FILE = open(file_edit,"r")
        commands = cPickle.load(FILE)
        commands2 = cPickle.load(FILE)
        FILE.close()
        print "Load successful!"
    # The delete line command
    elif command[0] == valid_commands[7][0] and command[1] == valid_commands[7][1] and command[2] == valid_commands[7][2] and command[3] == valid_commands[7][3] and command[4] == valid_commands[7][4] and command[5] == valid_commands[7][5] and command[6] == valid_commands[7][6] and command[7] == valid_commands[7][7] and command[8] == valid_commands[7][8] and command[9] == valid_commands[7][9] and command[10] == valid_commands[7][10]:
        commands[int(command[12:]) - 1] = []
        commands2[int(command[12:]) - 1] = []
    # The edit line command
    elif command[0] == valid_commands[8][0] and command[1] == valid_commands[8][1] and command[2] == valid_commands[8][2] and command[3] == valid_commands[8][3] and command[4] == valid_commands[8][4] and command[5] == valid_commands[8][5] and command[6] == valid_commands[8][6] and command[7] == valid_commands[8][7] and command[8] == valid_commands[8][8]:
        edit_line = int(command[10:]) - 1
        command = raw_input("... ")
        # The print command
        if command[0] == valid_commands[0][0] and command[1] == valid_commands[0][1] and command[2] == valid_commands[0][2] and command[3] == valid_commands[0][3] and command[4] == valid_commands[0][4]:
            if command[6] == "'" or command[6] == '"':
                i = 7
                to_print = ''
                while i < len(command) - 1:
                    to_print = to_print + command[i]
                    i = i + 1
                commands[edit_line] = 'print'
                commands2[edit_line] = to_print
            else:
                i = 6
                to_print = ''
                while i < len(command):
                    to_print = to_print + command[i]
                    i = i + 1
                commands[edit_line] = 'print'
                commands2[edit_line] = 'v(' + to_print + ')'
        # The wait command
        elif command[0] == valid_commands[1][0] and command[1] == valid_commands[1][1] and command[2] == valid_commands[1][2] and command[3] == valid_commands[1][3]:
            i = 5
            to_wait = ''
            while i < len(command) - 8:
                to_wait = to_wait + command[i]
                i = i + 1
            commands[edit_line] = 'wait'
            commands2[edit_line] = to_wait
        # The input command
        elif command[0] == valid_commands[2][0] and command[1] == valid_commands[2][1] and command[2] == valid_commands[2][2] and command[3] == valid_commands[2][3] and command[4] == valid_commands[2][4]:
            i = 6
            to_input = ''
            while i < len(command):
                to_input = to_input + command[i]
                i = i + 1
            commands[edit_line] = 'input'
            commands2[edit_line] = to_input
        # The calculator function
        elif command[0] == valid_commands[3][0] and command[1] == valid_commands[3][1] and command[2] == valid_commands[3][2] and command[3] == valid_commands[3][3]:
            commands[edit_line] = 'calc'
            commands2[edit_line] = command[4:len(command)]
        # The set command
        elif command[0] == valid_commands[4][0] and command[1] == valid_commands[4][1] and command[2] == valid_commands[4][2]:
            commands[edit_line] = 'set'
            commands2[edit_line] = command[4:len(command)]
        else:
            print "That is not a valid command."
    # The insert line command
    elif command[0] == valid_commands[9][0] and command[1] == valid_commands[9][1] and command[2] == valid_commands[9][2] and command[3] == valid_commands[9][3] and command[4] == valid_commands[9][4] and command[5] == valid_commands[9][5] and command[6] == valid_commands[9][6] and command[7] == valid_commands[9][7] and command[8] == valid_commands[9][8] and command[9] == valid_commands[9][9] and command[10] == valid_commands[9][10] and command[11] == valid_commands[9][11] and command[12] == valid_commands[9][12] and command[13] == valid_commands[9][13]:
        edit_line = int(command[15:]) - 1
        command = raw_input("... ")
        # The print command
        if command[0] == valid_commands[0][0] and command[1] == valid_commands[0][1] and command[2] == valid_commands[0][2] and command[3] == valid_commands[0][3] and command[4] == valid_commands[0][4]:
            if command[6] == "'" or command[6] == '"':
                i = 7
                to_print = ''
                while i < len(command) - 1:
                    to_print = to_print + command[i]
                    i = i + 1
                commands[edit_line:edit_line] = ['print']
                commands2[edit_line:edit_line] = [to_print]
            else:
                i = 6
                to_print = ''
                while i < len(command):
                    to_print = to_print + command[i]
                    i = i + 1
                commands[edit_line:edit_line] = ['print']
                commands2[edit_line:edit_line] = ['v(' + to_print + ')']
        # The wait command
        elif command[0] == valid_commands[1][0] and command[1] == valid_commands[1][1] and command[2] == valid_commands[1][2] and command[3] == valid_commands[1][3]:
            i = 5
            to_wait = ''
            while i < len(command) - 8:
                to_wait = to_wait + command[i]
                i = i + 1
            commands[edit_line:edit_line] = ['wait']
            commands2[edit_line:edit_line] = [to_wait]
        # The input command
        elif command[0] == valid_commands[2][0] and command[1] == valid_commands[2][1] and command[2] == valid_commands[2][2] and command[3] == valid_commands[2][3] and command[4] == valid_commands[2][4]:
            i = 6
            to_input = ''
            while i < len(command):
                to_input = to_input + command[i]
                i = i + 1
            commands[edit_line:edit_line] = ['input']
            commands2[edit_line:edit_line] = [to_input]
        # The calculator function
        elif command[0] == valid_commands[3][0] and command[1] == valid_commands[3][1] and command[2] == valid_commands[3][2] and command[3] == valid_commands[3][3]:
            commands[edit_line:edit_line] = ['calc']
            commands2[edit_line:edit_line] = [command[4:len(command)]]
        # The set command
        elif command[0] == valid_commands[4][0] and command[1] == valid_commands[4][1] and command[2] == valid_commands[4][2]:
            commands[edit_line:edit_line] = ['set']
            commands2[edit_line:edit_line] = [command[4:len(command)]]
        else:
            print "That is not a valid command."
    # The help command
    elif command == 'help':
        print "Opal help"
        print ""
        print "Here are Opal's commands:"
        print "print 'text'/[v] - prints text or the value of a variable"
        print "   print 'hello'"
        print "   print name"
        print "wait [#] seconds - waits the specified # of seconds"
        print "   wait 3 seconds"
        print "input [v] - allows the user to input the value for a variable"
        print "   input name"
        print "calc([#]/[v](+, -, *, /)[#]/[v]) - a calculator for numbers and variables;\nstores information in the 'calc_value' variable"
        print "   calc(4+4)"
        print "   calc(num+4)"
        print "   calc(num*2)"
        print "   calc(num1+num2)"
        print "   calc(calc_value+7)"
        print "set [v] to [#]/[v] - sets a variable to a certain value"
        print "   set x to 7"
        print "   set x to y"
        print "   set x to calc_value"
        print "   set x to 'hello'"
        print "random function - these variables are part of the random numbers fuction:"
        print "   random_max - the maximum choice for a random number"
        print "   random_min - the minimum choice for a random number"
        print "   random - picks a random number between v(random_min) and v(random_max)"
        print "save [n] - saves the program as the name entered; NO EXTENTION"
        print "   save test"
        print "load [n] - loads the program titles the name entered; NO EXTENTION"
        print "   load test"
        print "delete line [#] - deletes a certain line in the program"
        print "   delete line 1"
        print "edit line [#] - edits a certain line in the program"
        print "   edit line 3"
        print "insert line at [#] - inserts a a certain line into the program;\n1 inserts a line at the very beginning of the program" 
        print "   insert line at 1"
        print "new - deletes all program data and makes a new program"
        print "list - lists the program"
        print "run - runs the program"
        print "exit - exits Opal"
        print ""
    # The new program function
    elif command == 'new':
        commands = []
        commands2 = []
    # The list command
    elif command == 'list':
        print "Program:"
        print ""
        for i in range(0, len(commands)):
            if commands[i] == 'print':
                if commands2[i][0:2] == 'v(' and commands2[i][len(commands2[i]) - 1] == ')':
                    print "print " + commands2[i][2:len(commands2[i]) - 1]
                else:
                    print "print '" + commands2[i] + "'"
            elif commands[i] == 'wait':
                print "wait " + commands2[i] + " seconds"
            elif commands[i] == 'input':
                print "input" + commands2[i]
            elif commands[i] == 'calc':
                print "calc" + commands2[i]
            elif commands[i] == 'set':
                print "set " + commands2[i]
        print ""
    # The run command
    elif command == 'run':
        print "Running program:"
        print ""
        for i in range(0, len(commands)):
            variablevalues[1] = random.randint(int(variablevalues[2]), int(variablevalues[3]))
            if commands[i] == 'print':
                if commands2[i][0:2] == 'v(' and commands2[i][len(commands2[i]) - 1] == ')':
                    if commands2[i][2:len(commands2[i]) - 1] in variables:
                        for j in range(0, len(variables)):
                            if variables[j] == commands2[i][2:len(commands2[i]) - 1]:
                                print variablevalues[j]
                            else:
                                place_holder = 0
                    else:
                        print "Error - Undefined Variable"
                else:
                    print commands2[i]
            elif commands[i] == 'wait':
                time.sleep(int(commands2[i]))
            elif commands[i] == 'input':
                if commands2[i] in variables:
                    place_holder = 0
                else:
                    variables.append(commands2[i])
                    variablevalues.append('0')
                varvalue = raw_input("? ")
                for j in range(0, len(variables)):
                    if variables[j] == commands2[i]:
                        variablevalues[j] = varvalue
            elif commands[i] == 'calc':
                j = 0
                while commands2[i][j] not in operators:
                    j = j + 1
                calc1 = commands2[i][1:j]
                j = j + 1
                k = j
                while commands2[i][j] != ')':
                    j = j + 1
                calc2 = commands2[i][k:j]
                if calc1 in variables:
                    for j in range(0, len(variables)):
                        if variables[j] == calc1:
                            calc_num = variablevalues[j]
                    calc1 = calc_num
                if calc2 in variables:
                    for j in range(0, len(variables)):
                        if variables[j] == calc2:
                            calc_num = variablevalues[j]
                    calc2 = calc_num
                if commands2[i][k - 1] == '+':
                    variablevalues[0] = int(calc1) + int(calc2)
                elif commands2[i][k - 1] == '-':
                    variablevalues[0] = int(calc1) - int(calc2)
                elif commands2[i][k - 1] == '*':
                    variablevalues[0] = int(calc1) * int(calc2)
                elif commands2[i][k - 1] == '/':
                    variablevalues[0] = int(calc1) / int(calc2)
            elif commands[i] == 'set':
                j = 0
                while commands2[i][j] != ' ':
                    j = j + 1
                variable_add = commands2[i][0:j]
                if commands2[i][j + 4] == "'" or commands2[i][j + 4] == '"':
                    value_add = commands2[i][j + 5:len(commands2[i]) - 1]
                else:
                    value_add = commands2[i][j + 4:len(commands2[i])]
                    if value_add in variables:
                        for j in range(0, len(variables)):
                            if variables[j] == value_add:
                               value_add = variablevalues[j]
                if variable_add not in variables:
                    variables.append(variable_add)
                    variablevalues.append(value_add)
                else:
                    for j in range(0, len(variables)):
                        if variables[j] == variable_add:
                           variablevalues[j] = value_add
        print ""
    # The exit command
    elif command == 'exit':
        print "Are you sure? (Y/N)"
        exitsure = raw_input("")
        if exitsure == 'y':
            print "Thanks for using Opal!"
            running_opal = 0
    else:
        print "That is not a valid command."

It's very long...


Creator of Opal

Offline

 

#39 2009-12-05 19:54:41

Gershmer
Admin
From: Newton Centre, Massachusetts
Registered: 2009-10-08
Posts: 515
Website

Re: Opal

Code:

# Start Program
# This section imports the modules Opal needs to function
import time
import random
import cPickle
# This is the opening sequence
print "Opal v0.2"
print "A text-based programming language"
print "Based on 'Emerald' by the Emerald Team"
print "Type 'help' for command list"
print "*Opal is sponsored by the Emerald Team*"
place_holder = raw_input("Hit enter to initiate Opal")
# This sets the variables and lists to default
valid_commands = ['print', 'wait', 'input', 'calc', 'set', 'save', 'load', 'delete line', 'edit line', 'insert line at']
commands = []
commands2 = []
variables = ['calc_value', 'random', 'random_min', 'random_max']
variablevalues = [0, 0, 1, 10]
operators = ['+', '-', '*', '/']
exitsure = 'n'
running_opal = 1
# This is the main loop
while running_opal == 1:
    command = raw_input(">>> ")
    # The print command
    if command[0] == valid_commands[0][0] and command[1] == valid_commands[0][1] and command[2] == valid_commands[0][2] and command[3] == valid_commands[0][3] and command[4] == valid_commands[0][4]:
        if command[6] == "'" or command[6] == '"':
            i = 7
            to_print = ''
            while i < len(command) - 1:
                to_print = to_print + command[i]
                i = i + 1
            commands.append('print')
            commands2.append(to_print)
        else:
            i = 6
            to_print = ''
            while i < len(command):
                to_print = to_print + command[i]
                i = i + 1
            commands.append('print')
            commands2.append('v(' + to_print + ')')
        # The wait command
    elif command[0] == valid_commands[1][0] and command[1] == valid_commands[1][1] and command[2] == valid_commands[1][2] and command[3] == valid_commands[1][3]:
        i = 5
        to_wait = ''
        while i < len(command) - 8:
            to_wait = to_wait + command[i]
            i = i + 1
        commands.append('wait')
        commands2.append(to_wait)
    # The input command
    elif command[0] == valid_commands[2][0] and command[1] == valid_commands[2][1] and command[2] == valid_commands[2][2] and command[3] == valid_commands[2][3] and command[4] == valid_commands[2][4]:
        i = 6
        to_input = ''
        while i < len(command):
            to_input = to_input + command[i]
            i = i + 1
        commands.append('input')
        commands2.append(to_input)
    # The calculator function
    elif command[0] == valid_commands[3][0] and command[1] == valid_commands[3][1] and command[2] == valid_commands[3][2] and command[3] == valid_commands[3][3]:
        commands.append('calc')
        commands2.append(command[4:len(command)])
    # The set command
    elif command[0] == valid_commands[4][0] and command[1] == valid_commands[4][1] and command[2] == valid_commands[4][2]:
        commands.append('set')
        commands2.append(command[4:len(command)])
    # The save command
    elif command[0] == valid_commands[5][0] and command[1] == valid_commands[5][1] and command[2] == valid_commands[5][2] and command[3] == valid_commands[5][3]:
        file_edit = command[5:] + ".opal"
        FILE = open(file_edit,"w")
        cPickle.dump(commands, FILE)
        cPickle.dump(commands2, FILE)
        FILE.close()
        print "Save successful!"
    # The load command
    elif command[0] == valid_commands[6][0] and command[1] == valid_commands[6][1] and command[2] == valid_commands[6][2] and command[3] == valid_commands[6][3]:
        file_edit = command[5:] + ".opal"
        FILE = open(file_edit,"r")
        commands = cPickle.load(FILE)
        commands2 = cPickle.load(FILE)
        FILE.close()
        print "Load successful!"
    # The delete line command
    elif command[0] == valid_commands[7][0] and command[1] == valid_commands[7][1] and command[2] == valid_commands[7][2] and command[3] == valid_commands[7][3] and command[4] == valid_commands[7][4] and command[5] == valid_commands[7][5] and command[6] == valid_commands[7][6] and command[7] == valid_commands[7][7] and command[8] == valid_commands[7][8] and command[9] == valid_commands[7][9] and command[10] == valid_commands[7][10]:
        commands[int(command[12:]) - 1] = []
        commands2[int(command[12:]) - 1] = []
    # The edit line command
    elif command[0] == valid_commands[8][0] and command[1] == valid_commands[8][1] and command[2] == valid_commands[8][2] and command[3] == valid_commands[8][3] and command[4] == valid_commands[8][4] and command[5] == valid_commands[8][5] and command[6] == valid_commands[8][6] and command[7] == valid_commands[8][7] and command[8] == valid_commands[8][8]:
        edit_line = int(command[10:]) - 1
        command = raw_input("... ")
        # The print command
        if command[0] == valid_commands[0][0] and command[1] == valid_commands[0][1] and command[2] == valid_commands[0][2] and command[3] == valid_commands[0][3] and command[4] == valid_commands[0][4]:
            if command[6] == "'" or command[6] == '"':
                i = 7
                to_print = ''
                while i < len(command) - 1:
                    to_print = to_print + command[i]
                    i = i + 1
                commands[edit_line] = 'print'
                commands2[edit_line] = to_print
            else:
                i = 6
                to_print = ''
                while i < len(command):
                    to_print = to_print + command[i]
                    i = i + 1
                commands[edit_line] = 'print'
                commands2[edit_line] = 'v(' + to_print + ')'
        # The wait command
        elif command[0] == valid_commands[1][0] and command[1] == valid_commands[1][1] and command[2] == valid_commands[1][2] and command[3] == valid_commands[1][3]:
            i = 5
            to_wait = ''
            while i < len(command) - 8:
                to_wait = to_wait + command[i]
                i = i + 1
            commands[edit_line] = 'wait'
            commands2[edit_line] = to_wait
        # The input command
        elif command[0] == valid_commands[2][0] and command[1] == valid_commands[2][1] and command[2] == valid_commands[2][2] and command[3] == valid_commands[2][3] and command[4] == valid_commands[2][4]:
            i = 6
            to_input = ''
            while i < len(command):
                to_input = to_input + command[i]
                i = i + 1
            commands[edit_line] = 'input'
            commands2[edit_line] = to_input
        # The calculator function
        elif command[0] == valid_commands[3][0] and command[1] == valid_commands[3][1] and command[2] == valid_commands[3][2] and command[3] == valid_commands[3][3]:
            commands[edit_line] = 'calc'
            commands2[edit_line] = command[4:len(command)]
        # The set command
        elif command[0] == valid_commands[4][0] and command[1] == valid_commands[4][1] and command[2] == valid_commands[4][2]:
            commands[edit_line] = 'set'
            commands2[edit_line] = command[4:len(command)]
        else:
            print "That is not a valid command."
    # The insert line command
    elif command[0] == valid_commands[9][0] and command[1] == valid_commands[9][1] and command[2] == valid_commands[9][2] and command[3] == valid_commands[9][3] and command[4] == valid_commands[9][4] and command[5] == valid_commands[9][5] and command[6] == valid_commands[9][6] and command[7] == valid_commands[9][7] and command[8] == valid_commands[9][8] and command[9] == valid_commands[9][9] and command[10] == valid_commands[9][10] and command[11] == valid_commands[9][11] and command[12] == valid_commands[9][12] and command[13] == valid_commands[9][13]:
        edit_line = int(command[15:]) - 1
        command = raw_input("... ")
        # The print command
        if command[0] == valid_commands[0][0] and command[1] == valid_commands[0][1] and command[2] == valid_commands[0][2] and command[3] == valid_commands[0][3] and command[4] == valid_commands[0][4]:
            if command[6] == "'" or command[6] == '"':
                i = 7
                to_print = ''
                while i < len(command) - 1:
                    to_print = to_print + command[i]
                    i = i + 1
                commands[edit_line:edit_line] = ['print']
                commands2[edit_line:edit_line] = [to_print]
            else:
                i = 6
                to_print = ''
                while i < len(command):
                    to_print = to_print + command[i]
                    i = i + 1
                commands[edit_line:edit_line] = ['print']
                commands2[edit_line:edit_line] = ['v(' + to_print + ')']
        # The wait command
        elif command[0] == valid_commands[1][0] and command[1] == valid_commands[1][1] and command[2] == valid_commands[1][2] and command[3] == valid_commands[1][3]:
            i = 5
            to_wait = ''
            while i < len(command) - 8:
                to_wait = to_wait + command[i]
                i = i + 1
            commands[edit_line:edit_line] = ['wait']
            commands2[edit_line:edit_line] = [to_wait]
        # The input command
        elif command[0] == valid_commands[2][0] and command[1] == valid_commands[2][1] and command[2] == valid_commands[2][2] and command[3] == valid_commands[2][3] and command[4] == valid_commands[2][4]:
            i = 6
            to_input = ''
            while i < len(command):
                to_input = to_input + command[i]
                i = i + 1
            commands[edit_line:edit_line] = ['input']
            commands2[edit_line:edit_line] = [to_input]
        # The calculator function
        elif command[0] == valid_commands[3][0] and command[1] == valid_commands[3][1] and command[2] == valid_commands[3][2] and command[3] == valid_commands[3][3]:
            commands[edit_line:edit_line] = ['calc']
            commands2[edit_line:edit_line] = [command[4:len(command)]]
        # The set command
        elif command[0] == valid_commands[4][0] and command[1] == valid_commands[4][1] and command[2] == valid_commands[4][2]:
            commands[edit_line:edit_line] = ['set']
            commands2[edit_line:edit_line] = [command[4:len(command)]]
        else:
            print "That is not a valid command."
    # The help command
    elif command == 'help':
        print "Opal help"
        print ""
        print "Here are Opal's commands:"
        print "print 'text'/[v] - prints text or the value of a variable"
        print "   print 'hello'"
        print "   print name"
        print "wait [#] seconds - waits the specified # of seconds"
        print "   wait 3 seconds"
        print "input [v] - allows the user to input the value for a variable"
        print "   input name"
        print "calc([#]/[v](+, -, *, /)[#]/[v]) - a calculator for numbers and variables;\nstores information in the 'calc_value' variable"
        print "   calc(4+4)"
        print "   calc(num+4)"
        print "   calc(num*2)"
        print "   calc(num1+num2)"
        print "   calc(calc_value+7)"
        print "set [v] to [#]/[v] - sets a variable to a certain value"
        print "   set x to 7"
        print "   set x to y"
        print "   set x to calc_value"
        print "   set x to 'hello'"
        print "random function - these variables are part of the random numbers fuction:"
        print "   random_max - the maximum choice for a random number"
        print "   random_min - the minimum choice for a random number"
        print "   random - picks a random number between v(random_min) and v(random_max)"
        print "save [n] - saves the program as the name entered; NO EXTENTION"
        print "   save test"
        print "load [n] - loads the program titles the name entered; NO EXTENTION"
        print "   load test"
        print "delete line [#] - deletes a certain line in the program"
        print "   delete line 1"
        print "edit line [#] - edits a certain line in the program"
        print "   edit line 3"
        print "insert line at [#] - inserts a a certain line into the program;\n1 inserts a line at the very beginning of the program" 
        print "   insert line at 1"
        print "new - deletes all program data and makes a new program"
        print "list - lists the program"
        print "run - runs the program"
        print "exit - exits Opal"
        print ""
    # The new program function
    elif command == 'new':
        commands = []
        commands2 = []
    # The list command
    elif command == 'list':
        print "Program:"
        print ""
        for i in range(0, len(commands)):
            if commands[i] == 'print':
                if commands2[i][0:2] == 'v(' and commands2[i][len(commands2[i]) - 1] == ')':
                    print "print " + commands2[i][2:len(commands2[i]) - 1]
                else:
                    print "print '" + commands2[i] + "'"
            elif commands[i] == 'wait':
                print "wait " + commands2[i] + " seconds"
            elif commands[i] == 'input':
                print "input" + commands2[i]
            elif commands[i] == 'calc':
                print "calc" + commands2[i]
            elif commands[i] == 'set':
                print "set " + commands2[i]
        print ""
    # The run command
    elif command == 'run':
        print "Running program:"
        print ""
        for i in range(0, len(commands)):
            variablevalues[1] = random.randint(int(variablevalues[2]), int(variablevalues[3]))
            if commands[i] == 'print':
                if commands2[i][0:2] == 'v(' and commands2[i][len(commands2[i]) - 1] == ')':
                    if commands2[i][2:len(commands2[i]) - 1] in variables:
                        for j in range(0, len(variables)):
                            if variables[j] == commands2[i][2:len(commands2[i]) - 1]:
                                print variablevalues[j]
                            else:
                                place_holder = 0
                    else:
                        print "Error - Undefined Variable"
                else:
                    print commands2[i]
            elif commands[i] == 'wait':
                time.sleep(int(commands2[i]))
            elif commands[i] == 'input':
                if commands2[i] in variables:
                    place_holder = 0
                else:
                    variables.append(commands2[i])
                    variablevalues.append('0')
                varvalue = raw_input("? ")
                for j in range(0, len(variables)):
                    if variables[j] == commands2[i]:
                        variablevalues[j] = varvalue
            elif commands[i] == 'calc':
                j = 0
                while commands2[i][j] not in operators:
                    j = j + 1
                calc1 = commands2[i][1:j]
                j = j + 1
                k = j
                while commands2[i][j] != ')':
                    j = j + 1
                calc2 = commands2[i][k:j]
                if calc1 in variables:
                    for j in range(0, len(variables)):
                        if variables[j] == calc1:
                            calc_num = variablevalues[j]
                    calc1 = calc_num
                if calc2 in variables:
                    for j in range(0, len(variables)):
                        if variables[j] == calc2:
                            calc_num = variablevalues[j]
                    calc2 = calc_num
                if commands2[i][k - 1] == '+':
                    variablevalues[0] = int(calc1) + int(calc2)
                elif commands2[i][k - 1] == '-':
                    variablevalues[0] = int(calc1) - int(calc2)
                elif commands2[i][k - 1] == '*':
                    variablevalues[0] = int(calc1) * int(calc2)
                elif commands2[i][k - 1] == '/':
                    variablevalues[0] = int(calc1) / int(calc2)
            elif commands[i] == 'set':
                j = 0
                while commands2[i][j] != ' ':
                    j = j + 1
                variable_add = commands2[i][0:j]
                if commands2[i][j + 4] == "'" or commands2[i][j + 4] == '"':
                    value_add = commands2[i][j + 5:len(commands2[i]) - 1]
                else:
                    value_add = commands2[i][j + 4:len(commands2[i])]
                    if value_add in variables:
                        for j in range(0, len(variables)):
                            if variables[j] == value_add:
                               value_add = variablevalues[j]
                if variable_add not in variables:
                    variables.append(variable_add)
                    variablevalues.append(value_add)
                else:
                    for j in range(0, len(variables)):
                        if variables[j] == variable_add:
                           variablevalues[j] = value_add
        print ""
    # The exit command
    elif command == 'exit':
        print "Are you sure? (Y/N)"
        exitsure = raw_input("")
        if exitsure == 'y':
            print "Thanks for using Opal!"
            running_opal = 0
    else:
        print "That is not a valid command."

The saving is cPickle based.


http://card.ly/images/vcard-green-small.png

Offline

 

#40 2009-12-05 19:57:35

Magnie
> I am Ninja! <
From: Polaris, the planet
Registered: 2009-10-08
Posts: 321
Website

Re: Opal

We need to try saving and loading without Pickle. >.>


- I speak IF Common -
  ~ Magnie Mozios ~

Offline

 

#41 2009-12-05 20:00:43

Gershmer
Admin
From: Newton Centre, Massachusetts
Registered: 2009-10-08
Posts: 515
Website

Re: Opal

Magnie wrote:

We need to try saving and loading without Pickle. >.>

Right now we're just getting Opal up to speed, so it can be Emerald 0.4. There are already a lot of new commands, we just need to add some sort of GUI window like in Emerald 0.3.

@_____@


http://card.ly/images/vcard-green-small.png

Offline

 

#42 2009-12-05 20:13:57

Magnie
> I am Ninja! <
From: Polaris, the planet
Registered: 2009-10-08
Posts: 321
Website

Re: Opal

Also, everything needs to be in defs.... :/


- I speak IF Common -
  ~ Magnie Mozios ~

Offline

 

#43 2009-12-09 23:05:09

cds56
THE TOOOTH! THE TOOOOOOOOOOOOTH!!!!!
From: Canamadiana
Registered: 2009-11-07
Posts: 423

Re: Opal

I think that the GUI and console things should be separate utils. like python is.


http://www.catb.org/esr/faqs/glider.png

Offline

 

#44 2009-12-10 16:33:51

markyparky56
Hi...
From: Scotland
Registered: 2009-10-08
Posts: 910
Website

Re: Opal

cds56 wrote:

I think that the GUI and console things should be separate utils. like python is.

ARE.YOU.MAD? The command line is just annoying, having commands that are, edit line, insert line, delete line, are just annoying! You dont get the, in scratch, you don't get them in any language! (That i know of)


I am A M30Wr.
I always get the last word.

Offline

 

#45 2009-12-10 21:13:06

cds56
THE TOOOTH! THE TOOOOOOOOOOOOTH!!!!!
From: Canamadiana
Registered: 2009-11-07
Posts: 423

Re: Opal

ARE.YOU.MAD is a legal variable name in CPPEv0.2.8
and what you said made very few sense

opal is ultracool. but the functions that it provides can easily be replicated in CPPE, but that would mean that CPPE would be CPPO(cplusplus opal)
and not emerald, therefor making the acronym less cool and more drool.

ah yeah, opal is a fair amount of genius.


http://www.catb.org/esr/faqs/glider.png

Offline

 

#46 2009-12-10 22:28:27

The-Whiz
Opal Creator
Registered: 2009-11-29
Posts: 48

Re: Opal

cds56 wrote:

ARE.YOU.MAD is a legal variable name in CPPEv0.2.8
and what you said made very few sense

opal is ultracool. but the functions that it provides can easily be replicated in CPPE, but that would mean that CPPE would be CPPO(cplusplus opal)
and not emerald, therefor making the acronym less cool and more drool.

ah yeah, opal is a fair amount of genius.

Why, thank you.


Creator of Opal

Offline

 

#47 2009-12-15 19:50:04

markyparky56
Hi...
From: Scotland
Registered: 2009-10-08
Posts: 910
Website

Re: Opal

*smashing head off desk*

how long untill we can get rid of the command line? its not good looking and its not very easy to edit the scripting past in it, everything has to be down to th letter to do that, so not very good for beginners and what happens if you miss a letter out? you have to do it all over again!


I am A M30Wr.
I always get the last word.

Offline

 

#48 2009-12-15 19:55:16

cds56
THE TOOOTH! THE TOOOOOOOOOOOOTH!!!!!
From: Canamadiana
Registered: 2009-11-07
Posts: 423

Re: Opal

I Go With Markys Idea. We Need A Gui Scripter


http://www.catb.org/esr/faqs/glider.png

Offline

 

#49 2009-12-15 19:59:19

markyparky56
Hi...
From: Scotland
Registered: 2009-10-08
Posts: 910
Website

Re: Opal

finaly someone who agrees with me... How hard is it to do it? We got the kinda useless background/run screen, which i dont see the point of at the moment.

I think blender was created with python, and thats turned out fine, so why are we sitting around contemplating what new commands to put it?


I am A M30Wr.
I always get the last word.

Offline

 

#50 2009-12-16 02:35:58

cds56
THE TOOOTH! THE TOOOOOOOOOOOOTH!!!!!
From: Canamadiana
Registered: 2009-11-07
Posts: 423

Re: Opal

Because It's hard.

Although, I'm in the middle of making a gui for my CPPE, in visual basic. It's easy. lol.

It shouldn't be much harder in python except that python is not excactly a compile and theres your program kind of thing.
It has to go through a long and painful process of being py2exe'd

And I believe that blender just uses many python libs. I don't believe it's actually programmed in python.


http://www.catb.org/esr/faqs/glider.png

Offline

 

Adverts

Board footer

Powered by FluxBB
Hosted by PunBB-Hosting