[Discussion] Generic X3TC S&M questions I

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

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

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

Post by Cycrow » Fri, 16. Oct 09, 11:53

How are you assigning the signal. Is it via the global script map or individually on the ships ?

If its the global map set the class to ts instead of ship as the init script have separate signals for various classes including ts
As ship classes are higher than the global ship class they will take priority

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

Post by s9ilent » Fri, 16. Oct 09, 20:24

It's and individual map to the ship

001 $targ = get player tracking aim
002
003 *START $targ -> call script plugin.sfm.ship.loop :
004 *$targ -> connect ship command/signal COMMAND_ATTACK to script plugin.sfm.signal.attacked with prio 100
005 $targ -> set ship command/signal COMMAND_ACTION to global default behaviour
006 $targ -> add secondary signal: signal=SIGNAL_ATTACKED, script='plugin.sfm.signal.attacked', prio=100, name='tes'
007
008 *$targ -> send signal SIGNAL_ATTACKED : arg1=null, arg2=null, arg3=null, arg4=null
009 *$targ -> interrupt with script plugin.sfm.signal.attacked and prio 100



Essentially I did line 4 and 8, then line 5 6 8 (and I also tried shooting as well, instead of just line 8). Ill play around with it a bit more nowish and see what happens

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

Post by Cycrow » Fri, 16. Oct 09, 23:37

did that paste properly ?
as its showing "COMMAND_ACTION" and "COMMAND_ATTACK" not "SIGNAL_ATTACKED"

also, im not certain but i think the send signal command will only work if u send the correct arguments.

without checking thou, i cant remember which of the arguments are actually required and which can be set to null

Samoorai
Posts: 17
Joined: Sat, 17. Oct 09, 07:51

Post by Samoorai » Sat, 17. Oct 09, 13:38

Can anyone please tell me how to add the atmospheric lifter to the terran shipyards? All I want is to legally buy one (or several) instead of screwing around with useless marines.

KNT79
Posts: 80
Joined: Thu, 10. Sep 09, 19:14

Post by KNT79 » Sat, 17. Oct 09, 19:37

The question about components.txt file. Some ship modding tutorials use this file. After wasting yesterday evening on making cockpit on custom ship model I have no idea what this file stands for.

Making cockpit part in the ship model and exporting this to components.txt results in (0,0,0) cockpit inside the ship. I have managed to make right cockpit only by putting cameradummy into the scene. I looked at Cerberus and this ship too has no entry in components.txt.

So, what is the function of the components.txt? Is it obsolete?
NOT PEACE BUT A SWORD

ladyboy
Posts: 69
Joined: Fri, 14. Sep 07, 19:18

Post by ladyboy » Sat, 17. Oct 09, 22:58

@Samoorai - maybe this would do the job. havn't tested it

Code: Select all

$race = {Terran} 
$ship = {Terran Atmospheric Lifter} 
$psec = [PLAYERSHIP]->get sector
$i = 0 
while $i < 40 
  $dock = find station in galaxy: startsector=$psec class or type={Shipyard 2037} race=$race flags=[Find.Random] refobj=null serial=null max.jumps=100
  if $dock->exists
    $dock->add product to factory or dock: $ship
    $c = $dock->get amount of ware $ship in cargo bay
    skip if $c > 0 
      = $dock->add 1 units of $ship
  end
  inc $i =
end
 
I have a question. I have a ship and i want to get an array of all the ships docked with it.. is there an easy way?
All those moments will be lost.. in time, like tears.. in rain.
[ external image ]

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

Post by s9ilent » Sat, 17. Oct 09, 23:44

@ladyboy


077 |$ship.list = = [THIS] -> get ship array from sector/ship/station
It's under universal and sector commands

(Where this is the station/carrier (or sector))

ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh » Mon, 19. Oct 09, 04:48

Any chance of a short overview of the new 2.5 menu commands?

Inparticular:
- add section to custom menu:
- create text for custom menu, left= right=
- add value selection to menu:

[This is both cool and annoying.... I've spent days of man-hours trying to write a general purpose reusable menu system, and now I suspect some of the routines I wrote are already deprecated!]
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.

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

Post by s9ilent » Mon, 19. Oct 09, 09:48

Just on that general purpose reusable menu system, I considered doing something like this before, but I found it mostly useless.

As the only "common" element was the general structure:

$page.id = ###
$heading = xxx
top:
*building menu happens here
send menu
handle returns (either do stuff, or loop back to the top:)

The one few exceptions to this where generic input handlers (e.g. input number, input string- but these are separate scripts).
The only code which I've extensively re-used would be my tree-view generating code. link to picture
Some other common elements that I used was a:
Back (Esc) return -1
Exit return -2


Although, I think it would be very useful for a generic tfile to be available for common menu items. e.g. All the colours, %s x1-5, the formats and other tags, as well as common phrases such as Back, Exit, Back (Esc), Exit (Esc). As well as some other generic string manipulating scripts e.g. I have a comma delimiter, and a R/Y/G -ve/0/+ve comma delimiter + Cr suffix-ator. A percentage-er would also be nice (although I find that I almost always either get 0%'s or HUGE overflows... so I haven't been able to use one yet)






As for the new commands, I haven't used them yet although I would "guess" (mostly baseless guessing, some of it educated guessing)

Add section might allow for arrays of text, to create columned menus
Create text for custom menu left = right = would presumably allow for a left justified and right justified section of text, although the lack of ret var, might sugest that this is a NON selectable item
Add value selection, probably creates a selection with selectable options

e.g.
add selection to menu: $mymenu
text = " Auto Jump drive Usage"
Value Array= {"Yes", "No", "Emergency Only"}
default value = 1
returnid = "ajumpvar"

Code: Select all

Jump drive                            << No >>
Who's return would presumably be {"ajumpvar", 0/1/2}

But once again, just a guess (It might actually return the raw values, so it might return Yes, No, Emergency Only, similarly, it might return the pointers to the things (e.g. if you put a ship in there, it might point to the ship) or it might just return the string of what ever was in there (so it would just return the ship name)

Once again, all guesses. (So I could be completely wrong, trial and error is usually the best way to go) (Note, this last one is a HUGE guess, but its something I idea'ed in the devnet, and I can't think of how else such a command could be used)




*edit*
I also ask you all please update the Xai corp msci as you go, its super useful but sometimes I think I'm the only one on there :S
link

ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh » Mon, 19. Oct 09, 10:16

@s9ilent: Yeah I checked out the MSCI on Xai Corp first, but the enw menu commands are not listed yet. Your assumptions seem pretty logical, I will have to invest some (more!) time to trying them out.

As for reusable menu systems, I have a secret weapon in that fight. I wrote a JSON parser (if you don't know, JSON is basically a lightweight alternative to XML) in MSCI. The beauty is that you can embed JSON object definitions within your t-files. I'm finding it really useful. It's not as fast (CPU-wise) as using a bunch of locals/globals directly, but perfect for writing a menu system. I'll be releasing it shortly. I've done all the code and thoroughly tested (i.e. by building a monolithic general purpose menu system). The problem is I need to find a few hours to sit down and document the functions.
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.

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

Post by Cycrow » Mon, 19. Oct 09, 19:06

for the new menu commands, u can look here

http://forum.egosoft.com/viewtopic.php?t=261816

also my cheat scripts uses some of the new commands, or the 2.5 boarding command script also makes use of the new column.

the only one thats not really mentioned is the add section, this simply adds a gap between the selections

ladyboy
Posts: 69
Joined: Fri, 14. Sep 07, 19:18

Post by ladyboy » Tue, 20. Oct 09, 19:56

I'm having trouble finding script commands for turrets.
i seen "->get number of turrets" in another script but i can't find it or any others in Exscriptor.. where are they? if they exist

is there anyway to search through all the script commands for a keyword?
All those moments will be lost.. in time, like tears.. in rain.
[ external image ]

ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh » Tue, 20. Oct 09, 23:19

ladyboy wrote:I'm having trouble finding script commands for turrets.
i seen "->get number of turrets" in another script but i can't find it or any others in Exscriptor.. where are they? if they exist

is there anyway to search through all the script commands for a keyword?
You want General Object Commands->Weapon Information for most of what you're after. Then, when you want to change the laser in a turret, you (obviously!) have to look in the Trade->Ship commands ('switch laser in turret <num> gun <num> to <ware>').
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.

Hauger
Posts: 16
Joined: Sun, 5. Mar 06, 06:44
x3tc

Post by Hauger » Wed, 21. Oct 09, 06:40

So I've kinda taken on writing my first script. My idea is to be able to blacklist sectors that I don't wish for any of my ships including the one I'm in to fly in or through. If I can figure out how, even wipe out looking in the sector for best buys and sells. So anyway I've looked at peoples mods and saw how they handled ship routing. It seems that most either use their own custom mapping, or they use the built in path determination which is used like

Code: Select all

$sector.move = get next sector on route from sector $sector.move to sector [SECTOR]
The only way I would be able to tell a ship not to use a sector would be to give it a custom command. However, if I have a universe trader running the universe trader command, they will not use this custom script to avoid the blacklist sector.

In a nutshell the question is this. Is it possible to reroute the "get next sector on route from sector" calls to my custom script, or to force that command to not use certain sectors? My apologies if I placed this in the wrong area. I couldn't find it posted anywhere.

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

Post by s9ilent » Wed, 21. Oct 09, 10:47

@ Hauger
To answer your question, No.

But lots of scripts reference the !move.movetoxxxxx scripts, so you can replace those ones via false patching (or by physically replacing but that is not suggested) your one on top of the existing ones.

Hauger
Posts: 16
Joined: Sun, 5. Mar 06, 06:44
x3tc

Post by Hauger » Thu, 22. Oct 09, 04:07

Thanks for the reply s9ilent, I'm assuming I shouldn't be releasing any public scripts using this method since it is not suggested?

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

Post by s9ilent » Thu, 22. Oct 09, 22:44

False patching can do it safely (as it doesn't physical replace them).

jlehtone
Posts: 21881
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone » Thu, 22. Oct 09, 23:10

s9ilent wrote:False patching can do it safely (as it doesn't physical replace them).
:? Stock scripts are in the 'scripts' folder rather than in cat/dat. "False patching" adds cat/dat packages, but how could that help in the 'scripts' folder?

ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh » Fri, 23. Oct 09, 05:45

You can replace stock scripts using the plugin manager. Make sure you have the script packed as .pck like the stock one. Put it in a spk package. Then, when you install, it will overwrite the stock one with yours, but also save a backup of the original (AFAIK, I hope anyway! because I rely on that for some of my scripts). Then when you uninstall your package it will restore the original version. I'm certain this ability was in X3R plugin manager, I never actually checked the X3TC one!
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.

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

Post by s9ilent » Sat, 24. Oct 09, 00:21

Hmm... interesting...
I had always thought that you could use scripts in a cat/dat (in a \scripts sub folder) hmm.... :S

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