[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
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

@ScRaT_GER, EmperorJon (btw, cool Jon pic :P)

I haven't read your script in much detail, but just be aware, there is a different between type and class.
e.g.

"Argon Mercury Wheat trader" that is flying around in space, is a an object, of type Mercury (Tship_a_ts_001 or what ever, maintype x, subtype y)
And this type, happens to also be of class TS, which is of class transport ship, which is of class ship, which is a type of class movable object, which is of class object

An object is an actual thing, in space, that you can blow up (if it can die, its an object - there are some exceptions)
A type, is something category of objects, represented by a maintype and a subtype. e.g. maintype 11, subtype 0 represents energy cells
A class, is grouping of types or classes. (see pg 107 of the msci)


So you also have to be careful when you use things like
$FClass = $FShip -> get object class
As I'm fairly certain it returns the class, and not the type
(i.e. It will return TS, and not Argon Mercury maintype x subtype y)
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

As I'm fairly certain it returns the class, and not the type
Oops, you're right.

@EmperorJon

Simply use the following command instead:
$FType = $FShip -> get ware type code of object

And of course change $FClass in the "create ship" command to $FType.

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

Post by EmperorJon »

I was indeed pointing out that there was a problem there and I didn't know what command to fix it.

Anyway, I'm more concerned over the simple problem.

I can use that to exclude TS, TP etc. easily, but why is it doing that in the first place!?

It only does that if I swap the two = 1 [2] values around in the array command, and as it is now which is as it should be to work, it just makes M1s, or if I swap all the append to arrays around, M8s and then Mammoths.

So it's counting up beyond M8s and heading into nothing, or down below M1s but staying in M1, as oppose to going M1 M2 M3 etc...

Or so I thought.

But as I said, the logfile says it's checking M1s M2s etc. but only ever makes the M1s!?

What's wrong with it!? :lol:
______
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 »

FIXED! :D
______
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 »

I can use that to exclude TS, TP etc. easily, but why is it doing that in the first place!?

It only does that if I swap the two = 1 [2] values around in the array command
How did you write the code, if you don't know what it does?

The array commands are always like this:
$array[$index] = $value
$value = $array[$index]
FIXED! Very Happy
And did you understand, why it is fixed?

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

Post by EmperorJon »

I do know how to use it? When did I say I didn't?


And yes, I know why it's fixed.

It was using up all of the BaseNumber (multiplied) on the first class.

By moving that value into before the next array starts it refreshes with each new class.

However, this means I get the same number of every class, so now I've just manually input how many I want.

I'm going to rip the support script up, copy it, and make one for every mission, instead of all of them in 1 script. I can get greater control over what each one does then. It's for the best, even if it does mean I have loads of scripts.
______
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 »

I do know how to use it? When did I say I didn't?
My question was:
How did you write the code, if you don't know what it does?

I was only asking, because of your statements concerning arrays, which seemed a bit vague at some points.
However, this means I get the same number of every class, so now I've just manually input how many I want.
Maybe you could add another modifier for each ship class.
I'm going to rip the support script up, copy it, and make one for every mission, instead of all of them in 1 script. I can get greater control over what each one does then. It's for the best, even if it does mean I have loads of scripts.
Yes, definitely. You could also consider creating separate scripts for certain tasks, like spawning ships.
Then you'd have almost the same system the Vanilla MD Missions use (Opponent Balancing System), which is a library, whose only purpose is to spawn a suitable amount of enemies.


Btw: You wrote:
If I could do it MD I would, but the fact that you choose to do the missions yourself and they give you a rank and everything means I'd need to make every military into a corporation to do it.
I don't quite understand the reasoning behind that. Maybe there's a misunderstanding of how the MD works, which could save you a huge amount of difficult SE-Mission-Coding, because that's exactly the field the MD is good at.

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

Post by EmperorJon »

The fact is I'd need 5 new ranking system/corporation things which only gave you a mission when asked for, and which intergrated with various scripting...

I'll stick to SE thanks.

:P

Anyway, yes, I know have a script for each mission, and for spawning each mission's support.

So that's about 20 already. -.-
______
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 »

I assume...

Code: Select all

086   Begin:
087 @ = wait 5000 ms
088   inc $timecheck = 
089   $Sec = $Sector -> get station array from sector
090   $Count =  size of array $Sec
091   send incoming message $Count to player: display it=[TRUE]
092   inc $Checks = 
093   while $Count
094   |dec $Count = 
095   |$Out = $Sec[$Count]
096   |$Owner = $Out -> get owner race
097   |display subtitle text: text=$F2 duration=1000 ms
098   |if $Owner == $Enemy
099   ||if $Out -> exists
100   |||skip if not  has $Out been discovered
101   ||||goto label Begin
102   |||send incoming message 'One has been discovered.' to player: display it=[TRUE]
103   |||skip if $Checks == $Count
104   ||||goto label Begin
105   |||$Plsec = [PLAYERSHIP] -> get sector
106   |||if $Plsec != $Sector
107   ||||send incoming message 'Hey, pilots who actually attack the target usually go better.' to player: display it=[TRUE]
108   |||else if $Plsec == $Sector
109   ||||send incoming message 'Mission complete!' to player: display it=[TRUE]
110   |||end
111 @ |||= [THIS] -> call script 'ej.military.remove.support' :  sector=$Sector
112   ||end
113   |end
114   end
115   return null
Should work as a recon mission? I've never used 100 'has $Out been discovered'... And I think I messed arrays up again somewhere.

EDIT: Completely changed the script after noticing problems. Still, is that how that command works?
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

@ Emperor Jon about general script design

It is (in my opinion, and I think gazz said it before.. some where as well) much easier to do this:
If not...
|continue
end
...

Than to do:
if
|if
||if
||end
|end
end


As it is easier to debug
(Also once you have else if and else's in there, it becomes nightmarish to read when you have them all nested in each other)




e.g. consider:

086 Begin:
087 @ = wait 5000 ms
088 inc $timecheck =
089 $Sec = $Sector -> get station array from sector
090 $Count = size of array $Sec
091 send incoming message $Count to player: display it=[TRUE]
092 inc $Checks =
093 while $Count
094 |dec $Count =
095 |$Out = $Sec[$Count]
096 |$Owner = $Out -> get owner race
097 |display subtitle text: text=$F2 duration=1000 ms
098 |if not $Owner == $Enemy
continue
end


099 ||if not $Out -> exists
continue
end

100 |||skip if not has $Out been discovered
101 ||||goto label Begin
102 |||send incoming message 'One has been discovered.' to player: display it=[TRUE]
103 |||skip if $Checks == $Count
104 ||||goto label Begin
105 |||$Plsec = [PLAYERSHIP] -> get sector

106 |||if $Plsec != $Sector
107 ||||send incoming message 'Hey, pilots who actually attack the target usually go better.' to player: display it=[TRUE]
108 |||else if $Plsec == $Sector
109 ||||send incoming message 'Mission complete!' to player: display it=[TRUE]
110 |||end
111 @ |||= [THIS] -> call script 'ej.military.remove.support' : sector=$Sector



114 end
115 return null





----
Unrelated side ... question/query
I thought that the discovered ness of value, was for the encyclopedia, (i.e. you discovered types, not objects)?
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

No idea, but I've restructured it still using that discovered command...

US with Duke's. 1 station. Found it, mission complete.
XC023. 2 stations. Found one, nothing, found second, mission complete.

Looks like it works... ;)
______
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 »

Just for a little confirmation on while, dec. loops...

Ending the while is where it should reach before going back, decreasing again and continuing, until the while is untrue then it ignores the end.

That's pretty straightforward. But are there any known... instances of it just continuing beyond the end? When it shouldn't do...? :roll:
______
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 »

But are there any known... instances of it just continuing beyond the end? When it shouldn't do...?
Yes, when your loop condition is incorrect.
For arrays, you can always use the following structure to traverse backwards:

Code: Select all

$array = array alloc: size = 5
$count = size of array $array
while $count
  dec $count= 
  $element = $array[$count]
end
"while $count" simply means, that as long as the object refered to by $count evaluates to true, the loops body should be executed. In this case the object refered to by $count is an integer, which will, at some point, reach the value 0.
0, null and [FALSE] are the only variables which evaluate to false, so the loop finishes.

The above structure is fool-proof - it will always traverse the complete array, not more, not less.
But if you get the variable $count somehow different, e.g. by manually assigning a value to it and if this value is negative by accident, you'll have a infinite loop.

There are of course many other possibilities to traverse beyond the limits of an array, so you'd have to show some code for us to be able to help you.

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

Post by EmperorJon »

I found out my mistake.

I forgot to set count as the size of the array, and fixed it. :roll:

Now I've honed in on my text problems too... I know that [red][/red] etc. doesn't work in menus, but all my messages using the alternative method don't come up.

Is it a case of 1 for menus and 1 for messages? Or have I got other problems?

Every message of mine using \033YSpecial Task-Force Unit\033X as an example, won't show up. This does fine because it's in a menu, but as a message, nope...

So is it true!? :roll:
______
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 »

Is it a case of 1 for menus and 1 for messages?
Yes, unfortunately.

Nobody understands why, but Egosoft arranged it that way...

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

Post by EmperorJon »

I guess we'll never know.

Ah well, sorted most of it now. Time to start textifying! :D
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
Logain Abler
Posts: 2255
Joined: Mon, 31. Oct 05, 08:44
x4

Post by Logain Abler »

EmperorJon wrote:I guess we'll never know.

Ah well, sorted most of it now. Time to start textifying! :D
textifying! class name for it :) Last thing I do and it usually takes the longest.. after fixng all the bugs/features :oops:
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

I'm not the only person who has to do it afterwards!? :O

An actual proffesional does it the same way AS ME!?

:lol:
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
Logain Abler
Posts: 2255
Joined: Mon, 31. Oct 05, 08:44
x4

Post by Logain Abler »

EmperorJon wrote: An actual proffesional does it the same way AS ME!?

:lol:
You haven't seen my code then! But thx :D

LV, Cycrow, Gazz, ScRaT_GER and a a few others, now they are professionals.

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

Post by EmperorJon »

Hmm, I can't seem to find a default vanilla script to dock a ship with another ship...? Anyone help?

Oh, and I see you added someone to that list since I last looked. :P
______
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”