[Discussion] Generic X3TC S&M questions II

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Posting code doen't cause trouble in a scripting Q&A-Thread. ;)
Maybe others with similar problems can learn, too.

Greetings,
ScRaT
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

:)

(A bit different from before, no relvals etc.)

Code: Select all

001   $Checks = [THIS] -> get local variable: name='ej.bounty.doublesig'
002   if $Checks != [TRUE]
003   |[THIS] -> set local variable: name='ej.bounty.doublesig' value=[TRUE]
004   |send incoming message 'Wow, it actually working' to player: display it=[TRUE]
005   |
006   * Basic stats...
007   |$arr =  get warearray for [THIS]
008   |$mil = get global variable: name='ej.player.which.military'
009   |
010   |$att = [THIS] -> get attacker
011   |$race = [THIS] -> get owner race
012   |skip if $att == Player
013   ||$attrace = $att -> get owner race
014   |$bounty = [THIS] -> get local variable: name='ej.bounty'
015   |if $bounty == null
016   ||$bounty = 0
017   |end
018   |send incoming message 'Step1. Stats' to player: display it=[TRUE]
019   |
020   * Multipliers for attackers.
021   |
022   * All races x2 for X,K,Y and Enemy Race
023   * All races x2 for their Enemy
024   * All races x2 for Pirates except Teladi (x1)
025   * All races x0 for any other kills. You dont get paid for friendly fire!
026   |
027   * If the players military, or the race of the attacker is...
028   |
029   |if $mil OR $attrace == Argon
030   ||if $race == Paranid OR $race == Pirates
031   |||$multiplier = 2
032   ||else
033   |||$multiplier = 0
034   ||end
035   ||
036   |else if $mil OR $attrace == Boron
037   ||if $race == Split OR $race == Pirates
038   |||$multiplier = 2
039   ||else
040   |||$multiplier = 0
041   ||end
042   ||
043   |else if $mil OR $attrace == Split
044   ||if $race == Boron OR $race == Pirates
045   |||$multiplier = 2
046   ||else
047   |||$multiplier = 0
048   ||end
049   ||
050   |else if $mil OR $attrace == Paranid
051   ||if $race == Argon OR $race == Pirates
052   |||$multiplier = 2
053   ||else
054   |||$multiplier = 0
055   ||end
056   ||
057   |else if $mil OR $attrace == Teladi
058   ||if $race == Pirates
059   |||$multiplier = 1
060   ||else
061   |||$multiplier = 0
062   ||end
063   ||
064   * If the the race of the attacker is... (player cant join mil. for these races)
065   ||
066   |else if $attrace == Yaki
067   ||$multiplier = 2
068   ||
069   |else if $attrace == Terran
070   ||$multiplier = 0
071   ||
072   |else if $attrace == ATF
073   ||$multiplier = 0
074   ||
075   |else if $attrace == Pirates
076   ||if $race == Teladi
077   |||$multiplier = 1
078   ||else
079   |||$multiplier = 2
080   ||end
081   ||
082   |else if $attrace == Enemy Race
083   ||$multiplier = 2
084   ||
085   |else if $attrace == Kha'ak
086   ||$multiplier = 2
087   ||
088   |else if $attrace == Xenon
089   ||$multiplier = 2
090   ||
091   |else
092   ||send incoming message 'Unknown military or race as killer, may cause problems.' to player: display it=[TRUE]
093   |end
094   |
095   * If the killed ship is X,K,Y or ER, it x2 to the killer to overide x0s above!
096   |
097   |if $race == Xenon OR $race == Kha'ak OR $race == Yaki OR $race == Enemy Race
098   ||$multiplier = 2
099   |end
100   |
101   |send incoming message 'Step2. Multis' to player: display it=[TRUE]
102   * Works out worth of ship.
103   |
104   |$waretype = [THIS] -> get ware type code of object
105   |$shipbase = get average price of ware $waretype
106   |
107   |send incoming message 'Step3. Values' to player: display it=[TRUE]
108   |
109   * Works out worth of ships items as minimal
110   |$count =  size of array $arr
111   |while $count
112   ||dec $count = 
113   ||$item = $arr[$count]
114   ||$amountware = [THIS] -> get amount of ware $item in cargo bay
115   ||$itemworth = get min price of ware $item
116   ||$worth = $worth + ( $itemworth * $amountware )
117   ||send incoming message 'Counting through the ships wares...' to player: display it=[TRUE]
118   |end
119   |
120   * Works out worth of ships items plus the base ship cost
121   |$finalworth = $worth + $shipbase
122   |
123   * Player is killer - recieves previous bounties plus worth, affected by a Xplier.
124   |if $attrace == Player
125   ||$finalpayout = ( $bounty + $finalworth ) * $multiplier
126   ||add money to player: $finalpayout
127   ||send incoming message 'You just recieved...' to player: display it=[TRUE]
128   ||
129   * Player isnt killer - killer gets worth added to its bounty, which is now found.
130   |else if $attrace != Player
131   ||$bounty = $att -> get local variable: name='ej.bounty'
132   ||if $bounty == null
133   |||$bounty = 0
134   |||$bounty = ( $bounty + $finalworth ) * $multiplier
135   |||$att -> set local variable: name='ej.bounty' value=$bounty
136   ||end
137   |end
138   end
139   
140   * Notes
141   
142   * Killed ships belonging to player pass the item & ship worth on when killed.
143   * As you, the pilot, is not dead, theres no bounty.
144   
145   * Bounties betweem race doesnt matter.
146   * EG. Pirate kills Xenon, Player as Argon mil. kills Pirate.
147   * Bounty passed on contains a Xenon kill by the pirate.
148   * Surely thats good for the military!? No. Reasoning as such:
149   * Pirate survives Xenon attack, is obviously skilled & a threat therefore.
150   * Pirate -> Xenon bounty is passed on to the player.
151   * Lets say the multiplier has made it huge, Pirates killing Boron.
152   return null
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

As I said here "get ware array" is the wrong command for your purpose.
I guess, you want to get ALL wares on the ship, right? To do so, the only possibilty is to loop through all main and subtypes, which can be quite time consuming.

Greetings,
ScRaT

PS: Other than that, you code looks way better than before!
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Oh well. I'll get a loop of every Maintype and Subtype running, check to see if there are any, then amount, then get waretype then get price?

Right?
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Yeah, but you don't need every maintype, only the ones from 8 to 16, because the other maintypes represent stations, asteroids, etc.
But you should really test, if it isn't too performance or time consuming. If so, you might think about simply using "get tradable ware array" and ignore installed items. But that's really up to you, since I don't know what you have in mind.

Greetings,
ScRaT
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Got 2 loops running next to eachother, loops maintypes 8-16 and the subtypes for each, but I've hit a blank... what do I want to do now? On the loop through subtypes do I see then say 'get waretype code for maintype / subtype' 'how many on ship' 'work out worth' or am I confused.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

So, this is the first 30 lines, I'm stuck after that. (Mental block)

Forgotten how to say 'Ware worth onboard = this worth + previous total worth'

Code: Select all

001   $Checks = [THIS] -> get local variable: name='ej.bounty.doublesig'
002   if $Checks != [TRUE]
003   |[THIS] -> set local variable: name='ej.bounty.doublesig' value=[TRUE]
004   |send incoming message 'Wow, it actually working' to player: display it=[TRUE]
005   |
006   |$Maintype =  array alloc: size=0
007   |append 8 to array $Maintype
008   |append 9 to array $Maintype
009   |append 10 to array $Maintype
010   |append 11 to array $Maintype
011   |append 12 to array $Maintype
012   |append 13 to array $Maintype
013   |append 14 to array $Maintype
014   |append 15 to array $Maintype
015   |append 16 to array $Maintype
016   |$MainCount =  size of array $Maintype
017   |while $MainCount
018   ||dec $MainCount = 
019   ||$MaintypeNumber = $Maintype[$MainCount]
020   ||$Subtypes =  get number of subtypes of maintype $MaintypeNumber
021   ||$SubCount =  size of array $Maintype
022   ||while $SubCount
023   |||dec $SubCount = 
024   |||$SubtypeNumber = $Subtypes[$SubCount]
025   |||$wareonboard =  get ware from maintype $MaintypeNumber and subtype $SubtypeNumber
026   |||$Amount = [THIS] -> get amount of ware $wareonboard in cargo bay
027   |||$Min = get min price of ware $wareonboard
028   |||$worth = $Amount * $Min
029   ||end
030   |end

EDIT:

IT WORKS, IT BALLY WELL WORKS! :o

EDIT2: You get a fifth of the ship price plus onboard stuff minimum price. So killing an freighter will get you less than most combat ships... Problem is the signals appear to be sort of overlapping worriedly...

Basically, I run the command to lay signal, kill a ship, get money, celebrate, add another and kill it, get money... hey, wait, I didn't run a signal whilst that second one existed. :o

AH!

It's like the signals running constanly?

Not only that, it works even though I put in a check to make sure you're part of the 'military'. Still pays you. And doesn't appear to pay 1/5th, more like a half.

AND, if that weren't bad enough, sometimes it pays you, sometimes not... arg! It'll be a problem with putting 'end' in the wrong place.

Anyway, I'll share it with you. My pride and joy:

Code: Select all

001   $Checks = [THIS] -> get local variable: name='ej.bounty.doublesig'
002   if $Checks != [TRUE]
003   |[THIS] -> set local variable: name='ej.bounty.doublesig' value=[TRUE]
004   |send incoming message 'Wow, it actually working' to player: display it=[TRUE]
005   |
006   |$Maintype =  array alloc: size=0
007   |append 8 to array $Maintype
008   |append 9 to array $Maintype
009   |append 10 to array $Maintype
010   |append 11 to array $Maintype
011   |append 12 to array $Maintype
012   |append 13 to array $Maintype
013   |append 14 to array $Maintype
014   |append 15 to array $Maintype
015   |append 16 to array $Maintype
016   |$MainCount =  size of array $Maintype
017   |while $MainCount
018   ||dec $MainCount = 
019   ||$MaintypeNumber = $Maintype[$MainCount]
020   ||$Subtypes =  get number of subtypes of maintype $MaintypeNumber
021   ||$SubCount =  size of array $Maintype
022   ||while $SubCount
023   |||dec $SubCount = 
024   |||$SubtypeNumber = $Subtypes[$SubCount]
025   |||$wareonboard =  get ware from maintype $MaintypeNumber and subtype $SubtypeNumber
026   |||$Amount = [THIS] -> get amount of ware $wareonboard in cargo bay
027   |||$Min = get min price of ware $wareonboard
028   |||$worth = $Amount * $Min
029   |||skip if $Tot.OnboardWorth != null
030   ||||$Tot.OnboardWorth = 0
031   |||$Tot.OnboardWorth = $Tot.OnboardWorth + $worth
032   ||end
033   |end
034   |
035   |
036   * Basic stats...
037   |$mil = get global variable: name='ej.player.which.military'
038   |if $mil != null
039   ||
040   ||$att = [THIS] -> get attacker
041   ||$race = [THIS] -> get owner race
042   ||skip if $att == Player
043   |||$attrace = $att -> get owner race
044   ||$bounty = [THIS] -> get local variable: name='ej.bounty'
045   ||if $bounty == null
046   |||$bounty = 0
047   ||end
048   ||send incoming message 'Step1. Stats' to player: display it=[TRUE]
049   ||
050   * Multipliers for attackers.
051   ||
052   * All races x2 for X,K,Y and Enemy Race
053   * All races x2 for their Enemy
054   * All races x2 for Pirates except Teladi (x1)
055   * All races x0 for any other kills. You dont get paid for friendly fire!
056   ||
057   * If the players military, or the race of the attacker is...
058   ||
059   ||if $mil OR $attrace == Argon
060   |||if $race == Paranid OR $race == Pirates
061   ||||$multiplier = 2
062   |||else
063   ||||$multiplier = 0
064   |||end
065   |||
066   ||else if $mil OR $attrace == Boron
067   |||if $race == Split OR $race == Pirates
068   ||||$multiplier = 2
069   |||else
070   ||||$multiplier = 0
071   |||end
072   |||
073   ||else if $mil OR $attrace == Split
074   |||if $race == Boron OR $race == Pirates
075   ||||$multiplier = 2
076   |||else
077   ||||$multiplier = 0
078   |||end
079   |||
080   ||else if $mil OR $attrace == Paranid
081   |||if $race == Argon OR $race == Pirates
082   ||||$multiplier = 2
083   |||else
084   ||||$multiplier = 0
085   |||end
086   |||
087   ||else if $mil OR $attrace == Teladi
088   |||if $race == Pirates
089   ||||$multiplier = 1
090   |||else
091   ||||$multiplier = 0
092   |||end
093   |||
094   * If the the race of the attacker is... (player cant join mil. for these races)
095   |||
096   ||else if $attrace == Yaki
097   |||$multiplier = 2
098   |||
099   ||else if $attrace == Terran
100   |||$multiplier = 0
101   |||
102   ||else if $attrace == ATF
103   |||$multiplier = 0
104   |||
105   ||else if $attrace == Pirates
106   |||if $race == Teladi
107   ||||$multiplier = 1
108   |||else
109   ||||$multiplier = 2
110   |||end
111   |||
112   ||else if $attrace == Enemy Race
113   |||$multiplier = 2
114   |||
115   ||else if $attrace == Kha'ak
116   |||$multiplier = 2
117   |||
118   ||else if $attrace == Xenon
119   |||$multiplier = 2
120   |||
121   ||else
122   |||send incoming message 'Unknown military or race as killer, may cause problems.' to player: display it=[TRUE]
123   ||end
124   ||
125   * If the killed ship is X,K,Y or ER, it x2 to the killer to overide x0s above!
126   ||
127   ||if $race == Xenon OR $race == Kha'ak OR $race == Yaki OR $race == Enemy Race
128   |||$multiplier = 2
129   ||end
130   ||
131   ||send incoming message 'Step2. Multis' to player: display it=[TRUE]
132   * Works out worth of ship.
133   ||
134   ||$waretype = [THIS] -> get ware type code of object
135   ||$shipcost = get average price of ware $waretype
136   ||$shipbase = $shipcost / 5
137   ||
138   ||send incoming message 'Step3. Values' to player: display it=[TRUE]
139   ||
140   * Works out worth of ships items plus the base ship cost
141   ||$finalworth = $worth + $shipbase
142   ||
143   * Player is killer - recieves previous bounties plus worth, affected by a Xplier.
144   ||if $attrace == Player
145   |||$finalpayout = ( $bounty + $finalworth ) * $multiplier
146   |||add money to player: $finalpayout
147   |||$stringfinal =  convert number $finalpayout to string
148   |||send incoming message $stringfinal to player: display it=[TRUE]
149   |||
150   * Player isnt killer - killer gets worth added to its bounty, which is now found.
151   ||else if $attrace != Player
152   |||$bounty = $att -> get local variable: name='ej.bounty'
153   |||if $bounty == null
154   ||||$bounty = 0
155   ||||$bounty = ( $bounty + $finalworth ) * $multiplier
156   ||||$att -> set local variable: name='ej.bounty' value=$bounty
157   |||end
158   ||end
159   |end
160   end
161   
162   * Notes
163   
164   * Killed ships belonging to player pass the item & ship worth on when killed.
165   * As you, the pilot, is not dead, theres no bounty.
166   
167   * Bounties betweem race doesnt matter.
168   * EG. Pirate kills Xenon, Player as Argon mil. kills Pirate.
169   * Bounty passed on contains a Xenon kill by the pirate.
170   * Surely thats good for the military!? No. Reasoning as such:
171   * Pirate survives Xenon attack, is obviously skilled & a threat therefore.
172   * Pirate -> Xenon bounty is passed on to the player.
173   * Lets say the multiplier has made it huge, Pirates killing Boron.
174   return null
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Code: Select all

040   ||$att = [THIS] -> get attacker 
...
042   ||skip if $att == Player
043   |||$attrace = $att -> get owner race
...
144   ||if $attrace == Player
There are two errors here.

1. If $att was the player, $attrace would never be set and thus "if $attrace == Player" will never be true.

2. I'm pretty sure that the "get attacker" command returns an object and not a race. So comparing $att to a race (Player) is not the right thing to do. You could either compare the race of $att to Player or you could compare $att directly to [PLAYERSHIP] (I'm not sure, what you want to do exactly).
In the first case, it would also work for your AI Ships, in the second case only for the playership.

I'm not sure, whether this solves the inconsitent behaviour though.
Not only that, it works even though I put in a check to make sure you're part of the 'military'. Still pays you. And doesn't appear to pay 1/5th, more like a half.
One easy method to observe how your code is executed are debug statements, which write some values to your logbook. Just check on an easy test case, whether all variables have the correct value, etc.

And now some tips on your code:

Code: Select all

001   $Checks = [THIS] -> get local variable: name='ej.bounty.doublesig'
002   if $Checks != [TRUE] 
You can simplify this by writing only:

Code: Select all

if not get global variable 'ej.bounty.doublesig'
Plus, instead of putting all the code inside this conditional statement, I'd do this:

Code: Select all

skip if not get global variable: name = 'ej.bounty.doublesig'
return null
set global variable: name = 'ej.bounty.doublesig' value=[TRUE]
That's not really important, but it's easier to understand.

Code: Select all

029   |||skip if $Tot.OnboardWorth != null
030   ||||$Tot.OnboardWorth = 0 
Simply create $Tot.OnboardWorth before the $MainCount - loop and you don't need such a strange structure.

Code: Select all

037   |$mil = get global variable: name='ej.player.which.military'
038   |if $mil != null 
Same as with the other global variable.

Code: Select all

153   |||if $bounty == null
154   ||||$bounty = 0
155   ||||$bounty = ( $bounty + $finalworth ) * $multiplier 
Simply write:

Code: Select all

if not $bounty
  $bounty = ( $bounty + $finalworth ) * $multiplier
Greetings,
ScRaT
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Thanks for the tips, solved soem of the problems, still working on a few more at the moment.

And, I don't seem to be getting money for onboard stuff.

Which means

1. Another one of those errors is causing an problem with it
2. It really can't get the wares of a 'husk'
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

1. Another one of those errors is causing an problem with it
2. It really can't get the wares of a 'husk'
As I said, you can only check those with debug messages.
So first you format your text and then write to the player logbook:

Code: Select all

$text = sprintf: fmt='Wares on board: %s, Worth: %s', $warearray, $worth, null, null, null
write to player logbook $text
As for 2.: For me it worked.

Greetings,
ScRaT
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

Hint
And, I don't seem to be getting money for onboard stuff.
Check your maintype/subtype loops.
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

I'll deal with all that later. I have more pressing matters now.

My previous script which swaps round weapons, I was trying to get something to install lasers after I got the PBE/PBG removal to work... and I've got it!

Look. I got an Adv. Mamba 4 PBGs and ran it, look now!

http://i758.photobucket.com/albums/xx22 ... 1270836888

And this is important. I should get a beta out ASAP. Why? Because just now :o : http://forum.egosoft.com/viewtopic.php?t=275079


I think it makes it more realistic that Pirates will be armed with whatever they can get their grubby hands on!

I'll fix this up then follow your suggestions for my other. I feel inspired...
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Hint
Good hint, which should solve everything! I didn't even consider, that this could be the source of the problem. xD

@EmperorJon
Just think again about how loops work, what arrays are, and what they are not.
Hint: Is $Subtypes really an array?

Greetings,
ScRaT
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Hint: Is $Subtypes really an array?
Sorry Mark, didn't see your post (wasn't there before I began typing)

No. It's not. And as far as I can see I'm not treating it so. :wink:
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

EmperorJon wrote:No. It's not. And as far as I can see I'm not treating it so. :wink:
Look harder.

Code: Select all

020   ||$Subtypes =  get number of subtypes of maintype $MaintypeNumber 
021   ||$SubCount =  size of array $Maintype 
022   ||while $SubCount 
023   |||dec $SubCount = 
024   |||$SubtypeNumber = $Subtypes[$SubCount]
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Yarr! There be the blight'r!

I think more or less all of that array's wrong anyway. Look:

Code: Select all

001   $Checks = [THIS] -> get local variable: name='ej.bounty.doublesig' 
002   if $Checks != [TRUE] 
003   |[THIS] -> set local variable: name='ej.bounty.doublesig' value=[TRUE] 
004   |send incoming message 'Wow, it actually working' to player: display it=[TRUE] 
005   | 
006   |$Maintype =  array alloc: size=0 
007   |append 8 to array $Maintype 
008   |append 9 to array $Maintype 
009   |append 10 to array $Maintype 
010   |append 11 to array $Maintype 
011   |append 12 to array $Maintype 
012   |append 13 to array $Maintype 
013   |append 14 to array $Maintype 
014   |append 15 to array $Maintype 
015   |append 16 to array $Maintype 
016   |$MainCount =  size of array $Maintype 
017   |while $MainCount 
018   ||dec $MainCount = 
019   ||$MaintypeNumber = $Maintype[$MainCount] 
020   ||$Subtypes =  get number of subtypes of maintype $MaintypeNumber 
021   ||$SubCount =  size of array $Maintype 
022   ||while $SubCount 
023   |||dec $SubCount = 
024   |||$SubtypeNumber = $Subtypes[$SubCount] 
025   |||$wareonboard =  get ware from maintype $MaintypeNumber and subtype $SubtypeNumber 
Or is it, I'm confused. That's the only mistake isn't it...?


EDIT: <3 you all. :roll:

It's WURKEN! :lol:
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

That's still wrong - you have $Subcount as the number of maintypes rather than the number of subtypes. You're also trying to extract the subtype number from a variable which is not an array.

Code: Select all

017   |while $MainCount 
018   ||dec $MainCount = 
019   ||$MaintypeNumber = $Maintype[$MainCount] 
020   ||$SubtypeNumber =  get number of subtypes of maintype $MaintypeNumber 
022   ||while $SubtypeNumber
023   |||dec $SubtypeNumber = 
025   |||$wareonboard =  get ware from maintype $MaintypeNumber and subtype $SubtypeNumber
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

I thought so, but it seems to be working fine. I just loaded a ship with expensive guns and killed it and got paid loads?
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

006 |$Maintype = array alloc: size=0
007 |append 8 to array $Maintype
008 |append 9 to array $Maintype
009 |append 10 to array $Maintype
010 |append 11 to array $Maintype
011 |append 12 to array $Maintype
012 |append 13 to array $Maintype
013 |append 14 to array $Maintype
014 |append 15 to array $Maintype
015 |append 16 to array $Maintype
016 |$MainCount = size of array $Maintype
017 |while $MainCount
This may work, but it's ugly as hell. ;)
Following is my version of the Maintype-Subtype loop:

Code: Select all

$maintype = 8
while $maintype <= 16
  $subtype = get number of subtypes of maintype $maintype 
  while $subtype
    dec $subtype=
    $ware = get ware from maintype $maintype and subtype $subtype
    */ Do anything you want here /*
  end
  inc $maintype=
end
That's it. No black magic, just straight ahead.
I thought so, but it seems to be working fine. I just loaded a ship with expensive guns and killed it and got paid loads?
But wouldn't it be better, if you understood why your script is working?

Greetings,
ScRaT
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

But wouldn't it be better, if you understood why your script is working?
:lol:
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______

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