A peculiar scripting problem. Any guesses?

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

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

runner1891
Posts: 2
Joined: Sun, 7. Dec 03, 07:44
x3

A peculiar scripting problem. Any guesses?

Post by runner1891 »

First off, I'm new here, and I apologize for asking for help without posting much of anything else, but this problem is driving me crazy.

Here's the situation. I'm scripting up a mod that will allow a player to "order" any items he wishes and have them delivered to a ship of his choosing. In order to even "deliver" the items, a check must be made to ensure that the ship will be able to carry the items ordered. The check goes as follows (in pseudocode):

test = can ship carry item class? (an M5 can't carry a Gamma PPC)
totalvolume = get volume of item * quantity (a TS can't carry 10,000 units of anything)
if test == null
write to logbook "ware is too big"
else if totalvolume > ship->freevolume
write to logbook "not enough free space"
else
(code for adding items here)


Here's my problem. Sometimes the script works and sometimes it doesn't. Most of the time, the wierdest thing happens. I will get a "not enough free space" error and will suddenly have 9 Gamma PPC's, 6 Beta PPC's, and 3 Alpha PPC's added to my ship! Most of the time, I try to order energy cells so I don't have to get out of my ship to dock at a SPP. Free weapons are great, but I have no idea where they're coming from.

I've traced through the code and the comparer runs and then skips down to the final return statement. Can anyone think of a reason why these specific items are instantly added to my inventory almost every time? An additional brain-teaser is that I am creating a ship off in space to simulate delivery time. Only when the ship reaches the selected receiver is ANY add item command called. To put it short, a bunch of PPC cannons are thrown into my ship (if they can fit) and I don't even call an "add item to ship" command at all. Any ideas? Maybe my savegames are corrupted or something. Perhaps it's the 1.2 patch. I am stumped. All that work for nothing is really angering.
xSiNx
Posts: 114
Joined: Wed, 3. Dec 03, 18:37
x3

Re: A peculiar scripting problem. Any guesses?

Post by xSiNx »

runner1891 wrote:First off, I'm new here, and I apologize for asking for help without posting much of anything else, but this problem is driving me crazy.

Here's the situation. I'm scripting up a mod that will allow a player to "order" any items he wishes and have them delivered to a ship of his choosing. In order to even "deliver" the items, a check must be made to ensure that the ship will be able to carry the items ordered. The check goes as follows (in pseudocode):

test = can ship carry item class? (an M5 can't carry a Gamma PPC)
totalvolume = get volume of item * quantity (a TS can't carry 10,000 units of anything)
if test == null
write to logbook "ware is too big"
else if totalvolume > ship->freevolume
write to logbook "not enough free space"
else
(code for adding items here)


Here's my problem. Sometimes the script works and sometimes it doesn't. Most of the time, the wierdest thing happens. I will get a "not enough free space" error and will suddenly have 9 Gamma PPC's, 6 Beta PPC's, and 3 Alpha PPC's added to my ship! Most of the time, I try to order energy cells so I don't have to get out of my ship to dock at a SPP. Free weapons are great, but I have no idea where they're coming from.

I've traced through the code and the comparer runs and then skips down to the final return statement. Can anyone think of a reason why these specific items are instantly added to my inventory almost every time? An additional brain-teaser is that I am creating a ship off in space to simulate delivery time. Only when the ship reaches the selected receiver is ANY add item command called. To put it short, a bunch of PPC cannons are thrown into my ship (if they can fit) and I don't even call an "add item to ship" command at all. Any ideas? Maybe my savegames are corrupted or something. Perhaps it's the 1.2 patch. I am stumped. All that work for nothing is really angering.
Eh... This is weird... I've written such a script and I don't have this problem.

Alex.
Firedancer
Posts: 632
Joined: Wed, 13. Aug 03, 15:45
x3

Re: A peculiar scripting problem. Any guesses?

Post by Firedancer »

xSiNx wrote:
runner1891 wrote:First off, I'm new here, and I apologize for asking for help without posting much of anything else, but this problem is driving me crazy.

Here's the situation. I'm scripting up a mod that will allow a player to "order" any items he wishes and have them delivered to a ship of his choosing. In order to even "deliver" the items, a check must be made to ensure that the ship will be able to carry the items ordered. The check goes as follows (in pseudocode):

test = can ship carry item class? (an M5 can't carry a Gamma PPC)
totalvolume = get volume of item * quantity (a TS can't carry 10,000 units of anything)
if test == null
write to logbook "ware is too big"
else if totalvolume > ship->freevolume
write to logbook "not enough free space"
else
(code for adding items here)


Here's my problem. Sometimes the script works and sometimes it doesn't. Most of the time, the wierdest thing happens. I will get a "not enough free space" error and will suddenly have 9 Gamma PPC's, 6 Beta PPC's, and 3 Alpha PPC's added to my ship! Most of the time, I try to order energy cells so I don't have to get out of my ship to dock at a SPP. Free weapons are great, but I have no idea where they're coming from.

I've traced through the code and the comparer runs and then skips down to the final return statement. Can anyone think of a reason why these specific items are instantly added to my inventory almost every time? An additional brain-teaser is that I am creating a ship off in space to simulate delivery time. Only when the ship reaches the selected receiver is ANY add item command called. To put it short, a bunch of PPC cannons are thrown into my ship (if they can fit) and I don't even call an "add item to ship" command at all. Any ideas? Maybe my savegames are corrupted or something. Perhaps it's the 1.2 patch. I am stumped. All that work for nothing is really angering.
Eh... This is weird... I've written such a script and I don't have this problem.

Alex.
Worked fine for me too... maybe you check volume space only but not volume size? also a ship being able to transport a weapon type doesn't mean it can actually use it... I'd dcheck my script
User avatar
moggy2
Posts: 5505
Joined: Wed, 6. Nov 02, 20:31
x3ap

Post by moggy2 »

how aout just using the can transport ware command?
GnatB
Posts: 1225
Joined: Thu, 27. Feb 03, 20:44
x4

Post by GnatB »

Well, one issue I can think of is that FALSE may not equal NULL. Most languages that's true, but not all. If you mean FALSE, you should probably use FALSE.... don't see why that would randomly create said weapons on your ship withour you even ordering them though.

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