untoldwind / KontrolSystem2

Autopilot scripting system for KSP2
Other
54 stars 14 forks source link

How do I get resource type in a part? #99

Closed SodaPopinski closed 3 months ago

SodaPopinski commented 6 months ago

In a previous version, each part had a "resources" field, where I could get resource.name. That doesn't seem to work anymore.

Here's some example code that no longer works. for (n in 0..vessel.parts.length) { //fix once I know how to add items to a list let part = vessel.parts[n] if(part.resources.list.length != 0) { if (vessel.parts[n].resources.list[0].resource.name == "Methane") { // CONSOLE.print_line(vessel.parts[n].part_name + " num: " + n.to_string()) all_tanks += n let part_location = vessel.facing.vector*100.0 - part.global_position.to_local(vessel.control_frame) if (!up) { if (part_location.magnitude > rear_most_amount) { rear_most_amount = part_location.magnitude rear_most_tank = n } } else { if (part_location.magnitude < rear_most_amount) { rear_most_amount = part_location.magnitude rear_most_tank = n } } // CONSOLE.print_line(part_location.to_fixed(2)) } } }

untoldwind commented 6 months ago

My bad, the annotation was accidentally removed by a merge.

untoldwind commented 6 months ago

Should be fixed in 0.5.0.1

github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 60 days with no activity.

github-actions[bot] commented 3 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.