Let mining drones collect the right things
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
Let mining drones collect the right things
Hi,
got another interesting (maybe) bug. If you activate drones they are collecting every minerals, although in the UI only one is selected. (on player ships)
After debugging the script "mining.collect.drone" it seems, that it becomes as parameter always a target, but never a ware. Ware is null.
I couldn't find any references, who is executing it except fe "mining.collect.ship.capital", but this script seems to never be called.
How to find who is starting the mining.collect.drone script to see how the parameter are set?
got another interesting (maybe) bug. If you activate drones they are collecting every minerals, although in the UI only one is selected. (on player ships)
After debugging the script "mining.collect.drone" it seems, that it becomes as parameter always a target, but never a ware. Ware is null.
I couldn't find any references, who is executing it except fe "mining.collect.ship.capital", but this script seems to never be called.
How to find who is starting the mining.collect.drone script to see how the parameter are set?
Re: Let mining drones collect the right things
fight.attack.object.capital which is the general turret/drone control script for capital ships. what exactly is the problem?
Re: Let mining drones collect the right things
Thank you for the hint! I think i know now what is the problem
The "LaunchDrone_OreCollector" action (line 136) needs filled variable called "$pickuptargets_solid". This variable is filled just before drone launch at line 893 with this:
"$locfindsolid" is not used in any matter when "LaunchDrone_OreCollector" is called.
So there is no handling which mineral is selected in the UI. All mining drones collect everything when activated on a ship.
There is some handling about different minerals to collect at line 682 but this seems not to be executed on player ships.
The "LaunchDrone_OreCollector" action (line 136) needs filled variable called "$pickuptargets_solid". This variable is filled just before drone launch at line 893 with this:
Code: Select all
<find_object name="$pickuptargets_solid" space="this.zone" class="class.asteroid" multiple="true">
<match_distance object="this.assignedcontrolled" max="this.assignedcontrolled.maxradarrange"/>
</find_object>
So there is no handling which mineral is selected in the UI. All mining drones collect everything when activated on a ship.
There is some handling about different minerals to collect at line 682 but this seems not to be executed on player ships.
Re: Let mining drones collect the right things
yeah. ware detection is done when $pickuptargets_solid is populated in the event handler with comment "dronemode collectable found" and that with comment "miningdronemode changed ... ". you could add another check right before each drone is launched, but would be redundant since LaunchDrone_OreCollector is called right after each check in the two handlers.
Re: Let mining drones collect the right things
If it is redundant than i have nothing to do, do i? Because drones collect everything instead of selected mineral. Or maybe i just missunderstand you, sorry for my english.
Re: Let mining drones collect the right things
that's why i was asking what exactly the problem is. have you found steps to reproduce the issue? i just tested with an L ship with mining drones set to collect ore, and it did.
Re: Let mining drones collect the right things
hi,
yea its easy to reproduce it:
https://www.reddit.com/r/X4Foundations/ ... nstead_of/
No mods, fresh creative start. Disarm drones, select different mineral, mine something, arm drones with different mineral and they bring every mineral.
But about the code
The handler "dronemode collectable found" is not called in that case, because i disarmed drones and armed again.
I've used debug_to_file command to prove it.
When the player arms drones the another handler "miningdronemode changed" is called. I'm not sure, but could be because of this check:
In this handler there is no check for $dronemode to populate $pickuptargets_solid. Only wares.
The find_object command gives not filtered asteroids back into variable $pickuptargets_solid and after this LaunchDrone_OreCollector is called. Each mineral is collected.
In handler "dronemode collectable found" all collectables are stored first in $collectables and then filtered to variable $pickuptargets_solid.
Maybe this could be the fix for the other handler?
Edit: The drones also bring empty chunks, for that they should not launch in the first place. For this, the quantity would have to be taken into account beforehand. What is the command to do it?
yea its easy to reproduce it:
https://www.reddit.com/r/X4Foundations/ ... nstead_of/
No mods, fresh creative start. Disarm drones, select different mineral, mine something, arm drones with different mineral and they bring every mineral.
But about the code
The handler "dronemode collectable found" is not called in that case, because i disarmed drones and armed again.
I've used debug_to_file command to prove it.
When the player arms drones the another handler "miningdronemode changed" is called. I'm not sure, but could be because of this check:
Code: Select all
<event_object_miningdrones_armed object="this.assignedcontrolled"/>
The find_object command gives not filtered asteroids back into variable $pickuptargets_solid and after this LaunchDrone_OreCollector is called. Each mineral is collected.
In handler "dronemode collectable found" all collectables are stored first in $collectables and then filtered to variable $pickuptargets_solid.
Maybe this could be the fix for the other handler?
Edit: The drones also bring empty chunks, for that they should not launch in the first place. For this, the quantity would have to be taken into account beforehand. What is the command to do it?
Re: Let mining drones collect the right things
you may be on to something.
Re: Let mining drones collect the right things
yup, fixed. thanks!
in the "miningdronemode changed ... " handler
Code: Select all
<find_object name="$pickuptargets_solid" space="this.zone" class="class.asteroid" multiple="true">
<match_distance object="this.assignedcontrolled" max="this.assignedcontrolled.maxradarrange"/>
<match_wares>
<ware ware="$locwares"/>
</match_wares>
</find_object>
Re: Let mining drones collect the right things
Nice small fix! it works, I just tested it
I already wanted to filter the variable $pickuptargets_solid using $newminingdronemode or fill a new list. (After the find_object command, like in the other handler)
However, if the drones should not bring chunks with 0 minerals then I have to do it and iterate the list and check for the amount right?
I already wanted to filter the variable $pickuptargets_solid using $newminingdronemode or fill a new list. (After the find_object command, like in the other handler)
However, if the drones should not bring chunks with 0 minerals then I have to do it and iterate the list and check for the amount right?
Re: Let mining drones collect the right things
you could just check $asteroid.wares.{$ware}.count. asteroids without the ware you're interested in or that are empty should both return 0.
EDIT: sorry, time's more limited since at work today and misread your post. did you mean with the fix i posted? should implicitly also fix drones picking up empty asteroids. only asteroids with any $locwares in them would get into $pickuptargets_solid.
EDIT: sorry, time's more limited since at work today and misread your post. did you mean with the fix i posted? should implicitly also fix drones picking up empty asteroids. only asteroids with any $locwares in them would get into $pickuptargets_solid.
Re: Let mining drones collect the right things
Yea, sorry, my fault. I realized that "empty" asteroid is not in $locwares and won't be collected.
But, your hint helps me still to filter out asteroids with small amount like <50. There often asteroids with 1 or 10 minerals. The interesting one is above 500, so this saves the drone the time.
But, your hint helps me still to filter out asteroids with small amount like <50. There often asteroids with 1 or 10 minerals. The interesting one is above 500, so this saves the drone the time.
Re: Let mining drones collect the right things
Another thing: At line 695:
Shouldn't it be $miningdronemode == dronemode.collectsilicon?
Code: Select all
<do_elseif value="($miningdronemode == dronemode.collectore) and $collectables.{$interruptcounter}.wares.{ware.silicon}.count">
Re: Let mining drones collect the right things
right, forgot to mention. already fixed here. fix is as you said.