Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ANT = elements.allocate("DayLightInc", "ANT")
- elements.element(ANT, elements.element(elements.DEFAULT_PT_PROT))
- elements.property(ANT, "Name", "ANT")
- elements.property(ANT, "Description", "Langtons's ant. You can set speed by changing ''dcolour'' property (Default = 20). LR")
- elements.property(ANT, "Colour", 0xff8888)
- elements.property(ANT, "MenuSection", 12)
- local function update (i,xu,yu,s,nt)
- ctype = sim.partProperty(i, "ctype")
- if ctype == 0 then
- sim.partProperty(i, "life", xu);
- sim.partProperty(i, "tmp2", yu);
- sim.partProperty(i,"ctype",14);
- dc = sim.partProperty
- if dc(i,"dcolour") == 0 then dc(i, "dcolour", 20) end
- sim.partProperty(i, "tmp", 3)
- sim.partProperty(i, "x", 5)
- sim.partProperty(i, "y", 5)
- else
- for ir = 1,sim.partProperty(i,"dcolour"),1 do
- oldX = sim.partProperty(i, "life") -- get x
- oldY = sim.partProperty(i, "tmp2") -- get y
- side = sim.partProperty(i,"tmp")
- sim.partProperty(i, "x", 5)
- sim.partProperty(i, "y", 5)
- idr = sim.partCreate(-1,oldX,oldY, tpt.el[dmnd])
- if idr == -1 then
- id = sim.partID(oldX,oldY)
- else
- id = nil
- sim.partKill(idr)
- end
- if id == nil then
- side = (side+1)%4
- sim.partCreate(-3,oldX,oldY,14) --if empty
- else
- side = (side-1)%4
- sim.partKill(id) --if not empty
- end
- if side == 0 then --up
- oldY = oldY - 1
- elseif side == 1 then --right
- oldX = oldX+1
- elseif side == 2 then --down
- oldY = oldY+1
- elseif side == 3 then --left
- oldX = oldX-1
- end
- sim.partProperty(i, "life", oldX)
- sim.partProperty(i,"tmp2", oldY) --return particle
- sim.partProperty(i, "tmp", side)
- end
- end
- end
- elements.property(ANT, "Update", update)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement