Smart Spiders and Arrays

Post about your finished mods here.
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

0.28 alpha is available to download now.

CHANGES

Added the FreightersAndMore attribute to all devices except the Heliotrope solar panel array

Changed some device descriptions

Changed the location of the settings link in the ship interior dockscreen so that the link now shows up near the bottom of the list instead of at the top

Added scrRefreshScreen to refresh the current dockscreen after a spider or array automatically installs/uninstalls. Fixed a bug where the refresh was causing the itemPicker screen to reset the cursor position to the beginning of the list.

KNOWN ISSUE: When this mod is enabled, the Naginata ship in The Backroads is unusable. When TBR tries to install items onto the ship at the beginning of the game, the game generates errors and keeps the player from exiting the installation dockscreen.
SOLVED. The problem was in TBR code from the file AE-AA09-TBRPlayerships.xml, line 1048 (accessed 2016 March). (enum (objGetItems gSource "*U") aeInstall (shpInstallDevice gSource aeInstall)) tries to install anything in the ship's cargo hold, even if it is not an installable device, generating an error. Fixed this by adding <MiscellaneousDevice/> to the box with the faded label, making the box uninstallable at stations, and making it uninstall itself if a mod happens to install it. A more robust fix would involve changing the TBR code for the Naginata playership.
gunship256 wrote:
Still get the Nil,nil device slot bug in the Misc Devices screen as well. Someone else is having trouble with updating screens. I'll try and find the reference. It might help. EDIT: It's AP in The Backroads with a casino(?) not being cooperative. But he hasn't fixed it yet. Looking at the code in your mods I saw scrRefreshScreen. Possibly if you can get this function in the code after the arrays/spiders uninstall that might help to fix it.
That's a really good idea. I don't know if there's a function I can use to test whether a screen is currently active, and I'm not sure what will happen if I call scrRefreshScreen when no screen is active. I'll have to test this and hopefully incorporate a fix in the next release.
I initially tried fixing the update problem by just refreshing the screen whenever a spider or array installs or uninstalls:

Code: Select all

(scrRefreshScreen gScreen)
That caused the game to throw an error if no dockscreen was active. I fed the code to (isError) to keep that from happening:

Code: Select all

(isError (scrRefreshScreen gScreen))
This worked, but it was causing other annoying dockscreen problems. Before the changes, itemPicker (and the 'U' menu) were dangerous places to be because if a spider installed or uninstalled, the player's cursor position in the itemPicker list would change, but the list wouldn't update. This could result in the player buying, selling, or using the wrong item. I've wasted many a weapon enhancer this way before.

After the changes, the dockscreen would refresh but bring the player all the way back to the top of the list, which was a big annoyance, especially since there was no warning or explanation for it. I (mostly) solved this problem by having the game remember the cursor position before refreshing the screen:

Code: Select all

(isError (setq theCursor (scrGetListCursor gScreen)))
(isError (scrRefreshScreen gScreen))
(isError (scrSetListCursor gScreen theCursor))
There are still a couple of bugs, though they're much smaller and mostly tolerable. The 'U' menu still wouldn't update correctly with this code, but that's hopefully not a problem now that the spiders no longer have any <Invoke> code.

Also, when itemPicker refreshes, the mod remembers the cursor position, but the spider has ALREADY installed/uninstalled by the time I call (scrGetListCursor). This smaller bug no longer results in the player buying/selling the wrong item, but it does move seem to move the cursor around unpredictably. It's more of an annoyance than a problem, since the screen still refreshes and displays the cursor position properly.

I think I can fix this by moving scrGetListCursor to a point before the spider installs/uninstalls. If it works, the fix will be in the next version.

EDIT: Solved! The code below works correctly in preliminary testing, though I haven't released the changes in a new version yet.

Code: Select all

(isError (setq theCursor (scrGetListCursor gScreen)))
                           
(shpInstallDevice gSource theDevice)
                           
; Refresh the dockscreen pane in case moving this device around broke itemPicker
; Used isError in case scrRefreshScreen is called while a dockscreen is not currently pulled up
; Use scrGetListCursor and scrSetListCursor to remember where we were in
; the itemPicker list

(isError (scrRefreshScreen gScreen))
(isError (scrSetListCursor gScreen theCursor))
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

0.29 alpha is available now.

CHANGES

There an issue where the itemPicker cursor position was not being stored correctly, causing the cursor to jump around if a patch spider moved around and refreshed the dockscreen. Fixed this by storing the cursor position BEFORE the patch spider moves, moving the spider, refreshing the screen, and then restoring the cursor position.
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

0.30 alpha is available now.

CHANGES

Spiders and arrays only refresh the dockscreen now if they move around while actually on the playership. This prevents patch spiders on Ranx dreadnoughts from refreshing the playership's dockscreen.
mariareese
Anarchist
Anarchist
Posts: 1
Joined: Sat Jul 22, 2017 6:57 am

I have also a similar issue with 1.7 alpha .. :(
Post Reply