Reinforced Concrete

  • 12Me21
    2nd Nov 2016 Member 0 Permalink

    I'm sure this could be made more efficiently...

    elements.allocate("ME","RCNT")
    elements.element(elements.ME_PT_RCNT,elements.element(elements.DEFAULT_PT_CNCT))
    elements.property(elements.ME_PT_RCNT,"Name","RCNT")
    elements.property(elements.ME_PT_RCNT,"Description","Reinforced Concrete")
    elements.property(elements.ME_PT_RCNT,"Colour",0xBEACAC)


    local function noFall(i,x,y)
        if tpt.get_property("type",x,y+1)~=0 or (tpt.get_property("type",x+1,y+1)~=0 and tpt.get_property("type",x+1,y)~=0) or (tpt.get_property("type",x-1,y+1)~=0 and tpt.get_property("type",x-1,y)~=0) then
        --| R | or | #R | will not fall
         --| # |    | #  |
            tpt.set_property("vx",tpt.get_property("vx",i)/10,i)
            tpt.set_property("vy",0,i)
        end
    end

    tpt.element_func(noFall,elements.ME_PT_RCNT)
  • LBPHacker
    3rd Nov 2016 Developer 0 Permalink

    I don't think it can. You'd have to call at least 8 API functions regardless of how you order them around.

    Edited once by LBPHacker. Last: 3rd Nov 2016