Logic Gates: Help Needed

  • FM22
    3rd Mar 2014 Member 0 Permalink

    I'm trying to make a GATE element that does logic, but my function doesn't work. Can anyone help? Here is the update function:

    function spawninout(i,x,y,s,n)
    if tpt.get_property("tmp",x,y)==0 then
    if tpt.get_property("type",x-2,y)==tpt.el.sprk.id or tpt.get_property("type",x+2,y)==tpt.el.sprk.id then
    tpt.set_property("type",tpt.el.sprk.id,x,y+2)
    end
    end
    tpt.delete(x-2,y)
    tpt.delete(x+2,y)
    tpt.delete(x,y+2)
    tpt.create(x-2,y,"metl")
    tpt.create(x+2,y,"metl")
    tpt.create(x,y+2,"metl")
    end
    tpt.element_func(spawninout,elements.MOD_PT_GATE)

    This doesn't cause any errors and the METL spawning works properly (this element is only intended for use as a 1 pixel dot), its just that it doesn't output.

    Edited once by FM22. Last: 3rd Mar 2014
  • Faerindel
    5th Mar 2014 Member 0 Permalink

    Doesn't output what?

     

    If you mean to keep the spark going up from the gate, you are deleting and creating METL in the same pixel you just set to SPRK.

  • Schneumer
    5th Mar 2014 Member 0 Permalink

    Can someone tell me what a logic gate is?

  • FM22
    5th Mar 2014 Member 0 Permalink

    Oh yeah! Thanks, Faerindel.