Brauche Hilfe beim Befehl "while [DOCKEDAT] ==..." [ERLEDIGT]

Hier ist der ideale Ort um über Scripts und Mods für X³: Reunion zu diskutieren.

Moderators: Moderatoren für Deutsches X-Forum, Scripting / Modding Moderators

Post Reply
User avatar
-Ford-
Posts: 2064
Joined: Wed, 18. Jan 06, 18:40
x4

Brauche Hilfe beim Befehl "while [DOCKEDAT] ==..." [ERLEDIGT]

Post by -Ford- » Sat, 8. Apr 06, 19:03

Also hi erstmal, ich hab ein Problem bei einem meiner Projekte und wollte fragen ob mir vielleicht die Community helfen könnte. Also ich habe folgendes Problem: Ich das Main - Script meines GKS - Versorger überprüft gesetzte Variablen und lädt die zu kaufende Ware und deren Anzahl. Anschließend gibt sie dem Versorger den Befehl auf der Zielstation zu landen. So weit so gut. Nur wenn ich jetzt versuche Abzufragen ob der Versorger an der Zielstation gedockt ist und im positiven Fall die Ware kaufen soll, dann passiert - nichts - der Versorger kauft nichts, und führt auch keinen der weiteren Befehle aus. Falls es hilft hier das Überprüfungsscript für den Dockstatus:

Code: Select all

Arguments
1: STATION.WHERE.TO.BUY , Var/Station , '' 
2: ANZAHL , Var/Number , '' 
3: WARES , Var/Ware , '' 
Source Text

001   $DOCKEDAT = [THIS] -> is docked
002   BuyWaresAtStation:
003   while $DOCKEDAT
004    while $DOCKEDAT == $STATION.WHERE.TO.BUY
005     = [THIS] -> buy $ANZAHL units of $WARES
006     START [THIS] -> Kommando COMMAND_FOLLOW : arg1=[HOMEBASE], arg2=null, arg3=null, arg4=null
007     return null
008    end
009   end
010   while not $DOCKEDAT == $STATION.WHERE.TO.BUY
011 @  = wait 1000 ms
012    goto label BuyWaresAtStation
013   end
014   return null
Dem Script werden alle nötigen Variablen übergeben. Irgendwelche Vorschläge?

Lt. Ford [IBAP]
Last edited by -Ford- on Sat, 8. Apr 06, 22:53, edited 1 time in total.
Ponyfabulous

Kelthur
EGOSOFT
EGOSOFT
Posts: 790
Joined: Tue, 31. May 05, 18:24
x3tc

Post by Kelthur » Sat, 8. Apr 06, 19:22

Warum denn while? Nimm doch einfach if $DOCKEDAT == $STATION.WHERE.TO.BUY.

Übrigens gibt [THIS] -> is docked nicht die Station zurück, sondern nur ob das Schiff gedockt hat. Das ist natürlich nie gleich einer Station.

Raumfliegenjäger
Posts: 2865
Joined: Sat, 4. Jun 05, 14:41
x3tc

Post by Raumfliegenjäger » Sat, 8. Apr 06, 19:23

Meine Threorie:
Das Script wird nicht auf dem Schiff gestartet sondern Global und da bringen [This] befehle nicht sonderlich vie :roll:
Ich weiss was, nämlich das ich nichts weiss, also weiss ich doch was, nämlich das ich nichts weiss! :goner:

...während sie gerade den Anfang der Schlacht beobachten, kenne ich bereits den Schlussakt. [Kane]

User avatar
-Ford-
Posts: 2064
Joined: Wed, 18. Jan 06, 18:40
x4

Post by -Ford- » Sat, 8. Apr 06, 20:31

Werde beides ausprobieren @Azaneth bringt den der ingame Befehl [DOCKEDAT] irgednwas?

Lt. Ford [IBAP]
Ponyfabulous

Kelthur
EGOSOFT
EGOSOFT
Posts: 790
Joined: Tue, 31. May 05, 18:24
x3tc

Post by Kelthur » Sat, 8. Apr 06, 21:41

Wenn das Skript auf einem Schiff läuft, müsste [DOCKEDAT] die Station zurückgeben, an der das Schiff angedockt ist (und FALSE, falls es nicht gedockt ist). Habe damit aber noch nicht zu tun gehabt.

Auf jeden Fall liefert [THIS] -> get environment die Station, wenn es angedockt ist.

User avatar
-Ford-
Posts: 2064
Joined: Wed, 18. Jan 06, 18:40
x4

Post by -Ford- » Sat, 8. Apr 06, 22:53

Ich kann nur sagen DANKE :D Es funktioniert einbahnfrei und flüßig, die erste beta wird's in ein paar Tagen geben.

Lt. Ford [IBAP]
Ponyfabulous

User avatar
triple81
Posts: 438
Joined: Thu, 17. Nov 05, 20:13
x3

Post by triple81 » Sun, 9. Apr 06, 11:16

Lt. Ford [IBAP] wrote:Ich kann nur sagen DANKE :D Es funktioniert einbahnfrei und flüßig, die erste beta wird's in ein paar Tagen geben.

Lt. Ford [IBAP]
Es heisst einwandfrei :) . Kommt von Einwand, Einwände, keine Einwände haben. Gruss triple81

User avatar
Lucike
Posts: 12969
Joined: Sun, 9. May 04, 21:26
x4

Post by Lucike » Sun, 9. Apr 06, 13:01

Azaneth wrote:zurück, sondern nur ob das Schiff gedockt hat. Das ist natürlich nie gleich einer Station.
[DOCKEDAT] ist genau der richtige Weg, allerdings gibt "-> is docked" eine Stationen zurück, wenn das Objekt angedockt ist.

Gruß
Lucike
Image

Kelthur
EGOSOFT
EGOSOFT
Posts: 790
Joined: Tue, 31. May 05, 18:24
x3tc

Post by Kelthur » Sun, 9. Apr 06, 15:54

Tut mir leid... dann seh' ich beim nächsten mal besser nach, bevor ich auf Verdacht falsche Informationen verbreite.

Wäre ein Anfrage "-> is docked == TRUE" dann eigentlich erfolgreich?

User avatar
Red Spot
Posts: 3461
Joined: Fri, 4. Feb 05, 13:44
x3

Post by Red Spot » Sun, 9. Apr 06, 19:12

sorry for the non-German'ish .......


but your script has a 'freeze my game' command in there ....

the "Follow" command is to follow ships .. NOT stations ....
if you want a ship to return home .. just give it the "Return Home" command ....
(now your prob. using this on a carrier ... still I see no "is HOMEBASE a ship" check ...)

Next as I understand (my German isnt that great ....) your having problems having your ship to 'respond' ... ??
You might wanna try "load x units of ware" cause if the command is ordered to a ship with a carrier as home .. than the carrier has NO credits .. so the ship cant BUY ... make it LOAD ware and remove credits from the playeraccount ...

next ... what if the ship is not docked ... it will just wait in space and never do anything else ... ever again(or untill it gets a new command ....)

also loose both "while docked loops" and replace them with
"while $station.to.buy AND [DOCKEDAT] == $station.to.buy"

however there is no need for that loop ...

here is how I would (simply) do it;

while TRUE
skip if $station.to.buy exists
break

if [DOCKEDAT]
if [DOCKEDAT] == $station.to.buy
*buy/load wares ..
break
end
@=[THIS] -> move to sector [SECTOR]
=wait 500 ms
continue
end

if not [THIS] is in same sector as $station.to.buy
*move to correct sector
=wait 500 ms
continue
end

(now we know the ship is in sector and in the same sector as the station)

if $station.to.buy -> is docking possible of [THIS]
@=[THIS] fly to station $station.to.buy
=wait 500ms
continue
end

(if the script gets here it means the ship is ready to dock .. but the station cant dock it .... put some idle movement or a message to the player here)

end

(end of the script ...)
return null



G

User avatar
Lucike
Posts: 12969
Joined: Sun, 9. May 04, 21:26
x4

Post by Lucike » Sun, 9. Apr 06, 21:35

Das sieht ja alles sehr gruseling aus. :|

Code: Select all

Arguments
1: Station , Var/Station , 'Station' 
2: Ware , Var/Ware , 'Ware' 
3: Amount , Var/Number , 'Amount' 
Source Text

001   
002   skip if $Station -> exists
003    return null
004   skip if  is datatyp[ $Ware ] == DATATYP_WARE
005    return null
006   skip if $Amount > 0
007    return null
008   
009   while [THIS] -> is docked
010 @  = [THIS] -> fly to sector [SECTOR]
011 @  = wait 200 ms
012   end
013   
014   while [DOCKEDAT] != $Station
015 @  = [THIS] -> fly to station $Station
016 @  = wait 200 ms
017   end
018   
019   if $Station -> exists
020    skip if not [DOCKEDAT] == $Station
021     = [THIS] -> buy $Amount units of $Ware
022   end
023   
024   return null
Vielleicht noch ... dann wird's schon fast perfekt. ;)

Code: Select all

08a   skip if $Station -> is docking possible of [THIS]
08b    return null
08c   skip if [THIS] -> is docking allowed at $Station
08d    return null
Last edited by Lucike on Mon, 10. Apr 06, 15:08, edited 1 time in total.
Image

User avatar
-Ford-
Posts: 2064
Joined: Wed, 18. Jan 06, 18:40
x4

Post by -Ford- » Sun, 9. Apr 06, 23:13

Der Code sieht schon längst nicht mehr so aus wie oben :) . Und die erste BETA ist intern in der IBAP unterwegs 8)

Lt. Ford [IBAP]
Ponyfabulous

User avatar
Lucike
Posts: 12969
Joined: Sun, 9. May 04, 21:26
x4

Post by Lucike » Mon, 10. Apr 06, 07:17

Lt. Ford [IBAP] wrote:Der Code sieht schon längst nicht mehr so aus wie oben :) . Und die erste BETA ist intern in der IBAP unterwegs 8)
Das ist auch gut so, denn sowas "START [THIS] -> Kommando COMMAND_FOLLOW : arg1=[HOMEBASE], arg2=null, arg3=null, arg4=null" hat ein breites Grinsen auf mein Gesicht gezaubert. *gg*

Man sollte noch die Libs von Egosoft erwähnen, die natürlich auch genutzt werden können.

move.to.station
move.to.sector

Gruß
Lucike
Image

Post Reply

Return to “X³: Reunion - Scripts und Modding”