Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stor = tpt.el["stor"].id
- dlay = tpt.el["dlay"].id
- psns = tpt.el["psns"].id
- tsns = tpt.el["tsns"].id
- local ANT3 = elements.allocate("DayLightInc", "ANT3")
- elements.element(ANT3, elements.element(elements.DEFAULT_PT_PROT))
- elements.property(ANT3, "Name", "ANT3")
- elements.property(ANT3, "Description", "Langtons's ant. You can set speed by changing ''dcolour'' property (Default = 20). LRRL. stor-dlay-psns-tsns")
- elements.property(ANT3, "Colour", 0x0091d7)
- elements.property(ANT3, "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"].id)
- 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,stor) --if empty
- else
- if dc(id, "type") == stor then
- side = (side-1)%4
- dc(id, "type", dlay)
- elseif dc(id, "type") == dlay then
- side = (side+1)%4
- dc(id,"type",psns)
- elseif dc(id, "type") == psns then
- side = (side+1)%4
- dc(id,"type",tsns)
- elseif dc(id, "type") == tsns then
- side = (side-1)%4
- dc(id,"type",stor)
- end --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(ANT3, "Update", update)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement