RigidChips
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Regenerate

2 posters

Go down

Regenerate Empty Regenerate

Post by DanielLC Sat Dec 18, 2010 3:06 pm

There seems to be a bug where, every time I add a piece, all the pieces from other parents get attached back on. Admittedly, I could just exploit that bug to do what I was originally trying to do, but it wouldn't look nearly as awesome.

I had some trouble with the type part that I haven't gotten around to fixing, so it just replaces everything with frames.

I suggest using this with the bye.txt model, since that way you just need to press a button to break it instead of crashing it or something.

regenerate.rcs
Code:
function isAttached(chip)
  if chip == 0 then
    return true
  end
  return _PARENT(alias[chip+1]) == alias[parent[chip+1]+1]
end

function check(chip)
--  out(chip,alias[chip+1])
  out(chip,_PARENT(alias[chip+1]))
  if not ready[chip+1] then
    _SET(alias[chip+1],"ANGLE",_ANGLE(alias[chip+1])+5)
    if _ANGLE(alias[chip+1]) >= angle[chip+1] then
      _SET(alias[chip+1],"ANGLE",angle[chip+1])
      ready[chip+1] = true
    else
      return
    end
  end
  if isAttached(chip) then
    local i
    for i=1,table.getn(tree[chip+1]) do
      check(tree[chip+1][i])
    end
    return
  end
  ready[chip+1] = false
--  alias[chip+1] = _ADDCHIP(_PARENT(chip),_TYPE(chip),dir[_GET(chip,"DIR")+1],-180)
  alias[chip+1] = _ADDCHIP(alias[parent[chip+1]+1],"FRAME",dir[_GET(chip,"DIR")+1],-180)
end

function OnFrame()
  check(0)
--[[  for i=0,chips-1 do
    alias[i+1]
  end]]--
end

function OnInit()
  chips=_CHIPS()
  dir={"S","W","N","E"}
  alias={}
  ready={}
  angle={}
  parent={}
  tree={}
  local i
  for i=0,chips-1 do
    table.insert(alias,i)
    table.insert(ready,true)
    table.insert(angle,_ANGLE(i))
    table.insert(parent,_PARENT(i))
    table.insert(tree,{})
  end
  for i=1,chips-1 do   --the core doesn't have a parent
    table.insert(tree[_PARENT(i)+1],i)
  end
    table.insert(tree[1],1)

--  _SET(_CHIPS(),"OPTION",3)
--  gun=_ADDCHIP(0,"WHEEL","N",-90)
end

function OnReset()

end

function OnMode()

end

DanielLC
Tank
Tank

Posts : 78
Join date : 2010-10-23

Back to top Go down

Regenerate Empty Re: Regenerate

Post by JHaskly Sat Dec 18, 2010 6:59 pm

Something else interesting: if you just reset the model, the chips stay in place.

JHaskly
Admin

Posts : 235
Join date : 2010-07-16
Age : 28
Location : Brisbane

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum