Console tricks

  • nmd
    29th Jul 2012 Member 0 Permalink

    @ThunderSt (View Post)

    *facepalm*

    the tpt.el commands

     

  • boxmein
    29th Jul 2012 Former Staff 0 Permalink

    For future future people:


    I have made a website that generates the boilerplate code and lets you concentrate on editing the important parts.
    http://boxmein.net/tpt/tptelements/
    The code is open-source:
    http://github.com/boxmein/tptelements2


    For future people:


    Note that this tutorial implies the Lua Legacy API which may or may not be turned off in the farther future. To accommodate for that happening, use this command instead of tpt.el.inst.value:

    local values = { } -- Make a new table for safe keeping
    values["Name"] = "AWES"
    values["Description"] = "This is a demo element for a TPT thread."
    -- For the "keys" inside the square brackets, use any of those below but with a capital letter to start off.
    elements.element(elements.DEFAULT_PT_WATR, values)
    -- This is the magic command that will set all those values at once.


    -- Or, you could do it the Good Guy Greg way, and create your own entire element for this!
    elements.allocate("boxmein", "AWES")
    -- This creates a new key for your element and adds it in your namespace, so "boxmein" AWES and "FinalFlash50" AWES can be different.
    elements.element(elements.BOXMEIN_PT_AWES, elements.element(elements.DEFAULT_PT_VIBR) )
    -- This uses my newly generated key! ^ , also it copies all VIBR properties inside AWES.
    -- I guess the rest could be done exactly like above, but instead of elements.DEFAULT_PT_WATR use elements.BOXMEIN_PT_AWES

    Also make sure to read https://powdertoy.co.uk/Wiki/W/Powder_Toy_Lua_API.html
    and https://powdertoy.co.uk/Wiki/W/Lua_API:Elements.html


    @ThunderSt (View Post)
    All those are tpt.setXYZ. (Set's are used to modify various game aspects, el's are used to modify element properties for this game session) Those aren't tpt.el.XYZ.


    Quickly made list (from src/luaconsole.c @ lines 462 .. 572):

    tpt.el.inst.

    name - STRING, FOUR LETTERS - Changes the element's name
    color - HEXADECIMAL DIGIT OF 8 (Prepend 0x) - Changes the element's colour.
    advection - FLOATING POINT - How much moving air moves the element.
    airdrag - FLOATING POINT - How much air it pushes around when falling/moving
    airloss - FLOATING POINT, 1 IS MIN, 0 IS MAX - How much the element stops air.
    loss - FLOATING POINT, 1 IS MIN, 0 IS MAX - How much the element slows down during falling.
    collision - FLOATING POINT - Velocity will be multiplied by this on impact. Useful for idunno.
    gravity - FLOATING POINT - How fast the particle falls. Negative - it floats.
    diffusion - FLOATING POINT -How much the particle 'wiggles'. Think GAS.
    hotair - FLOATING POINT - How much the particle increases pressure by.
    falldown - INTEGER - How the particle moves. 0 = Solid. 1 = Powder. 2 = Liquid.
    flammable - INTEGER - How much the particle burns. 0 = not at all, higher = more burning.
    explosive - INTEGER - Does it explode? 0 = No. 1 = With fire. 2 = With fire OR with >2.5 pressure.
    meltable - BINARY INTEGER - Will it melt? 1 = Yes. 0 = No.
    hardness - INTEGER - Acid effects. 0 = Acid proof, The bigger the more it melts.
    menu - BINARY INTEGER - Is it on the menu? 1 = Yes. 0 = No.
    enabled - BINARY INTEGER - Can the element be used? 1 = Yes. 0 = No.
    weight - INTEGER - GAS 1, LIGHT 2, LIQUID 0-49, POWDERS 50-99, SOLID 100 - How "heavy" the element is. Think BCOL falling through DUST.
    menusection - INTEGER - Which menu it is in. See interface.h in the old source code.
    heat - FLOAT, MIN 0, MAX 10 000 - The starting temperature in the Kelvin scale. When displayed, 273.15 will be subtracted.
    hconduct - INTEGER, MIN 0, MAX 250 - How well it transfers heat.
    state - INTEGER - Which state the element is in.
    properties - INTEGER - See my later post.
    description - STRING - Element description.

    Aaaand now may one have fun.

    -- Below uses Lua Legacy API which may or may not be removed. --
    Set them with
    tpt.el.inst.gravity = 0
    Get them with
    gr = tpt.el.inst.gravity
    Edited once by boxmein. Last: 10th Apr 2016
  • nmd
    29th Jul 2012 Member 0 Permalink

    @boxmein (View Post)

     Many thanks, mein of the box *does the chinese bow thing while someone hits gong in background*

  • ThunderSt
    29th Jul 2012 Member 0 Permalink

    boxmein:

    @ThunderSt (View Post)
    All those are tpt.setXYZ. Those aren't tpt.el.XYZ.
    Quickly made list (from src/luaconsole.c @ lines 462 .. 572):
    tpt.el.inst.
    "name" "color" "advection" "airdrag" "airloss" "loss" "collision" "gravity" "diffusion" "hotair" "falldown" "flammable" "explosive" "meltable" "hardness" "menu" "enabled" "weight" "menusection" "heat" "hconduct" "state" "properties" "description"

    Guess their values yourself >:]
    Set them with
    tpt.el.inst.gravity = 0
    Get them with
    gr = tpt.el.inst.gravity

     

    AWSOMESAWCE! Time to reprogram an element!!! (temporarily)

     

    Edit: 'name' makes the element have no name, and 'color' makes the name have the life with soap ctype color, and black in the element selection.

  • boxmein
    29th Jul 2012 Former Staff 0 Permalink
    @ThunderSt (View Post)
    Seems like you gave it a false value. Try
    tpt.el.dmnd.name = "ELEM"
    tpt.el.dmnd.color = 0xFF001C5D

    (0xAARRGGBB where AARRGGBB is a hex code for the colour with opacity, or more precisely, two hex digits of alpha, two hex digits of red, two hex digits of green and two hex digits of blue. just type 0xFF and add the color from the top box in here...)
    Because I got it to happen
    image
    Edit: 0x333311 is an ugly colour. 0x001C5D is better.
    Edited once by boxmein. Last: 12th Jul 2015
  • Dawgie
    29th Jul 2012 Member 0 Permalink
    @boxmein (View Post)
    I was wondering is your name supposed to be box mein or box me in?
  • boxmein
    29th Jul 2012 Former Staff 0 Permalink
    @Dawgie (View Post)
    "Box Me In" I guess. Dunno how I thought of it. :D
  • ThunderSt
    29th Jul 2012 Member 0 Permalink

    I tried ''awsm'' (awesome in 4 letters), and it doesn't work.

    And thanks for the color thing..

     

  • boxmein
    29th Jul 2012 Former Staff 0 Permalink
    @ThunderSt (View Post)
    You're using two single quotes on both sides. If you can't make a double quote (If you have like Shift+2 or something to make this character [note that the two ticks are the same character]) " then you can use single quotes ' , the same that you already used but did a bit badly.
    Do this:
    tpt.el.watr.name = 'awsm'

    Basically, what your code did was make two empty strings
    ' ' and ' '
    and a try to get something called awsm which it didn't recognize.
  • ThunderSt
    30th Jul 2012 Member 0 Permalink

    @boxmein (View Post)

     
    IT WORKS! Thank you box!

     

    Edit: Coding water into 'AWSM', and changing properties.. I would like to have the possibility of binding multiple commands into a single one, so I could use that one and change an element into a brand new element via console without writting a lot of commands.

     

    Edit2: How do I make Watr stop turning into Wtrv because of heat?

     

    Edit3: Awesome Sauce, AKA: AWSM..

     

    Yep, modified water.

     

    Paused,

     

    2 frames after,

     

    4 frames after,

     

    12 frames after,

     

    after the explosion ended.