Ok, so heres what i got so far ...
# $1 !timeleft/trigger
# $2 SciencePoints needed
# $3 SP produced at start of the Process
# $4 Time till next Lab is build. refered to as building loop.
# $5 SP/h that is gained when a Lab is build.
#
on *:input:#kilrathy-iw: {
if ($1 == !timeleft) {
if ($calc($2 - ($3 * $4)) >= 0) { ; the script starts
var %time 0 ; %time variable to see how many "goto-steps" where done
var %sph $3 ; SP produced at start of the Process is set to variable %sph
var %step2 $2 ; SP needed is set to variable %step2
goto step1
:step1
var %step1 $calc(%step2 - (%sph * $4)) ; calculates the SP that is left after the first building loop
if (%step1 <= 0) { msg $chan %time ; stops the script if SP left is smaller then 0 (no more SP needed = Science done)
halt }
else { inc %time 1 ; if Science isnt done yet, building loop timer goes up an
goto step2 ; we go on to the same calc with the values of the previous step
}
:step2 inc %sph $5 , increase the amount of produced SP/h by the new gained production after a single building loop.
var %step2 $calc(%step1 - (%sph * $4)) ; same as in step1
if (%step2 <= 0) { msg $chan %time ; same as in step1
halt }
else { inc %time 1
inc %sph $5
goto step1 ; here the loop starts }
}
}
}
it doesnt work at all.
ok, if times to short at the beginning, it works

else its just looping even when theres a halt in there ...