The Powder Coder script[Py]

  • boxmein
    2nd Jun 2011 Former Staff 0 Permalink

    The PowderCoder script


    This is a topic dedicated to the PowderCoder script me and MasterMind555 have been preparing.
    There is a beta version just for now. Made in Python 2.6. (could make in VB soon)
    MasterMind555 is doing the element properties and stuff area from where you make the base for powder.h
    < powdercoder.tk >
    I have been making the other half. The scripting language.

    This is the first test release of the interpreter. Be sure to report any bug.
    Soon, MasterMind's page will be dedicated to this.
    It'll look better and have forums and stuff. I hope.
    #!/usr/bin/env python
    #C boxmein 2011. Use *EXIT* to close programs.
    print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
    print 'Hint: use *EXIT to exit the program.'
    print ' Boxmein\'s Powder Toy Script Interpreter!'
    print 'BETA 0.1 - Need to edit vars by yourself. '
    print '(it means any vars inside must be done by self)'
    print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
    filename= str(raw_input("What is the name of your file ->-> "))
    if filename == '*EXIT*' :
    exit()
    global f
    try:
    < tab >f = open(filename, 'r')
    except IOError:
    < tab >print 'File does not exist.'
    replacers = [['pressure','partgrid','blockgrid','ewallgrid','r','currentelem','currentpart','then','end','nearbypart','create','createline','kill','nearest','typechange'],
    ['pv[y/CELL][x/CELL]','pmap[y][x]','bmap[y][x]','emap[y][x]','pmap[y][x]','t','parts[i]','{','}','parts[r>>8]','create_part(-1,x,y,TYPE)','create_line(x1,y1,x2,y2,r,TYPE)','kill_part[i]','nearest_part(CURRENT,TYPE)','part_change_type(TYPE1,X,Y,TYPE2)']]
    content = f.read()
    content = content.split()
    for i in range(0, len(replacers)-1):
    < tab > content.replace(replacers[i,0],replacers[i,1])
    g = open(filename + '.c', 'w')
    g.write('int update_ELEMENTNAME(UPDATE_FUNC_ARGS) {' + content + '}')

    " Save as" this in Notepad as "All files (*.*)" and with the name "anyname.py"
    Then run it and voila. (For now, finds files within its directory)

    Be sure to not forget to replace < tab > with real tabs!
    Usage example:
    if ( pressure < 100 ) then currentpart .temp = 1000; end else then currentpart .temp = 2; end
  • Uberness
    2nd Jun 2011 Member 0 Permalink
    @boxmein (View Post)
    Lol, it's now a lua console now.
  • MasterMind555
    2nd Jun 2011 Member 0 Permalink
    @UBERNESS (View Post)
    Not related to the console

    Server Status : ONLINE
  • boxmein
    2nd Jun 2011 Former Staff 0 Permalink
    Lua now? lol. It's not to be added INTO THE CONSOLE. It's a separate program.
  • vanquish349
    2nd Jun 2011 Member 0 Permalink
    so what does this do

    and could you paste bin the code, cause in paste bin you can use tabs
  • boxmein
    2nd Jun 2011 Former Staff 0 Permalink
    I didn't feel necessary. Maybe if it gets longer.