EnglishGermanFrenchRussianItalianSpanish
Log inRegister
 
many script instances slow down SETA (spaceflies, Anarkis/Pirate Guild)
Post new topic Reply to topic Goto page Previous  1, 2
View previous topic :: View next topic
Author Message
Aldebaran_Prime



MEDALMEDALMEDAL

Joined: 20 Feb 2010
Posts: 999 on topic
Location: Düsseldorf, Altbiersektor
Thank you for registering your game
PostPosted: Fri, 8. Jun 18, 00:33    Post subject: Reply with quote Print

|K.O.S.H. wrote:
Yes, I stopped all global scripts.

I have an eye on the instances, the number does not increse anymore.
I patched the two (spacefly) scripts, so that i can kill any new instances, but he old ones remain :/

If there was a way to restart running scripts with a newer version, my problem would be solved.

Or a command to get all objects, that run a certain script.


please, may you publish the code here? I would include this into my mod to prevent new players to run into this problem


_________________
Back to top
View user's profile Send private message
Aldebaran_Prime



MEDALMEDALMEDAL

Joined: 20 Feb 2010
Posts: 999 on topic
Location: Düsseldorf, Altbiersektor
Thank you for registering your game
PostPosted: Tue, 12. Jun 18, 22:37    Post subject: Reply with quote Print

Hi all, because nobody posted here an answer, maybe somebody can check if the following approach works as I thought and it seems to.

The idea is, not to restart the spacefly script, if the version changes, but to destroy the whole spacefly if the version of its script changes.
This is possible without too many disadvantages for the player, because spaceflys are destroyed and re-created normally, if the player changes a sector. So latest after an update and one sector change the typical amout of spaceflys are back in sector.

I put the following code at the top of the !ship.cmd.idle.spacefly-script:
Code:

* set local variable to current script version
$CurrentSpaceflyVersion = get script version
* get last saved script version from global variable and save in local variable
$LastSpaceflyVersion = get global variable: name= 'idle.spacefly.version'
* set golbal variable to current version
set global variable: name='idle.spacefly.version' value =$CurrentSpaceflyVersion

*now compare current version with version of global variable
if not $LastSpaceflyVersion ==$CurrentSpaceflyVersion
 write to player logbook 'Debug: ship.cmd.idle.spacefly: different Script versions- I will kill myself'
* destroys the object where the sript is runnung on... only the next instance of a spacefly will survive
[THIS] -> destroy object: killer=null, show no explosion=0
return null
end
...


If the script version is not identically with the last saved version of this script, all spaceflys should kill themselfs, including their script instances

The same method may be used to examine an other global variable which can be manually set to "TRUE" to kill all running instances of spaceflys in the universe


Code:
...
*now examine global kill-variable
$KillSpaceFly = get global variable: name= 'KillSpaceFly'

if  $KillSpaceFly == [TRUE]
 write to player logbook 'Debug: ship.cmd.idle.spacefly:  KillSpaceFly == TRUE - I will kill myself'
* destroys the object where the sript is runnung on... as long  als KillSpaceFly ist true, no spacefly will survive
[THIS] -> destroy object: killer=null, show no explosion=0
return null
end
...



If we put this code in the spacefly-scripts we are prepared for future inflation of spaceflys.

what dou you think? Are there better approaches out there in x-universe?


_________________
Back to top
View user's profile Send private message
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)



Joined: 15 Nov 2004
Posts: 20505 on topic
Location: London
Thank you for registering your game
PostPosted: Wed, 13. Jun 18, 10:32    Post subject: Reply with quote Print

Theres actually a proper command to check for new versions, which would be better to use, as you wont need to use global variables

something like, if is new version of script available.

as the problem seems to be that spaceflys are in the null sector, you could simply put a check in for the current sector, if its null, then you could just destruct them as well.

one other thing, remember the followers as well, as spaceflies are in swarms


_________________
My Scripts | MY X3TC Scripts | X3 Plugin Manager | Custom Gui
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
SirNukes





Joined: 31 Mar 2007
Posts: 119 on topic

Thank you for registering your game
PostPosted: Wed, 13. Jun 18, 19:03    Post subject: Reply with quote Print

Killing the script on version change doesn't seem like it would have any advantage over rebooting the script on version change, unless you want to use a version change as an explicit hack to end all running copies. It would be cleaner to do a proper reboot and then just adding other tweaks to the new script to end it under some conditions.

One idea to prevent immortal spaceflies would be to add a lifetime to the spacefly script: after 2 hours (or whatever), the script can kill the spacefly off and end. Followers that then swap to the leader script would kick off a new timer and eventually die as well.

Though one worry is that the spaceflies might be unkillable. A couple of times in game I have run across immortal ships that could not be killed by any method I tried, including direct script commands or docking them and then killing their dock. The '!ship.cmd.idle.spacefly' script should probably be given its own timeout, since such spaceflies only swap to the leader script if the leader stops existing.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic Reply to topic Goto page Previous  1, 2
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Control Panel
Login Data
The time now is Mon, 18. Jun 18, 03:55

All times are GMT + 2 Hours

[ Disclaimer / Impressum ] | [ Privacy Policy / Datenschutz ]

Board Security

Copyright © EGOSOFT 1989-2018
Powered by phpBB © 2001, 2005 phpBB Group
Template created by Avatar & BurnIt!
Debug: page generation = 0.07256 seconds, sql queries = 18