I've written a script but that works for one atom but I cannot subtract
as many atoms as i want from the queue with a surplus the sciprt is the following:
Code: Select all
do(
Setinvent(1,1,invent(1,1)-1),
if(Content(c)=0,
do(
var([maxN],vbValue,0),
var([maxP],vbValue,0),
var([icounter],vbValue,0),
var([icounter2],vbValue,0),
{Find maximum surplus queue}
set(maxN,Max(invent(1,1),invent(2,1),invent(3,1),invent(4,1))),
For(icounter:=1,icounter<5,Inc(icounter),if(maxN=invent(icounter,1),maxP:=icounter,0)),
{If enough inventory sutract 15 atoms}
if(maxN>20,
For(icounter2:=1,icounter2<16,Inc(icounter2),
do(
SetLabel([Destination],1,First(AtomByName(invent(maxP,2),Model)))
MoveRequest(First(AtomByName(invent(maxP,2),Model)),2),
Trace([one more]),
)
)
)
)
)
)
The problems is that even thought it enters the For loup (The tracers is printed 15 times) the move request
is executed only once.
I've tried to use repeat but it only executes one time
Code: Select all
do(
Setinvent(1,1,invent(1,1)-1),
if(Content(c)=0,
do(
var([maxN],vbValue,0),
var([maxP],vbValue,0),
var([icounter],vbValue,0),
var([icounter2],vbValue,0),
{Find maximum surplus queue}
set(maxN,Max(invent(1,1),invent(2,1),invent(3,1),invent(4,1))),
For(icounter:=1,icounter<5,Inc(icounter),if(maxN=invent(icounter,1),maxP:=icounter,0)),
{If enough inventory sutract 15 atoms}
if(maxN>20,
Repeat(
do(
SetLabel([Destination],1,First(AtomByName(invent(maxP,2),Model)))
MoveRequest(First(AtomByName(invent(maxP,2),Model)),2),
Trace([one more]),
),15
)
)
)
)
)