Help needed

  • cartman300
    13th Sep 2012 Member 1 Permalink

    Hello. I'm doing an element in lua and it seems that i can't make it destroy when

    temperature is over 400 °C

    Here's what i use for now:

     

    function nthink(i,x,y,s,n)

    if tpt.get_property("ctype",i)==tpt.el.tron.id then
    if tpt.get_property("temp",i)>=(400+273.15) then
    tpt.delete(x,y)
    --tpt.create(x,y,"bmtl")
    end
    end
    end

    tpt.element_func(nthink,tpt.el.bran.id)

     

    Also, is there a way to create pressure on X and Y?

  • Simon
    14th Sep 2012 Administrator 1 Permalink
    tpt.delete has 2 modes of operation, tpt.delete(xCoord, yCoord) or tpt.delete(index), the latter is both faster and more reliable, you should use that instead.

    For pressure, see https://powdertoy.co.uk/Wiki/W/Lua.html#tpt.set_pressure
  • jacob1
    14th Sep 2012 Developer 1 Permalink
    But tpt.set_pressure can only set it to a specific value, not create extra pressure, and there is no tpt.get_pressure, so it might not be exactly what you want. Creating 10 pressure might actually decrease it from 200 to 10 and do the opposite of what you wanted. (Also, there's no other way until that is added)

    In tpt++ sometime (i'm going really slow with want I want to do with it, but I got a few things merged in already), I will try to add more commands to the old lua api, and fix all the bugs with them (like the ones mniip told me on irc, and the ones I already noticed with not checking if it's a valid type). I want to improve the save browser and make it have everything tpt does first (plus maybe a little more)

    @cartman300 (View Post)
    I didn't test it, but I think I know an easier way. If you add a transition at 400°C to 0 (PT_NONE), it will just disappear. Try tpt.el.bran.tempHighValue = 673.15 and tpt.el.bran.tempHighType = 0. This would make your element less laggy too, and you could still use the update function if you need it.
    Edit2: But this wouldn't work since you only have it transition at a certain ctype...

    Edit: Below
    pressure is on a 4x4 grid, so you need to use x/4 and y/4 to set it at the right spots
  • cartman300
    14th Sep 2012 Member 0 Permalink

    Simon:

    tpt.delete has 2 modes of operation, tpt.delete(xCoord, yCoord) or tpt.delete(index), the latter is both faster and more reliable, you should use that instead.

    For pressure, see https://powdertoy.co.uk/Wiki/W/Lua.html#tpt.set_pressure

     

    Yeah, i've got the nthink working, but i still don't understand pressure. It seems i can't really

    set pressure to 10 on X and Y. Is there a way to get pressure of an material?

     

    Post:

    Ah, cool. I got it working correctly, but there's only one feature missing. You say it's not possible to get pressure so it seems i can't make it. xD

  • carrots123
    5th Oct 2012 Member 0 Permalink

    can't you just go tpt.el.(element abbriviation here).airflow/airloss=(number)?

    otherwise what is the point of that?