Script Problem (wait und Objekt-Prüfung)

Hier ist der ideale Ort um über Scripts und Mods für X³: Terran Conflict und X³: Albion Prelude zu diskutieren.

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

thomas1217
Posts: 199
Joined: Wed, 13. Sep 06, 14:40

Script Problem (wait und Objekt-Prüfung)

Post by thomas1217 »

Moin @ all,
hab zwei Probleme und brauch eure Hilfe:

1. Wie fügt man in einem Setup Script ein Wait ein, dass der Script so zirka erst nach 2-3 Minuten läuft?

2. in dem Script will ich prüfen, ob es die gesuchten Schiffe und Stationen gibt, wenn nein sollen diese erstellt werden (bei dem Ausenposten klappt es nur beim Rest nicht)

Hier mein Script:

Code: Select all

001 @ = wait 12000 ms
002   
003   $Shield = 10 GJ Shild
004   $ANF.MA = Militärischer Außenposten
005   $ANF.H = ANF Hyricane
006   $ANF.T = ANF Typhoon
007   $ANF.O = ANF Orcane
008   $ANF.S = Argonen Argon Schiffswerft
009   
010   
011   $Sector.ANF = get sector from universe index: x=3, y=4
012   skip if not $Sector.ANF -> exists
013   |
014   $MA =  find station: sector=$Sector.ANF class or type=$ANF.MA race=Argonen flags=[Find.Multiple] refobj=$MA maxdist=null maxnum=99 refpos=null
015   $MA = get global variable: name=$GLOBAL.MA
016   if not $MA -> exists
017   |$MA =  create station: type=$ANF.MA owner=Argonen addto=$Sector.ANF x=6400 y=7500 z=10000
018   |= $MA -> install 3 units of $Shield
019   |$MA -> set current shield strength to 120000000
020   |set global variable: name=$GLOBAL.MA value=$MA
021   end
022   
023   $MA -> set relation against Player to Freund
024   $MA -> set relation against Argonen to Neutral
025   $MA -> set relation against Boronen to Neutral
026   $MA -> set relation against Split to Neutral
027   $MA -> set relation against Paraniden to Neutral
028   $MA -> set relation against Teladi to Neutral
029   $MA -> set relation against Xenon to Feind
030   $MA -> set relation against Kha'ak to Feind
031   $MA -> set relation against Piraten to Feind
032   $MA -> set relation against Goner to Neutral
033   $MA -> set relation against Terraner to Neutral
034   $MA -> set relation against Yaki to Feind
035   $MA -> add product to factory or dock: Energiezellen
036   $Max = $MA -> get free amount of ware Energiezellen in cargo bay
037   $Max =  = random value from 0 to $Max - 1
038   = $MA -> add $Max units of Energiezellen
039   $MA -> add product to factory or dock: Quantumröhren
040   $Max = $MA -> get free amount of ware Quantumröhren in cargo bay
041   $Max =  = random value from 0 to $Max - 1
042   = $MA -> add $Max units of Quantumröhren
043   $MA -> add product to factory or dock: Siliziumscheiben
044   $Max = $MA -> get free amount of ware Siliziumscheiben in cargo bay
045   $Max =  = random value from 0 to $Max - 1
046   = $MA -> add $Max units of Siliziumscheiben
047   $MA -> set name to 'ANF Hauptquartier'
048   
049   $SY =  find station: sector=$Sector.ANF class or type=$ANF.S race=Argonen flags=[Find.Multiple] refobj=$SY maxdist=null maxnum=99 refpos=null
050   $SY = get global variable: name=$GLOBAL.SY
051   if not $SY -> exists
052   |$SY =  create station: type=$ANF.S owner=Argonen addto=$Sector.ANF x=-7500 y=7500 z=0
053   |= $SY -> install 2 units of $Shield
054   |$SY -> set current shield strength to 120000000
055   |set global variable: name=$GLOBAL.SY value=$SY
056   end
057   
058   $SY -> add product to factory or dock: $ANF.H
059   $SY -> add product to factory or dock: $ANF.O
060   $SY -> add product to factory or dock: $ANF.T
061   $SY -> set relation against Player to Freund
062   $SY -> set relation against Argonen to Freund
063   $SY -> set relation against Boronen to Freund
064   $SY -> set relation against Split to Neutral
065   $SY -> set relation against Paraniden to Neutral
066   $SY -> set relation against Teladi to Freund
067   $SY -> set relation against Xenon to Feind
068   $SY -> set relation against Kha'ak to Feind
069   $SY -> set relation against Piraten to Feind
070   $SY -> set relation against Goner to Freund
071   $SY -> set relation against Sohnen to Neutral
072   $SY -> set relation against Goner to Freund
073   $SY -> set name to 'ANF Schiffswerft'
074   
075   $Sector.ANF = $MA -> get sector
076   
077   $Hyricane =  find ship: sector=$Sector.ANF class or type=$ANF.H race=Argonen flags=[Find.Multiple] refobj=$MA maxdist=null maxnum=99 refpos=null
078   
079   $Hyricane = get global variable: name=$GLOBAL.H
080   if not $Hyricane -> exists
081   |$NewShip = $ANF.H
082   |$NeuesSchiff =  create ship: type=$NewShip owner=Argonen addto=$Sector.ANF x=-5000 y=5000 z=0
083 @ |$Installiere = $NeuesSchiff -> call script 'plugin.stm.cheats.func.all' :  Schiffstyp=$NeuesSchiff  Wähle Rasse=Argonen
084   |set global variable: name=$GLOBAL.H value=$Hyricane
085   end
086   
087   $Typhoon =  find ship: sector=$Sector.ANF class or type=$ANF.T race=Argonen flags=[Find.Multiple] refobj=$MA maxdist=null maxnum=99 refpos=null
088   
089   $Typhoon = get global variable: name=$GLOBAL.T
090   if not $Typhoon -> exists
091   |$NewShip = $ANF.T
092   |$NeuesSchiff =  create ship: type=$NewShip owner=Argonen addto=$Sector.ANF x=0 y=5000 z=0
093 @ |$Installiere = $NeuesSchiff -> call script 'plugin.stm.cheats.func.all' :  Schiffstyp=$NeuesSchiff  Wähle Rasse=Argonen
094   |set global variable: name=$GLOBAL.T value=$Typhoon
095   end
096   
097   $Orcane =  find ship: sector=$Sector.ANF class or type=$ANF.O race=Argonen flags=[Find.Multiple] refobj=$MA maxdist=null maxnum=99 refpos=null
098   
099   $Orcane = get global variable: name=$Global.OR
100   if not $Orcane -> exists
101   |$NewShip = $ANF.O
102   |$NeuesSchiff =  create ship: type=$NewShip owner=Argonen addto=$Sector.ANF x=0 y=5000 z=0
103 @ |$Installiere = $NeuesSchiff -> call script 'plugin.stm.cheats.func.all' :  Schiffstyp=$NeuesSchiff  Wähle Rasse=Argonen
104   |set global variable: name=$Global.OR value=$Orcane
105   end
106   
107   return null
MfG
Thomas
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Re: Script Problem (wait und Objekt-Prüfung)

Post by Gazz »

thomas1217 wrote:1. Wie fügt man in einem Setup Script ein Wait ein, dass der Script so zirka erst nach 2-3 Minuten läuft?
Wait in setup scripts geht sowas von gar nicht.

Das setup script darf ein anderes script (mit START !) starten, das am Anfang ein paar waits hat.
2. in dem Script will ich prüfen, ob es die gesuchten Schiffe und Stationen gibt, wenn nein sollen diese erstellt werden (bei dem Ausenposten klappt es nur beim Rest nicht)
Erstmal fehlt Zeile 13, auf die sich das skip bezieht.
Wasauchimmer Du da tun wolltest, wird nicht passieren.

Zeile 14, 49, etc. sind sinnlos, da die Variable in der nächsten Zeile sofort wieder überschrieben wird.

Sämtlichen Names-variablen wie $GLOBAL.SY wird nirgendwo im Script ein Name zugewiesen.


Rein vom Design her sollte zuerst geprüft werden, ob die in den GV gespeicherten Objekte noch existieren.
Das erspart dann die find instructions, die merkliche Zeit verbrauchen können.

Dann läuft das script auch so schnell, daß du keinerlei wait mehr brauchst, und sich das erste Problem von selbst erledigt. =)
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
thomas1217
Posts: 199
Joined: Wed, 13. Sep 06, 14:40

Post by thomas1217 »

Danke für deine Antwort, allerdings hilft diese mir überhaupt nicht weiter, da ich immer noch nicht weiß wie ich prüfen soll, ob ein Schiff XY schon vorhanden ist und wenn nicht soll es ja erstellt werden. Das wait hab ich festgestellt nützt mir auch nichts, da der Script beim Starten des Spiels ausgeführt wird, jedoch auf das was er sich bezieht erst ungefähr 2 Minuten nach Spielstart ausgeführt wird.

Bsp:

MD Script startet und gibt mir eine Nachricht zurück.
Erst jetzt darf der Script im SE laufen, weil er auf dem MD Script "aufbaut". Und wie gesagt möchte ich prüfen ob ein Schiff da ist oder nicht. Könntest du, damit ich es besser verstehe ein kleines Beispiel mir zeigen. Ich bin im scripten nicht so bewandert. Ich habe gedacht, wenn ich das Schiff oder eine Station in eine Global übergebe und prüfe ob es vorhanden ist, dass der Script dann nichts macht. Aber er erstellt jetzt immer die Stationen und Schiffe. Ich hab das so geändert Setup Script läd den Script. Und wenn dich richtig verstanden habe dann müßte es doch so aussehen, oder nicht?

Code: Select all

001 @ = wait 12000 ms
002   
003   $GLOBAL.H = 'Mod.Hyricane'
004   $GLOBAL.MA = 'Mod.MA'
005   $Global.OR = $Mod.OR
006   $GLOBAL.SY = 'Mod.SY'
007   $GLOBAL.T = 'Mod.T'
008   
009   $Shield = 10 GJ Shild
010   $ANF.MA = Militärischer Außenposten
011   $ANF.H = ANF Hyricane
012   $ANF.T = ANF Typhoon
013   $ANF.O = ANF Orcane
014   $ANF.S = Argonen Argon Schiffswerft
015   
016   skip if not $Sector.ANF -> exists
017   |$MA = get global variable: name=$GLOBAL.MA
018   if not $MA -> exists
019   |$Sector.ANF = get sector from universe index: x=3, y=4
020   |$MA =  create station: type=$ANF.MA owner=Argonen addto=$Sector.ANF x=6400 y=7500 z=10000
021   |= $MA -> install 3 units of $Shield
022   |$Hull = $MA -> get max hull
023   |$MA -> set current shield strength to $Hull
024   |set global variable: name=$GLOBAL.MA value=$MA
025   end
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

Finde ich verwirrend, da in Zeile 16 $Sector.ANF = null ist.
Z 17 wird also in jedem denkbaren Fall übersprungen und 18 ist dadurch immer TRUE.

Wenn Du Z 16 + 17 + 18 auskommentierst wäre es leichter lesbar und hätte den gleichen Effekt.

Und... wie kannst du durch ein einfaches wait garantieren, daß das MD script schon gelaufen ist?
Solltest du nicht eher prüfen, ob der MD ein bestimmes Objekt schon erstellt hat?
Wenn ich mich nicht täusche kann der MD direkt scripts ausführen so daß du dafür gar keine Zaubertricks brauchst.
Last edited by Gazz on Sun, 7. Nov 10, 14:37, edited 1 time in total.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
Striker304
Posts: 915
Joined: Fri, 26. Mar 10, 21:15
x3tc

Post by Striker304 »

Also das wait für 3 Minuten würd ich so machen:

Code: Select all

001 $old.pltime = playing time
002 $timediff = 0
003 while $timediff < 180
004 $new.pltime = playing time
005 $timediff = $new.pltime - $old.pltime
006 =wait 10000ms
007 end
Obwohl Gazz natürlich Recht hat dass es nicht zeigt dass das MD script schon gelaufen ist.

Für die Schiffe:
Setze beim createn der Schiffe einfach die passende Globale Variable auf [TRUE]. Für die ANF Hyricane würde das ganze dann so aussehen:

Code: Select all

001 $Hyricane = get Global Variable Name ='ANF.Hyricane'
002 If not $Hyricane = [TRUE]
003 $newship = create ship type: 'ANF Hyricane' (und so weiter)
004 set Global Variable Name 'ANF Hyricane' = [TRUE]
Machs mit dem MA genauso wie mit den Schiffen, und lass dann Z. 16-18 weg.

mfg
Striker
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

004 set Global Variable Name 'ANF Hyricane' = [TRUE]

Damit kann man aber später nur prüfen, ob das Objekt irgendwann schonmal erstellt wurde, aber nicht, ob es noch existiert.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
Striker304
Posts: 915
Joined: Fri, 26. Mar 10, 21:15
x3tc

Post by Striker304 »

Das ist richtig. Aber da kann man einfach bei den 3 Schiffen SIGNAL_KILLED mit einem Script verbinden, dass die GVar wieder auf FALSE setzt.

mfg
Striker
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

1. funktioniert das signal nicht immer und
2. spart man sich das Signal-Script komplett, wenn man gleich das Objekt in die GV screibt.

Bei den Stationen hatte er ja ohnehin schon die einfachere und bessere Methode benutzt. Bei den Schiffen allerdings nicht.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
thomas1217
Posts: 199
Joined: Wed, 13. Sep 06, 14:40

Post by thomas1217 »

Danke ihr beiden die Scripte laufen jetzt. Nur der MD Script will sie nicht starten. Mal sehen werde mal im MD Thread nachfragen.

Schönen Abend noch
Thomas

Return to “X³: Terran Conflict / Albion Prelude - Scripts und Modding”