
Recommendations on script Structure
I know prom has gone over it before to a degree but I figured I'd ask a specific questions regarding script structure. As I have stated before I am rewriting my coloniser and its going well, however I am trying to truely make it easier for me to read and to eliminate redundant code. Part of my approach is to use Gosub for a majority of smaller actions so I can keep the main code as clean as possible. I am running into difficulties when writing for the different tpes of colonising (macrowise) I really would like to stay away from having to write tons of dif macros.
Code:
If ($Type = "x2 ore")
Send $Macro1
else
If ($Type = "x3 ore")
Send $Macro 2
else
If ($Type = "Bwarp")
Send $Macro 3
end
end
end
Mostly because I would have to write so many differnet macros and as I add protections (Tlock,fighit,figloss,limphits,etc) I would more than likely have to rewrite those again.
Code:
Without TLock
m1*yyl1*t*m(secnum)*yy*l(pnum)snl1*tnt1*
With Tlock
Settextlinetrigger lock :lock "Locating beam"
Settextlinetrigger Nolock :Nolock "No locating beam found"
M1*y
pause
:lock
y(cont)
:nolock
n(cont)
So heres my questions finally:
-What do you recommend for script structure?
-Do includes work better than subs?
-Am I forced to have a buncha macros for the if structures in a effort to not clutter the main code?
I ask because I believe I'm looking at a significantly large script and the more lines I can save the better, as well as making it easier on the eyes. The original TFarmer was like 600lines long, I expect this one to near on 2-3k when its all said and done.