[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

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

Post by Cycrow » Fri, 31. Jul 09, 22:01

i dont know the exact formula used, but i do know that its based soley on the relval of the product.

the number of products and resources needed are based on the relval of the resources that are added.

each resource type has a coefficent, ie tech wares relval is used differently to a mineral ware, etc

so slight changes to relval in the resources can considerably alter the number of products per cycle

Virenex
Posts: 2
Joined: Sun, 2. Aug 09, 18:09

Post by Virenex » Sun, 2. Aug 09, 21:06

hi i just downloaded the scrip to create derelict ships. i installed it fine and it shows up in my script editor in-game but i cannot execute the file. this is my first time trying to use a script and i would like some help in doing so. thxx

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

Post by s9ilent » Mon, 3. Aug 09, 10:13

Q:

$flyware = create flying ware: maintype=$main subtype=$sub count=$ware.amt sector=[SECTOR] x=$x y=$y z=$z selfdestruct=0

What does the selfdestruct argument do?

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Mon, 3. Aug 09, 11:50

That's the lifetime I'd say.
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.

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

Post by Cycrow » Mon, 3. Aug 09, 17:24

Gazz wrote:That's the lifetime I'd say.
not quite, its actually just a switch.

0 being disabled, then any other number will activate the self destruct timer.

this will destroy the object after a random time, which is between 15 and 45 minutes

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

Post by s9ilent » Tue, 4. Aug 09, 00:27

Ahh cool thanks, ok and now for another question

[Find.Expand]
What does it do? it seems to be used in the find.gate commands, but I'm unsure of what it does... I'm trying to use the find.gate to do a quick -is this sector jumpable (find.jumpable) but the stock scripts use this flag too, so I thought I would as well.. but its giving false positives.

Does find.expand|find.jumpable do something like... does this gate eventually link to a gate that fulfils the other criteria?

The exact flags I'm using are:
017 $flags = [Find.Nearest] | [Find.Expand] | [Find.JumpableGate]
018 skip if not [OWNER] == Player
019 |$flags = $flags | [Find.Known]

*edit* I've since taken out find.nearest (as I didn't actually need it..). Also the false positives could be caused by multiple reasons, but this one seemed like the most likely

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

Post by Cycrow » Tue, 4. Aug 09, 03:59

the find gate command will search for gates in the current sector, as its a sector search routine.

the expand flags expands this search into the universe, this only works along side Find.Nearest.

basically, if you just use find.nearest, u get the nearest gate in the sector if there is one.

if you use it, it will expand out sector by sector until it finds the nearest viable gate to you

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

Post by s9ilent » Wed, 5. Aug 09, 04:18

Q: When a ship is killed, is it still running its original task 0 task?

e.g. I want to replace the signal signal.killed, but I want it to only run on ships running my scripts. So is using the following statement valid? Or does the task 0 get stopped prior to signal.killed being run?

Code: Select all

if [THIS] is script 'myscript' on stack of scripts on task 0
   do stuff stuff
else
   call script !ship.signal.killed (the stock ego soft one)
end
return null

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

Post by ThisIsHarsh » Wed, 5. Aug 09, 04:31

s9ilent wrote:Q: When a ship is killed, is it still running its original task 0 task?

e.g. I want to replace the signal signal.killed, but I want it to only run on ships running my scripts. So is using the following statement valid? Or does the task 0 get stopped prior to signal.killed being run?

Code: Select all

if [THIS] is script 'myscript' on stack of scripts on task 0
   do stuff stuff
else
   call script !ship.signal.killed (the stock ego soft one)
end
return null
Two ideal ways.

You could set the signal individually for each ship. E.g. at the top of 'myscript'' connect the signal via "[THIS]->connect ship command/signal", or preferably "[THIS]->add secondary signal".

Second way is to make it global, but have myscript set a local variable on the ship to flag it should use the alternative signal, e.g.

Code: Select all

if [THIS]->get local variable: name='mysigkilled.enabled'
   do stuff stuff
else
   call script !ship.signal.killed (the stock ego soft one)
end
Again, use of a secondary signal is preferred, then the stock script will still be run after yours.

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

Post by s9ilent » Wed, 5. Aug 09, 04:53

I'm hoping to specifically overwrite the stock script, as I want to replace the on death message. (I want to do lots of other stuff, but they could easily be done on a sec signal)

The use of a global variable is not recommended either, as it will not pick up the issue that the script may not be running (as it could've been terminated)

Q: Which once again leads to the original question, is the ships original task 0 still running, when the signal.killed is fired?




Also, on a similar note
Q: The signal.killed arguments, what do they do?
killer, the killer, obvious
cmd, the command, obvious
cmd targ1, the command target, obvious
cmd targ 2, the cmd target 2, obvious
cmd par1 ????
cmd par2 ????

Given that the signal uses this line:

Code: Select all

  START $newleader->command $cmd : arg1=$cmdtarget, arg2=$cmdtarget2, arg3=$cmdpar1, arg4=$cmdpar2
I can only assume.. they are command arguments... but on the other hand, par ~ partner?




Another question...
Q: ... Where/ how to I over write the stock logbook message on ship death.. I thought it was in the signal.killed.. but its not

aka1nas
Posts: 1414
Joined: Thu, 7. Jul 05, 05:17
x4

Post by aka1nas » Wed, 5. Aug 09, 08:47

Is it possible for UI/HUD mods to change the size of the menus? They get pretty small on larger resolutions like 1920x1200 and having lists scale downwards vertically more would mean a lot less clicking around.

If so, where would I need to look at to get at these properties?

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

Post by Cycrow » Wed, 5. Aug 09, 16:22

s9ilent wrote:I'm hoping to specifically overwrite the stock script, as I want to replace the on death message. (I want to do lots of other stuff, but they could easily be done on a sec signal)

The use of a global variable is not recommended either, as it will not pick up the issue that the script may not be running (as it could've been terminated)

Q: Which once again leads to the original question, is the ships original task 0 still running, when the signal.killed is fired?
no its not still running, as the signal script also runs on task 0, so it'll overright it
s9ilent wrote:Also, on a similar note
Q: The signal.killed arguments, what do they do?
killer, the killer, obvious
cmd, the command, obvious
cmd targ1, the command target, obvious
cmd targ 2, the cmd target 2, obvious
cmd par1 ????
cmd par2 ????

Given that the signal uses this line:

Code: Select all

  START $newleader->command $cmd : arg1=$cmdtarget, arg2=$cmdtarget2, arg3=$cmdpar1, arg4=$cmdpar2
I can only assume.. they are command arguments... but on the other hand, par ~ partner?
those 4 are just the arguments of the command.
targ1 and targ2 is usually defined as the 2 targets, par1 and par2 stand for parameter 1 and 2.

its just additional arguments for your command
s9ilent wrote:Another question...
Q: ... Where/ how to I over write the stock logbook message on ship death.. I thought it was in the signal.killed.. but its not
this is hardcoded when the ship is killed, so you cant remove it, only add your own on top

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Wed, 5. Aug 09, 16:30

Cycrow wrote:this is hardcoded when the ship is killed, so you cant remove it, only add your own on top
If the secondary signal fires first and your secondary signal includes

set owner race: neutral race,

the hardcoded signal should not write a log message because it isn't your ship any more? =)
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.

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

Post by s9ilent » Thu, 6. Aug 09, 04:19

Hmmm... this comes as a mixed blessing :):(:S<3</3

@ Gazz, Thanks for the tip :)

@ Cycrow. But I thought that signals where interrupts, so shouldn't the higher priority signal.killed script just be on the top of the stack, but the main script still there (just not being run at the time due to its 0 priority)?
:S



I don't suppose someone could explain to me how priorities work?


*Edit* Just to clarify what I said earlier, when I said ".. is it still running.." I mean to say, is it still on the stack of scripts on task 0

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Thu, 6. Aug 09, 14:38

They are interrupt scripts. Cycrow was just being very literal because the former task 0 script isn't "running" while interrupted. =)

Priorities only rule who can interrupt who.

A Pri 99 interrupt cannot interrupt a Pri 150 script. It merely bounces.
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.

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

Post by Cycrow » Thu, 6. Aug 09, 20:40

actually not all signals are interupts


when a ship is killed, the task on that ship is stoped as part of this process.

this usually happens before the signal scripts are fired. So the signal script will not interupt anything.

there are a few other interupts that are also not interupts, but these run on seperate tasks as to not interfere with the current script command

badboy_COD
Posts: 12
Joined: Thu, 30. Jul 09, 10:30
x3tc

Take out ships that keep apearing every 10 min

Post by badboy_COD » Fri, 7. Aug 09, 00:08

How can u take out ships that keep apearing every 10 min? Does anyone know how this can be done?

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

Re: Take out ships that keep apearing every 10 min

Post by jlehtone » Fri, 7. Aug 09, 00:19

badboy_COD wrote:How can u take out ships that keep apearing every 10 min?
What ships?

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

Post by s9ilent » Fri, 7. Aug 09, 00:36

Thanks for the replies, but I've got more questions (Again :P). On a similar but different note, I've tried to create secondary signals for buying and selling wares.
Q: Why aren't my secondary buy/sell signals working?


*** resolved ***
I set the priority to > 0 and it works, (Specifically I set it to.. 10 so its the same as signal.docked)


This is the main command: plugin.sfm.ship.loop
001 [THIS] -> set command: COMMAND_TYPE_TRADE_42
002
003
004 [THIS] -> connect ship command/signal SIGNAL_ATTACKED to script 'plugin.sfm.signal.attacked' with prio 100
005
006 [THIS] -> add secondary signal: signal=SIGNAL_BUYWARE, script='plugin.sfm.signal.buyware', prio=0, name='sfm.buyware'
007 [THIS] -> add secondary signal: signal=SIGNAL_SELWARE, script='plugin.sfm.signal.selware', prio=0, name='sfm.selware'
008 [THIS] -> add secondary signal: signal=SIGNAL_DOCKED, script='plugin.sfm.signal.docked', prio=0, name='sfm.docked'
...


But neither the buy nor sell signals is firing.
(The attacked and docked signal work fine thou)

Here is the actual buy signal: plugin.sfm.signal.buyware
-The restore command removes the signals and does clean up
-I tried putting in log book prints on top of the restore, and on line 1, but I saw no messages (and this was after I restarted the command)

001 $scr.var.data = 'plugin.sfm.data'
002
003 $scr.var.sta = 'plugin.sfm.stat'
004
005
006
007
008 if not [THIS] -> is script 'plugin.sfm.ship.loop' on stack of task=0
009 |@ = [THIS] -> call script 'plugin.sfm.signal.restore' :
010 |return null
011 end
012
013 $com.av = 5
014 $com.pr = 25
015
016 if [HOMEBASE] -> exists
017 |$global = get global variable: name=$scr.var.sta
018 |if $global[2]
019 ||$hb.data = [HOMEBASE] -> get local variable: name=$scr.var.data
020 ||if not $hb.data
021 |||$hb.data = = array alloc: size=5
022 |||$hb.data[0] = 0
023 |||$hb.data[1] = 0
024 |||$hb.data[2] = 0
025 |||$hb.data[3] = 0
026 |||$time = = playing time
027 |||$hb.data[4] = $time
028 |||[HOMEBASE] -> set local variable: name=$scr.var.data value=$hb.data
029 ||end
030 ||$earnt = $hb.data[0]
031 ||$hb.com = $hb.data[2]
032 ||$earnt = $earnt + $amt * $price
033 ||$hb.data[0] = $earnt
034 |end
035 end
036
037
038 $avprice = = get average price of ware $ware
039 $com = $avprice * $amt * $com.av / 1000
040
041
042 if $hb.data
043 |$hb.com = $hb.com + $com
044 |$hb.data[2] = $hb.com
045 end
046
047
048 if $price < $avprice
049 |$price = $avprice - $price
050 |$com.pr = $price * $amt * $com.pr / 1000
051 |
052 |
053 |if $hb.data
054 ||$hb.com.pr = $hb.data[3]
055 ||$hb.com.pr = $hb.com.pr + $com.pr
056 ||$hb.data[3] = $hb.com.pr
057 |end
058 |
059 |$com = $com + $com.pr
060 |
061 end
062 $task = = [THIS] -> get next available task: starting=100
063 [THIS] -> start task $task with script 'plugin.sfm.ship.transact.com' and prio 0: arg1=$com arg2=null arg3=null arg4=null arg5=null
064
065
066
067
068
069 return null
Last edited by s9ilent on Sun, 9. Aug 09, 05:07, edited 1 time in total.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Fri, 7. Aug 09, 19:51

I'm trying to get any kind of reaction out of Send SIGNAL_DOCKED but so far, without success.

I attach SIGNAL_DOCKED to the ship in any way I could find:

Code: Select all

001   $Target =  get player tracking aim
002   
003   $Target -> add secondary signal: signal=SIGNAL_DOCKED, script='a...a.SIGNAL.DOCK.SCR', prio=4800, name='SIG.DOCK'
004   
005   global secondary signal map: add signal=SIGNAL_DOCKED race=Player class=Ship script='a...a.SIGNAL.DOCK.SCR' prio=4900 name='SIG.DOCK.2'
006   
007   global script map: set: key=SIGNAL_DOCKED, class=Ship, race=Player, script='a...a.SIGNAL.DOCK.SCR', prio=5000
The priority of the default signal is 10 so this should always go through.

'a...a.SIGNAL.DOCK.SCR' is just a test script that writes all arguments to a log file.


So then I send the signal...

Code: Select all

001   $Target =  get player tracking aim
002   
003 @ = wait 5000 ms
004 @ = wait 5000 ms
005 @ = wait 5000 ms
006   
007   write to log file #312  append=[TRUE]  printf: fmt='Sending signal docked.'
008   
009   $Target -> send signal SIGNAL_DOCKED : arg1='Test.Arg.1', arg2='Test.Arg.2', arg3=null, arg4=null
The wait is only there so I can test sending the signal delayed, while the ship is docked.


The ship is running a priority 0 script on task 0.
When I send the signal, nothing happens.
I tried sending the signal from the outside (global script), from a high task ID on the object, and from task 0 on the object.
No go. No signal.

The log file shows "Send signal docked" but the actual signal script is never started.

So far the only way to get the signal to fire is when the ship has slowly meandered through the docking approach.
But that can not be the point of Send Signal so I must be missing something...
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.

Locked

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