[Discussion] Generic X3TC S&M questions I

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
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

Code like that is what nerd moms show their nerd kids to scare them into eating their veggies.
Direct jumps out of a while loop and to the same subroutine? *shudder*
Do you know where the next Return will lead? Maybe into a loop that now has an undefined beginning and condition?
It takes an interpreter with a strong stomach to digest this kinda recursion.

Write a better loop instead and get used to Continue and Break. =)
That is infinitely easier to debug, too.
Well, unless you have one of those newfangled 7-dimensional brains and the above code and all it's resulting recursions is perfectly clear to you.
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.
WindsOfBoreas
Posts: 283
Joined: Sun, 3. Aug 08, 20:30

Post by WindsOfBoreas »

I just checked and I was right...there is a rift in our universe. It's causing our physical laws to become more like the universe it is connected to. In no time at all, causality itself will become distorted. Quick, someone divide by zero! Hopefully that will save us all!
"Humanity has the stars in its future, and that future is too important to be lost under the burden of juvenile folly and ignorant superstition." - Isaac Asimov
pelador
Posts: 1399
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by pelador »

Mobius strip animation

Sorry couldn't resist.

Also remember you can use internal script calls as functional elements in a script to reduce the amount of duplicated tasks by using the return variable. This is marginally slower than keeping things in a routine and obviously can be compounded further if used within nested while loops. So it isnt the best choice for performance/optimization but may help with some scripts.
User avatar
chaosras
Posts: 99
Joined: Thu, 28. Oct 04, 18:50
x3tc

Post by chaosras »

s9ilent wrote: ...

Everything else ONLY use \033R type colour flags. And these tags have to be imported from a tfile (thou you can sprintf something like \033R%s\033X if you need a more generic option). e.g. This can include: Object names, menu's, command related stuff, al plugins etc. everything except logbooks. These can NOT take format tags (AFAIK)
I don't follow, are you saying I can get around using a tfile by using a sprintf command in my script?
Space Cowboy - http://www.myspace.com/hardknight

"I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion.
I watched C-beams glitter in the dark near Tannhäuser Gate. All those moments will be
lost in time, like tears in rain."
- R. Batty

HKP Transponder Interface Software
HKP Enhanced Missile Barrage
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Yes, but you have to use the \033R type colour tags for non log book stuff.

e.g. <t id="1550">\033R%s\033X</t> <--- in your text file
then use.. sprintf from page from text id 1550, arg1 2 3 4 5
User avatar
chaosras
Posts: 99
Joined: Thu, 28. Oct 04, 18:50
x3tc

Post by chaosras »

s9ilent wrote:Yes, but you have to use the \033R type colour tags for non log book stuff.

e.g. <t id="1550">\033R%s\033X</t> <--- in your text file
then use.. sprintf from page from text id 1550, arg1 2 3 4 5
But this still requires the t-file to exist, so I will take my conclusion from that fact... :P
Space Cowboy - http://www.myspace.com/hardknight

"I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion.
I watched C-beams glitter in the dark near Tannhäuser Gate. All those moments will be
lost in time, like tears in rain."
- R. Batty

HKP Transponder Interface Software
HKP Enhanced Missile Barrage
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22414
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

btw i will be building these things into the new plugin manager, so u wont need a text file to create coloured text

however it'll be awhile before thats ready for release
User avatar
chaosras
Posts: 99
Joined: Thu, 28. Oct 04, 18:50
x3tc

Post by chaosras »

Quick question, is it possible to set the command upgrade requirements to more than one ware? For example, I want a command that is available only if Navigation AND Exploration software are BOTH installed on a ship.
Space Cowboy - http://www.myspace.com/hardknight

"I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion.
I watched C-beams glitter in the dark near Tannhäuser Gate. All those moments will be
lost in time, like tears in rain."
- R. Batty

HKP Transponder Interface Software
HKP Enhanced Missile Barrage
WindsOfBoreas
Posts: 283
Joined: Sun, 3. Aug 08, 20:30

Post by WindsOfBoreas »

Edited since it was incorrect..

Check out the big brain on Gazz.
Last edited by WindsOfBoreas on Tue, 11. Aug 09, 18:52, edited 1 time in total.
"Humanity has the stars in its future, and that future is too important to be lost under the burden of juvenile folly and ignorant superstition." - Isaac Asimov
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

These are not binary flags. They cannot be ORed just like banana ice cream cannot be ORed.

You probably need to use a check script.
Brother Maynard! Read us the passage about check scripts from the holy MSCI!
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.
WindsOfBoreas
Posts: 283
Joined: Sun, 3. Aug 08, 20:30

Post by WindsOfBoreas »

Banana ice cream can be oared though...such a mess.
"Humanity has the stars in its future, and that future is too important to be lost under the burden of juvenile folly and ignorant superstition." - Isaac Asimov
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Just one more thing about check scripts.

Whilst you can use return Com.disabled (I think that's what its called) to show that the command is un-selectable if its missing the second software piece, if you want it to not display at all, you have to return null

e.g. This will just not show the command at all if the ware is not present

Code: Select all

skip if $ship get amt of ware $ware
return null
return true
e.g. This will show the command, but it will be grey'ed out

Code: Select all

skip if $ship get amt of ware $ware
return [Com.disabled]
return true

---------------------------------------------------

Q: One way gates
I'm just looking for some info on 1 way gates (I can't seem to find the info in the X3R/X2 stickies any more :S). More specifically, what gate ID's do they use?

I was under the impression that they use -1, and that they link to a gate of any id. (Or may be I had it the other way around, they have id 0-6 and link to -1's.... orrrrr.. maybe I imagined it again?)
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Where as a normal script, when it is interrupted, it would stop at the next break point, do the interrupt task, then return to the break point; A fly command when interrupted, will just end and return the flret_interupted. So typically, when the flret_interupted is encountered, you just repeat the fly command (thou most scripts catch this exception with a if not xxxxx, rather then catching that exception specifically)
Thanks for the answer. That's how I did it. However I still find it odd, that the FLRET_INTERRUPTED even fired, because the ship was OOS and there was now ship around which could have caused that.

Well, however I have another problem:

I'm experiencing strange behaviour with SIGNAL_SELWARE (most probably also SIGNAL_BUYWARE).
I have connected the SIGNAL_SELWARE to a station -- let's say a cahoona fab.
When I now move the blue slider to buy something WITHOUT actually doing so, the signal fires.

Is this intended or am I doing something wrong?

Greets,
ScRaT
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Wooot? Stations can use the signal too? I thought it was just for ships?
Out of curiosity, what are the arguments that it returns? (When your moving the blue with out trading?)



w.r.t flret_interrupted
It could be possible that other signals are firing (Attacked, leader needs help, leader jumping)
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Okay, my fault -- it was late yesterday. The signal works just fine!
Only fires, when something is really bought.
Wooot? Stations can use the signal too? I thought it was just for ships?
No, it's not. But remember, that when a station buys something, a ship is actually selling it.

The arguments are:
* 1: ship , Var/Ship , 'trading partner'
* 2: ware , Var/Ware , 'ware'
* 3: amount , Var/Number , 'amount'
* 4: price , Var/Number , 'price'

There is also a fifths argument returning special wares, like marines.
It could be possible that other signals are firing (Attacked, leader needs help, leader jumping)
No, as I said. In my whole testing universe, there is no other ship. The only thing that could be the reason is, that the ship was undocking before, but I left a wait of 1000 ms.
Additionally it happened all OOS...

Greets,
ScRaT
jay5965
Posts: 17
Joined: Thu, 24. Nov 05, 23:21
x3tc

Post by jay5965 »

What would cause the game to crash after the splash screen when loading a mod containing only one ship(body and scene files), a lang file, and a tships file?
This has really become quite a production to get a single ship working...hopefully the next one won't be so bad.

A copt of the .cat and .dat files are here...
http://www.mediafire.com/file/kzxlihozqgo/firstship.rar


...I have no idea what is wrong at this point, any ideas would be great.
Thanks.
ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh »

jay5965 wrote:What would cause the game to crash after the splash screen when loading a mod containing only one ship(body and scene files), a lang file, and a tships file?
This has really become quite a production to get a single ship working...hopefully the next one won't be so bad.

A copt of the .cat and .dat files are here...
http://www.mediafire.com/file/kzxlihozqgo/firstship.rar


...I have no idea what is wrong at this point, any ideas would be great.
Thanks.
If you are replacing a vanilla ship and you saved your game with one of those ships in the same sector as you, then it will crash on loading. Other than that I dunno.
There are 10 types of people in the S&M forums - those who understand binary, and those who don't.

Black holes are where God divided by zero.
jay5965
Posts: 17
Joined: Thu, 24. Nov 05, 23:21
x3tc

Post by jay5965 »

If you are replacing a vanilla ship and you saved your game with one of those ships in the same sector as you, then it will crash on loading. Other than that I dunno.
It crashes when starting the game from the launcher...I havent been able to even attempt to start a new game. Also, I made a new tships entry for it, so it isnt replacing any vanilla ships.

EDIT: I maganaged to get the ship into the game but textures do not display and the name is a readtext....
User avatar
chaosras
Posts: 99
Joined: Thu, 28. Oct 04, 18:50
x3tc

Post by chaosras »

So... I'm trying to spawn a new station in a sector, and it's acting weird.

a) No matter what x, y, z pos I use, it stays on the same spot in the sector (0,0,0), though targeting the new station will show its x, y, z as the ones I gave. Subsequently using a Set Position or Force Position script command has the same effect... changes the shown x, y, z but the station still sits on the same spot in the sector.

b) EDIT: Okay, I figured out this one...

Thanks!

EDIT AGAIN:

LOL Okay I figured the first one out too... was assuming x,y,z was in kilometers, but its in meters... heh. IGNORE POST THANKS!!
Space Cowboy - http://www.myspace.com/hardknight

"I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion.
I watched C-beams glitter in the dark near Tannhäuser Gate. All those moments will be
lost in time, like tears in rain."
- R. Batty

HKP Transponder Interface Software
HKP Enhanced Missile Barrage
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Q: How Large is a sector? And what is the max distance you can travel across it i.e. sqrt (x sq + y sq + z sq) ?


Context:
For my path finding script I'm adding up all the distances traveled, and I'm just wondering whether or not there is a chance of integer overflow and whether or not I should use a maths lib?

i.e. is 480 * max dist < 2 bil?
i.e. is max dist < 4.166 million?
i.e. is single axis max dist < 2.4 mil?

(by single axis dist i mean -n to + n)






Q2: Is the following code valid?
(i.e. Will it go B, A, B, or will something funkier happen?)

Code: Select all

gosub label2
gosub label1
return null

label1:
...stuff_A
label2:
...stuff_B
endsub

Context:
label 1 is called when an object in question dies, it performs clean up (stuff_A), and then picks the next best object (with code stuff_B)
label 2 is called when I just need to pick the next best (with out any clean up)








Q3: Do text files need to be in order?
e.g. tid 10, 9 8 7 6, is still valid right? i.e. They don't need to be incremental






Q4: I don't suppose someone knows what this equals? 224|2 (not in x3, but in ... ... computing.. bit flags type thing. (binary mask?)

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