% % Show Hyperjump Routes ending at a Planet (including 3 Ly square GravityWell) % % Best use: press "b" and "Ctrl-b" in the StarChart to draw HyperJump routes into the Map or delete them % Print "[fborg.q -- v0.0.11 kissner@it-operation.de]" % this takes a long time and produces a mess - does round GravityWell Sub allhyproutes () Local outerid Local innerid Local myline print "# Hello, take some time..." ForEach Planet Do outerid:=Id innerid:=outerid hyproutesGravWells Planets(outerid).Loc.X, Planets(outerid).Loc.Y For innerid := outerid To 500 Do If (Abs(Distance (Planets(outerid),Planets(innerid)) - 350) <= 3 ) Then print outerid, " ",innerid, ": ", Distance (Planets(outerid),Planets(innerid)) NewLine Planets(outerid).Loc.X, Planets(outerid).Loc.Y, Planets(innerid).Loc.X, Planets(innerid).Loc.Y, 1, Atom("HypRoute"), -1 EndIf Next % uncomment this for debugging % print "outerid" % if (outerid>5) Then Break Next "print done" EndSub Sub delhyproutes () Local cnt cnt:=0 ForEach Marker Do If (Tag=Atom("HypRoute")) Then cnt:=cnt+1 % print cnt Delete EndIf Next % print "done" EndSub % for round GravityWells Sub hyproutes2() Local tx,ty,innerid tx:=Loc.X ty:=Loc.Y % print tx , " " ,ty innerid:=0 Do While (innerid := FindPlanet((Abs( Distance(tx,ty,Loc.X,Loc.Y) - 350) < 3) And Id> innerid)) % print " ", Planets(innerid).Loc.X," ", Planets(innerid).Loc.Y NewLine tx, ty, Planets(innerid).Loc.X, Planets(innerid).Loc.Y, 1, Atom("HypRoute"), -1 Loop EndSub % for square GravityWells Sub hyproutes(tx,ty) Local innerid print tx , " " ,ty innerid:=0 Do While (innerid := FindPlanet( ( Id > innerid And (Abs (Distance(tx,ty,Loc.X,Loc.Y)-350) < 5 ) ) And ( (Abs(tx + 350*(Loc.X-tx)/Distance(tx,ty,Loc.X,Loc.Y) - Loc.X) <= 3 ) And ( Abs( ty + 350*(Loc.Y-ty)/Distance(tx,ty,Loc.X,Loc.Y) - Loc.Y) ) <= 3 ) )) If (Abs (Distance(tx,ty,Planets(innerid).Loc.X,Planets(innerid).Loc.Y)-350)>4.243) Then UI.Message "Miscalculation in hyproutes", "Warning", "OK" print " ", Planets(innerid).Loc.X," ", Planets(innerid).Loc.Y , ":" , Distance(tx,ty,Planets(innerid).Loc.X,Planets(innerid).Loc.Y) NewLine tx, ty, Planets(innerid).Loc.X, Planets(innerid).Loc.Y, 1, Atom("HypRoute"), -1 Loop EndSub Bind StarChart "b" := "hyproutes UI.X, UI.Y" Bind StarChart "ctrl-b" := "delhyproutes" %I should clean up the mess, define more functions and use delegation. Won't do that unless I can return a value from a routine