[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
Graxster
Posts: 817
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster »

Couple of questions:

1. Does anyone know the weapon value of the Tractor Beam in X3TC? Tried looking in Plugin Manager - Ship Creator, but those values are incorrect. Changing it to 64 gave it a High Energy Plasma Thrower instead.

2. Where is the Text name of a ship stored? I don't see any text names in Tships. ie: Hyperion, Nemesis, etc.. and how is the text name associated with the Tships entry?


Thanks!
-Grax

Edit: removed question #3. Figured that one out.
Last edited by Graxster on Wed, 29. Oct 08, 22:03, edited 1 time in total.
User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube »

Cycrow wrote:
i am working on a hotkey manager which should help things eventually i think
Was going to do this myself until I ran into issues.

The global variables themselves don't seem to "refresh" properly/quickly. Meaning, the keys themselves, even if they have a value of "null" still show up in the "get global variables" return. Really odd. And sometimes, after setting one to null, the rest of them dissapear. Unexpected inconsitent results so far.

Cycrow, have you experienced this at all?
RyuNoKami
Posts: 18
Joined: Wed, 2. Aug 06, 22:26

Post by RyuNoKami »

ThisIsHarsh wrote::lol: @ Litcube. I honestly thought of saying something similar when I saw RyuNoKami's first post. A bit consice to say the least...

@RyuNoKami: You mean you simply want a new custom start? or you want to add in features to make it feel more like you have D&D style character stats and a face and voice of a certain race, etc? Either can be done to an extent, the second option is not trivial though.
yea basically a new custom start, like say Male Terran Soldier instead of just the female terran soldier and so on and so forth.
athelred
Posts: 20
Joined: Thu, 1. Jan 04, 23:07
x3

Get functions for marine skills

Post by athelred »

I am working on script for marine training. Setting the fight/hack/Mechanical/Engineering values is clear and easy, but for the life of me I cannot find a set of get functions. Is there one, and where is it located? It would seem odd if there were not.

Also, where might I find instructions for unpacking the MD files, and instructions in their use? Is there a manual like the one for MSCI available someplace? I stopped playing X3R before the mission director came out, so I have no experience with it.

athelred
User avatar
Graxster
Posts: 817
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster »

OK, I'm stumped on this one. Can you not use a Hotkey on a script that requires an Argument? I wrote a script that has the argument Var Sector Position. Did the usual $x=$pos[0] $y=$pos[1], etc... then wrote a Hotkey setup script to call this script. When I press the Hotkey, it doesn't ask you to choose a Sector and Position, it just warps the ship to current sector, position 0,0,0. Thanks!

-Grax

P.S. When I run the script manually from the editor, it works fine.
jlehtone
Posts: 22541
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

I would guess that script call via hotkey does not do the "fill in the arguments" routine like the calls via menu or from SE. But isn't there now a SE command to pop up an inputdialog within code, or is that for strings only?
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.
User avatar
Graxster
Posts: 817
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster »

I also tried removing the Argument and adding to the first line of the script:
"$pos = [THIS] -> get user input, type: Var/Sector Position, title=null", and that didn't work either.

-Grax
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22437
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

Graxster wrote:OK, I'm stumped on this one. Can you not use a Hotkey on a script that requires an Argument? I wrote a script that has the argument Var Sector Position. Did the usual $x=$pos[0] $y=$pos[1], etc... then wrote a Hotkey setup script to call this script. When I press the Hotkey, it doesn't ask you to choose a Sector and Position, it just warps the ship to current sector, position 0,0,0. Thanks!

-Grax

P.S. When I run the script manually from the editor, it works fine.
no, hotkeys do not run the arguments. In X3, the only way to get those kind of thigns to work is if you added a command and used that via the ships command console.

however, in TC, there are other ways. What you want is the get user input command to do that. Basically it works like the arguments but can be anywhere in your script

Code: Select all

$pos = get user input: type = Var/Sector Position, title="Select position"
just remember to check the return value, if its null, then the user canceled the selection
User avatar
Graxster
Posts: 817
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster »

As I said in the post above yours, I tried that. Added:

Code: Select all

$pos = [THIS] -> get user input, type: Var/Sector Position, title='Select a Position'
Still get no user input option, and I get warped to 0,0,0.

-Grax
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22437
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

where was it added exactly ?

also remember that [THIS] doesn't exist for global scripts. althou it shouldn't make a difference for that command

i know it works because i have just done it.

maybe a hotkey script with exactly that line in, and i get the sector position selection
User avatar
Graxster
Posts: 817
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster »

It was added as the first line of the script. As far as [THIS] not working globally, I had to put something in there. There's only one command available, and you need 2 variables at the beginning of the line. Anyway, I figured out one problem. Once the game gets a script into memory it won't read the script if you change it. Reinit script cache doesn't seem to help. Quitting and restarting the game made it work.

Now the problem is that once I choose a sector and position, nothing happens. :D

Code: Select all

001   $pos = [THIS] -> get user input: type=Var/Sector Position, title='Select a Position'
002   if $pos -> exists
003   |$curSector = [PLAYERSHIP] -> get sector
004   |$x = $pos[0]
005   |$y = $pos[1]
006   |$z = $pos[2]
007   |$sector = $pos[3]
008   |if $curSector == $sector
009   ||[PLAYERSHIP] -> set position: x=$x y=$y z=$z
010   |else
011   ||[PLAYERSHIP] -> put into environment $sector ->
012   |end
013 @ |= wait 2500 ms
014   |[PLAYERSHIP] -> set position: x=$x y=$y z=$z
015   end
016   return null
That works perfectly if I delete the first line and use an Argument Var/Sector Position and run it from inside the script editor.
-G
ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh »

Graxster wrote: Now the problem is that once I choose a sector and position, nothing happens.
I think "if $pos -> exists " is a bit wrong, IIRC it returns if an object in the universe exists, not if something is null or not, for that you can just use "if $pos".
tatakau
Posts: 697
Joined: Sat, 21. Oct 06, 08:09
x3tc

Post by tatakau »

I want to get an array of player-owned ships....

Am I stuck using the command:

$array = get ships owned by <Player> of type <Object Class>

for every single ship class (M1,M2,M3,M4) and then concatenating the arrays, or is there an easier way of doing it? I've searched, and can't find anything easier. ><

~ Tatakau
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22437
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

yeah exist really wouldn't work for what you want.

as tatakau said, its checking if the varible is an actualy object, arrays are not objects so it'll always be false.

the easiest way would be a simple

Code: Select all

 if $pos
the better way would be

Code: Select all

if is datatype [ $pos ] = DATATYPE_ARRAY
EDIT: might as well exactly what the [THIS] is used for. It really depends on what varible type you are using, some of them do require to be run on a certain object, ie, ware of ship, would have to be run on a valid ship.

but most of them dont need to use it. However, some things like Var/Sector and Var/Sector position, will center on the objects sector.

ie, if [THIS] was a ship thats in Getsu Fune, for example, then when it opens up the menu, Getsu Fune will be the highligheted sector.

i would suggest using [PLAYERSHIP]
User avatar
Graxster
Posts: 817
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster »

ThisIsHarsh wrote:I think "if $pos -> exists " is a bit wrong, IIRC it returns if an object in the universe exists, not if something is null or not, for that you can just use "if $pos".
WTH? :lol:

Too many 4AM nights I guess, hehe. Changed it to "if $pos != null" and we're in business! Thanks!

On another note, any idea how to subtract money from the player with a variable? The only command I see is "add money to player". While you can subtract using a negative number, you can only enter either a number or a variable, and no minus sign. Here's what I'm trying to do:

get the amount of energy cells needed for a jump ($needed.eCells)
check cargo for the needed eCells ($actual.eCells)
if $needed.eCells > $actual.eCells
$cost = $needed.eCells * 25

(charging him 25 credits per eCell)
Now how do I subtract minus $cost from player money?

-Grax
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22437
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

simple this one

Code: Select all

$cost = - $cost
add money to player acount $cost
also, you do the same thing to remove wares from ships, as there is only an add command, not remove command
User avatar
Graxster
Posts: 817
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster »

Anyone have any idea how the game makes products vanish? And if it's possible for scripters/modders to use this function?

Example: In both X3R and X3TC I've never purchased a single Nav Satellite (only use advanced sats), yet Satellite Factories continue to produce sats, which are purchased and sold at Trading Stations or wherever, but eventually they vanish. Otherwise most factories that don't produce common consumables (like energy cells or food) would all eventually fill up. Or perhaps a better example is space fuel. Everyone knows space fuel distilleries are huge money makers, but how does the game make NPC's "consume" it?

-Grax
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

afaik they are removed randomly via Hardcode... there is no possibility to use this function, switch it of or to have any influence on it...
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22437
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

its not randomly, its based on the wares relval. But it is hardcoded.

you can make it do yourself easy enough. Just a simple script that removes wares from stations over time
User avatar
Graxster
Posts: 817
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster »

Cycrow wrote:its not randomly, its based on the wares relval. But it is hardcoded.

you can make it do yourself easy enough. Just a simple script that removes wares from stations over time
So if I use the RelVal of Space Fuel my ware will "vanish" over time?

Another question:

I'm calling the script, "move.jumptostation", then I have "while not [THIS] is docked" "@ = wait randomly from 3000 to 5000ms". I need some way to break out of this if for some reason the ship can't dock (station exploded, or some other unforeseen event is preventing docking). Any way to add a timeout or something in that loop? Or should I just add checks for "if $station exists", if docking is allowed, etc. and hope he doesn't get stuck in a loop? Thanks!

-Grax

Edit: Also, I'm having a problem creating factories with a script. I have a script that creates a factory in 2 sectors, the problem is that no matter what I do, it will only create the first factory and not the second. The scripting is identical from the 1st to the 2nd, with only the variable for the factory different (ie: $fac1 = create station Argon Prime, $fac2 = create station Kingdom End). I know the build part works, because if I comment out the entire first fab, the 2nd will get built. Any ideas?

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