My ship does not follow given target - why?

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

Post Reply
Nicoman35
Posts: 681
Joined: Thu, 17. Nov 05, 13:12
x3tc

My ship does not follow given target - why?

Post by Nicoman35 » Wed, 19. Mar 14, 11:47

I am doing a custom jump move script.
I want a ship to jump to a target object, then nearing it untill a certain range.

I call my script with this:

Code: Select all

$homebase = [PLAYERSHIP]-> get homebase
$return = [PLAYERSHIP]-> call script 'anarkis.lib.jumpmove' : argument1=$homebase
The jump is done ok, but then... my ship is going top speed, maintains that speed flying in some wierd direction, no matter what. And it is not close to the direction the target object is.

I have tried

Code: Select all

$arrived = [THIS]-> follow object $object with precision 10000 m
as well as (in a while loop)

Code: Select all

$arrived = [THIS]-> follow object $object with precision 10000 m : timeout=2000 ms
Question: Why is the ship not following the given target, but flying straigt away somewhere???
(if needed, I can post the whole script)

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

Post by UniTrader » Wed, 19. Mar 14, 12:07

where is your destination object? (coordinates)

where did you add those lines? after the script call? does this Script even exit?
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 ;)

Nicoman35
Posts: 681
Joined: Thu, 17. Nov 05, 13:12
x3tc

Post by Nicoman35 » Wed, 19. Mar 14, 12:15

UniTrader wrote:where is your destination object? (coordinates)

where did you add those lines? after the script call? does this Script even exit?
The "follow object" lines are integrated in the script 'anarkis.lib.jumpmove'
And the script does exist, as some debugging code before and behind the "follow object" lines is executed correctly.

The target object is the playerships homebase (an M2), and the M2 is idling somewhere near the middle of the sector (0,0,0).

User avatar
Jack08
Posts: 2993
Joined: Sun, 25. Dec 05, 10:42
x3tc

Post by Jack08 » Wed, 19. Mar 14, 17:15

Why are you using $object within your script? shouldn't you be using $argument1 as thats the name of the argument you gave in the script call.

You will definitely need to post the whole script if this isnt the problem.
[ external image ]
"One sure mark of a fool is to dismiss anything that falls outside his experience as being impossible."
―Farengar Secret-Fire

zanzal
Posts: 309
Joined: Sat, 15. Sep 12, 07:42
x3tc

Post by zanzal » Wed, 19. Mar 14, 17:32

I didn't think the player ship was supposed to have a homebase...

Nicoman35
Posts: 681
Joined: Thu, 17. Nov 05, 13:12
x3tc

Post by Nicoman35 » Thu, 20. Mar 14, 08:29

Thans for the efforts, gentlemen.
Sorted it out.

Here the explenation:

This call

Code: Select all

$homebase = [PLAYERSHIP]-> get homebase
$return = [PLAYERSHIP]-> call script 'anarkis.lib.jumpmove' : argument1=$homebase 
is inside of a script called by a hotkey. Thus, there is no reference object on which this script is running (null call).
Now - my wrong asumption, when calling a script on an object (in this case the playership) from a global script, the called script would run on task 0 of the object.

WRONG! It is not running on task 0, as far as I can see, it is not running at all on some task on the object, but is somehow also running as a global task. :gruebel:

Conclusion: Never - Never ever call something with a call like this

Code: Select all

= $some.object -> call script 'some.script' :
from a global script.

Use instead:

Code: Select all

$some.object-> begin task 0 with script 'some.script' and priority 0: arg1=null arg2=null arg3=null arg4=null arg5=null
Prevents wierd, puzzling results, which make you ask dumb questions in the forum anoying the others.

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

Post by Cycrow » Fri, 21. Mar 14, 11:35

or this

Code: Select all

START $some.object -> call script: 'some.script;

Post Reply

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