[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

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

Re: Set Product for Complexes

Post by Graxster »

Loki_81 wrote:I intended to sell: E-Cells and Nostrop (and something more after adding a few factories)
but both are intermediate products for the factories in the complex.
Go to your Complexes "adjust station parameters" console and turn "intermediate product trading" to YES.

-Grax
Loki_81
Posts: 19
Joined: Tue, 25. Nov 08, 02:06
x4

Post by Loki_81 »

Thanks for all the replies,

as I checked out the CAG-Script I discovered, that they only start to sell intermediates, if their rank is "Trader" or higher, mine are all "Couriers" or "Suppliers". So I'll just have to wait.

Sorry for the inconvenience and my own dumbness :headbang:

Greetings

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

Post by Graxster »

Guys... how do you add a shipyard and load it with ships of your choosing? Easy enough to create a shipyard I suppose, but you can't add ships that I can see...

-Grax
User avatar
XDrake
Posts: 133
Joined: Wed, 29. Oct 08, 18:48
x3tc

Post by XDrake »

I am some what new to scriting... I was looking for page ids and command ids when I noticed Object Tast.. with ship tasks listed under that heading. What are these and how do they differ for scrits?

Thanks
XDrake
jlehtone
Posts: 22486
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

Each object can have (limited?) number of tasks, ie scripts running on it. For example, when you do start a main command on ship, like "Attack all enemies", that script will run as task "0". Each turret has its own task number, and so do the two Additional Commands.

You can even test whether your script is running as task N. Thus you can act by that condition.

And objects can have more tasks than you can start from menus. For example, Lucike's scripts do start a background task/script that renames the ship. (It is not a one-shot action, since details like level will change over time.)

The most proper way to use background tasks is to iterate through the possible (background) task numbers, check for each whether that number is not in use, and if not, then start your background script as that task. You may want to store the task number into variable so that your main script can find the background task later. Dynamically allocated task number.

And remember, if the script is (infinite) loop, it must be stopped somehow. You cannot stop those tasks from any menu, so your main script has to stop them, or they have to check for stop condition every iteration. For example, the Lucike's "rename" stops if the task 0 is no longer one of Lucike's trade scripts that do use the rename.


Those that actually know how to script, will correct me. ;)
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.
lt_wentoncha
Posts: 495
Joined: Thu, 15. Dec 05, 01:51
x4

Scripts and savegames?

Post by lt_wentoncha »

Hi all,

How do scripts affect saved games? Say I install a script, spend two days building a complex (saving in between), and decide I no longer want the script and uninstall, or there's a newer version out and I update the script. Does that ruin the saved game?

My immediate question involved CAG/CLS...not sure if I want to install both. Thanks.
Loki_81
Posts: 19
Joined: Tue, 25. Nov 08, 02:06
x4

Post by Loki_81 »

It's me again,

I tried to set the experience for my STs to a level where I can start the UT-Command (I hate it to train them) but the "set pilot trade skill"-command doesn't seem to work the way I thought.
I wrote a script which got the trading skill from an UT and set it to my new ST but it still is at level 1.

Help please?
User avatar
Graxster
Posts: 817
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster »

@ lt_wentoncha: Just use the uninstall scripts. It shouldn't be a problem with your save games. Usually it's heavy-duty Mods that tend to break saved games when trying to load the save w/o them.

@ Loki_81: You can just edit setup.plugin.autotrade or one of the other autotrade scripts. In there it says what level experience they need to go from ST's to UT's. Just modify it so you can go to UT at level 1. Just remember to move the original script out of the scripts directory, because your modified script will be an .xml, and the game will use the .pck instead if it's in there.

A question of my own: Anyone know how to get a ship to start a patrol? I've been playing around with the various scripting commands, but can't seem to get the right combination. Or know of a script where someone's done it already? I want to create a race ship, then send it on a patrol. If I create a ship and "start task 0 with script: !ship.job.patrol" (with the parameters set), it appears to work when I create the ship in the sector I'm currently in, but OOS the ship just sits there. Weird.

-Grax
jlehtone
Posts: 22486
Joined: Sat, 23. Apr 05, 21:42
x4

Re: Scripts and savegames?

Post by jlehtone »

lt_wentoncha wrote:How do scripts affect saved games? Say I install a script, spend two days building a complex (saving in between), and decide I no longer want the script and uninstall, or there's a newer version out and I update the script.
When a script runs, its code must be cached in memory. And when you save, that cache-copy must be saved in order to continue (on load-game) exactly from the line where the execution was on the moment of save. So after load you still have that copy in memory, even if there no longer is a script file to load it from.

Where this can break, is when such cached script calls another script, for which there is no file any more (and since that script was not running during save, there is no cached copy). Those calls silently fail, so if the caller script assumes the call to do something, then Houston has a problem.

The scripts that usually remain in memory (forever) are those that execute an infinite loop. "Commands" that will continue to run, rather than doing one operation and then quitting.

The main file of CAG/CLS/EST are such loops. But they do check during every iteration, whether they should stop or restart. If you update those scripts, the main loop notices version change, and restarts itself, ie reloads the latest version from file. If you do their uninstall procedure, they again notice that there is a version change, and what they do restart, immediately quits. No more running script, script cache clears, and future saves have no traces of the uninstalled script.

Note though that the check is once per iteration. The ship may have just passed the check during save and is now on long trade run. Next check will occur after the run, ie perhaps several minutes after you have loaded the game.


Thus, to uninstall safely:
* Either the script is well written and handles uninstall gracefully, but you may have to play some time before it actually happens for every running copy.
* Or you have to make sure that the script to uninstall does not have any running copies, bits, or pieces anywhere before you save and quit to run uninstall.

And then there is the Plugin Manager. I can tell you nothing about the Plugin Manager.
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.
Loki_81
Posts: 19
Joined: Tue, 25. Nov 08, 02:06
x4

Post by Loki_81 »

I found a way to set the experience of my STs/UTs:

Code: Select all

ship->set local variable 'experience' to XXX
Just insert the desired value and enjoy
User avatar
Graxster
Posts: 817
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster »

Also, with removing scripts such as CAG, etc... it's best to give them the STOP command or otherwise interrupt the script. With those scripts in particular you could fire the pilot, stop the script, even get in the ship yourself to make sure nothing is running on it before uninstalling.

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

Post by ThisIsHarsh »

Is there any way to tell (via script) what upgrade a ship needs in order to run a given command? Specifically I'm thinking turret commands.

EDIT: Also, is there a way to tell what command is running on a turret? I can only find a 'get command' script command for ship's main task.
User avatar
Graxster
Posts: 817
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster »

ThisIsHarsh wrote:Is there any way to tell (via script) what upgrade a ship needs in order to run a given command? Specifically I'm thinking turret commands.

EDIT: Also, is there a way to tell what command is running on a turret? I can only find a 'get command' script command for ship's main task.
Not sure at the moment bro, and I don't have time to check right now, but I can maybe point you in a useful direction (hopefully). Open the script editor and change "additional info" to yes (under "reinit script cache/ship debug"). Select a ship with turrets and scroll down and you'll see what scripts are running. If you take a look at that structure (try to look at something like a Xenon J or K that has lots of turrets, or Pirate Brigantine/Carrack), I'm thinking the answer you're looking for may have something to do with "get Task" or whatever commands are available for tasks. You'll see in that debug info lots of "Task # -> turret script". Then maybe you can check what script is associated with which task number?

Hope that helps.

-Grax
kipstafoo
Posts: 86
Joined: Fri, 7. Nov 08, 00:08
x3tc

Post by kipstafoo »

In reading through the other threads, I've seen some minor discussion about SIGNAL_DAMAGED and SIGNAL_ATTACKED, but I must be suffering from some sort of mental condition as I can't get these to fire.

What I want to do is trap these signals when a ship owned by me is shot at. Optimally every time it is hit, but at the minimum I'd like it to work at least once. :P

I've set up the signal map in my 'setup' file. Code below is from Exscriptor:

global secondary signal map: add signal={SIGNAL_DAMAGED 1010} race={Player} class={Ship 2004} script='plugin.kipstafoo.test.dmgd' prio=1 name='kipstafoo.test.dmgd'

I have several messaging calls in the target script but I never get anything. Shouldn't this, in theory, fire that script?

Thanks for any help :)
ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh »

kipstafoo wrote:In reading through the other threads, I've seen some minor discussion about SIGNAL_DAMAGED and SIGNAL_ATTACKED, but I must be suffering from some sort of mental condition as I can't get these to fire.

What I want to do is trap these signals when a ship owned by me is shot at. Optimally every time it is hit, but at the minimum I'd like it to work at least once. :P

I've set up the signal map in my 'setup' file. Code below is from Exscriptor:

global secondary signal map: add signal={SIGNAL_DAMAGED 1010} race={Player} class={Ship 2004} script='plugin.kipstafoo.test.dmgd' prio=1 name='kipstafoo.test.dmgd'

I have several messaging calls in the target script but I never get anything. Shouldn't this, in theory, fire that script?

Thanks for any help :)
SIGNAL_DAMAGED only fires when the ship's shields are down and the ship is taking hull damage.

Secondary signals don't seem to work with SIGNAL_ATTACKED at all.

If you're still having problems, try changing the class from Ship, may be too generic, but unsure.
kipstafoo
Posts: 86
Joined: Fri, 7. Nov 08, 00:08
x3tc

Post by kipstafoo »

ThisIsHarsh wrote: SIGNAL_DAMAGED only fires when the ship's shields are down and the ship is taking hull damage.

Secondary signals don't seem to work with SIGNAL_ATTACKED at all.

If you're still having problems, try changing the class from Ship, may be too generic, but unsure.
Great! Thanks for the help man.

So I'm assuming SIGNAL_ATTACKED is the way to go to track shield-only damage? I'll have to bang on this a bit then.
User avatar
XDrake
Posts: 133
Joined: Wed, 29. Oct 08, 18:48
x3tc

Post by XDrake »

This may sound stupid, I am trying to debug a script and I need to get information about what my variables are doing. So I thought that I would send them to the logbook. So to learn I turned to Cycrow’s lessons, the first one… I know that it is for X3R, I have also seen it work with Graxster’s Find Empty Ship script… I can’t seen to get anything to work with the logbook

This is what I have:

Code: Select all

$display = 'this is a test'
write to player logbook $display
return null
I have tried this in many ways, thinking that the datatype was not right.. placing a direct string in the command, and I have not gotten it to work at all. :evil:

I am hoping you guys can point me in the right direction.
User avatar
Graxster
Posts: 817
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster »

That looks correct. One thing though, are you using the first command in General Commands? The one that looks like <Var/Obj><Variable> (or whatever it is). That's the one you need to use for that. The first one is a variable (obviously), then the second is <String>. Then Logbook Commands, "write to player logbook <Value>". Then r to run the script. Like I said, that looks correct to me, and should work, unless you're writing that from memory and it wasn't the way the script really looked, or you used the wrong command for the first line.

Or, are you looking for an incoming message and forgetting to look in the player logbook? Those are the only things I can think of atm.

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

Post by Cycrow »

the script looks fine, perhaps your just not running it correctly ?

althou personally i prefer to use the write to logbook: sprintf: fmt, command. Not that it should make a difference for that however
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22421
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

kipstafoo wrote:
ThisIsHarsh wrote: SIGNAL_DAMAGED only fires when the ship's shields are down and the ship is taking hull damage.

Secondary signals don't seem to work with SIGNAL_ATTACKED at all.

If you're still having problems, try changing the class from Ship, may be too generic, but unsure.
Great! Thanks for the help man.

So I'm assuming SIGNAL_ATTACKED is the way to go to track shield-only damage? I'll have to bang on this a bit then.
signal attacked is only triggered when the ship gets "Attacked" this is different from being Hit.

you can hit a ship a few times before the attacked signal is triggered. Usually it first gets triggered once you hit it enough for it to turn red against you

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