Two questions

The place to discuss scripting and game modifications for X²: The Threat.

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

User avatar
spudsman
Posts: 193
Joined: Fri, 30. Jul 04, 22:47
x3tc

Two questions

Post by spudsman »

Hi all,

First, does anyone know if anyone has created a linked-list library for X2? I just created a very simple one and am quite willing to share, but I don't want to submit a duplicate if there's already something more thoroughly proven out there.

Second, can anyone recommend a good file-hosting site? Thanks.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22438
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

just out of interest, y would u bother with linked list ?

the built in arrays already do everything a linked list can do
and it will be faster than creating scripts to do it
User avatar
spudsman
Posts: 193
Joined: Fri, 30. Jul 04, 22:47
x3tc

Post by spudsman »

Are the resize operations for the built-in array optimized (no, seriously, I don't know)?

A linked list allows me to insert a node in the middle of the list. A built-in array requires that I first resize the array to accommodate the elements that I'm adding and then shift each element over from the point where I want to add my new elements.

The only requirement with a linked-list is that I traverse it to the point where I'd like to insert the elements first.

Of course, there's script invocation overhead and some potential threading issues if the same linked list is manipulated by two separate processes.

Plus some tasks lend themselves to stack-solutions (like writing an RPN in X2). But in all seriousness, I have found it useful for my tasks.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22438
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

i think ur thinking of arrays in other languages like C.

in X scripting an array isn't like in C, its basically a linked list, you can remove and insert entries anywhere in the array. As well as append (push_back) and remove (pop_back) entries.

u dont need to resizes the array or even move entries around in the array.

and it is optimized simply coz built in commands are always faster than scripted commands.

coz scripting languages are inheritically slow, but the built in commands are already compiled and run at full speed

Return to “X²: The Threat - Scripts and Modding”