Accessing devices' powerUse

Freeform discussion about anything related to modding Transcendence.
Post Reply
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

I'd like to create a mod that will toggle a user-defined list of devices on/off in order to conserve power.

To do that, I'll need to create a list of installed devices with a powerUse greater than zero (it makes no sense to disable devices with a powerUse of zero).

Is there a way for a mod to access a device's powerUse?
PM
Fleet Admiral
Fleet Admiral
Posts: 2570
Joined: Wed Sep 01, 2010 12:54 am

Yes. (itmGetProperty theItem "power") Value returned is in kilowatts. Divide by 1000 for MW.
Download and Play in 1.9 beta 1...
Drake Technologies (Alpha): More hardware for combat in parts 1 and 2!
Star Castle Arcade: Play a classic arcade game adventure, with or without more features (like powerups)!
Playership Drones: Buy or restore exotic ships to command!

Other playable mods from 1.8 and 1.7, waiting to be updated...
Godmode v3 (WIP): Dev/cheat tool compatible with D&O parts 1 or 2.
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

Ah - thanks! That's a new property that came with API 29, but for some reason, I didn't see it on the function list on the forum. Here's a complete list of the new properties:

https://ministry.kronosaur.com/record.hexm?id=8048

Code: Select all

New Properties
The following properties are accessible via itmGetProperty and objGetItemProperty:

We now support a set of properties to return special damage attributes. For example, the 'damageRadiation property returns the value of the radiation attribute. The result is the number specified in the damage definition.
'averageDamage: Average damage, in HP, for a single shot of the weapon (including all fragments, and adjusted for enhancements).
'damage: For weapons, the average damage per 180 ticks (adjusted for enhancements).
'damageWMD180: Whereas 'damageWMD returns the WMD value in the damage definition (from 0 to 7), this property returns the average amount of WMD damage per 180 ticks. Note that this takes into account the fact we always do at least 1 point of WMD damage per hit.
'currency: Returns the default currency for the item. This is the same as (itmGetDefaultCurrency item), which is now deprecated.
'fireDelay: For weapons, this is the number of ticks elapsed between shots, adjusted for enhancements.
'fuelCapacity: For reactors, returns the fuel capacity (1 = 1 helium fuel rod); includes enhancements.
'fuelCriteria: For reactors, this is a item criteria describing the set of compatible fuel items.
'fuelEfficiency: For reactors, this is the power produced per fuel unit (including enhancements).
'fuelEfficiencyBonus: For reactors, this describes fuel efficiency as a percent change from the standard, which is 15. Includes enhancements.
'hpBonus: For shields and armor, we return the percent bonus to HP for each damage type (returned in a struct). Note that this is the bonus relative to standard armors of this level; it includes any enhancements.
'maxDamage: Maximum damage, in HP, for a single shot of the weapon (including all fragments, and adjusted for enhancements).
'maxHP: For shields, this is the maximum number of HP, taking enhancements into account.
'maxSpeed: For drive devices, returns the maximum speed (0-100). This takes enhancements into account.
'minDamage: Minimum damage, in HP, for a single shot of the weapon (including all fragments, and adjusted for enhancements).
'power: Now takes enhancements into account for all devices.
'thrust: For drive devices, returns the additional thrust (including enhancements).

Code: Select all

TransLisp
For backwards compatibility, the add and multiply functions convert their inputs to integers before the operation. This is consistent with pre-float versions of TransLisp, but it changes behavior from API 28.
(itmGetProperty item 'components) -> returns a list of item structures representing the components for the given item.
There is a new special attribute for items: +hasComponents:true. This special attribute can be used in item criteria to filter items that have components.
(objGetProperty obj 'currency) -> returns the default currency for the object (generally, a station). This is the same as (objGetDefaultCurrency obj), which is now deprecated.
(objGetProperty obj 'scale) -> returns the scale of the object. One of the following: star, world, station, ship, flotsam.
Added round, floor, and ceil functions. They work on any number and always return doubles. NOTE: I was tempted to automatically cast the result to integers, but this would break if the original value was out of 32-bit range.
(convertTo type value) -> coerces value to the given type. See typeof for a list of valid types.
Added (resColorBlend ...) to generate colors.
Added (scrSetBackgroundImage ...). See Dock Screen section above.
Added (objGetProperty obj 'dockingPorts), which returns a list of docking port descriptors.
Added (objSetProperty obj 'operatingSpeed 'half) to order a ship to travel at half speed. This can be reversed with (objSetProperty obj 'operatingSpeed 'full). You can also get the property to determine the current operating speed.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

thank you for making me notice this.
'power is definitely working and it is not returned by fncHelp.

I assembled manually this list:

Code: Select all

(itmGetProperty item|type property) -> value

property

   'averageDamage: Average damage, in HP, for a single shot of the weapon (including all fragments, and adjusted for enhancements).
   'blindingImmune
   'canBeDisabled
   'category
   'charges
   'components: returns a list of item structures representing the components for the given item.
There is a new special attribute for items: +hasComponents:true. This special attribute can be used in item criteria to filter items that have components.
   'currency: Returns the default currency for the item. This is the same as (itmGetDefaultCurrency item), which is now deprecated.
   'damage: For weapons, the average damage per 180 ticks (adjusted for enhancements).
   'damageWMD180: Whereas    'damageWMD returns the WMD value in the damage definition (from 0 to 7), this property returns the average amount of WMD damage per 180 ticks. Note that this takes into account the fact we always do at least 1 point of WMD damage per hit.
   'damaged
   'description
   'deviceDamageImmune
   'deviceDisruptImmune
   'disintegrationImmune
   'disrupted
   'EMPImmune
   'fireDelay: For weapons, this is the number of ticks elapsed between shots, adjusted for enhancements.
   'fuelCapacity: For reactors, returns the fuel capacity (1 = 1 helium fuel rod); includes enhancements.
   'fuelCriteria: For reactors, this is a item criteria describing the set of compatible fuel items.
   'fuelEfficiency: For reactors, this is the power produced per fuel unit (including enhancements).
   'fuelEfficiencyBonus: For reactors, this describes fuel efficiency as a percent change from the standard, which is 15. Includes enhancements.
   'hp
   'hpBonus: For shields and armor, we return the percent bonus to HP for each damage type (returned in a struct). Note that this is the bonus relative to standard armors of this level; it includes any enhancements.
   'installed
   'maxDamage: Maximum damage, in HP, for a single shot of the weapon (including all fragments, and adjusted for enhancements).
   'maxHP: For shields, this is the maximum number of HP, taking enhancements into account.
   'maxSpeed: For drive devices, returns the maximum speed (0-100). This takes enhancements into account.
   'minDamage: Minimum damage, in HP, for a single shot of the weapon (including all fragments, and adjusted for enhancements).
   'omnidirectional
   'power: Now takes enhancements into account for all devices.
   'radiationImmune
   'range (for weapons)
   'repairCost
   'repairLevel
   'shatterImmune
   'speed (for weapons)
   'thrust: For drive devices, returns the additional thrust (including enhancements).
if you find anything else, let me know about it and/or post it in the functionlist thread in the Modding Reference ! :)
PM
Fleet Admiral
Fleet Admiral
Posts: 2570
Joined: Wed Sep 01, 2010 12:54 am

For weapon/missile types, "speed" for missileSpeed, and "range" for range. I do not remember if value returned for range is in light-seconds or some other value.
Download and Play in 1.9 beta 1...
Drake Technologies (Alpha): More hardware for combat in parts 1 and 2!
Star Castle Arcade: Play a classic arcade game adventure, with or without more features (like powerups)!
Playership Drones: Buy or restore exotic ships to command!

Other playable mods from 1.8 and 1.7, waiting to be updated...
Godmode v3 (WIP): Dev/cheat tool compatible with D&O parts 1 or 2.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

PM wrote:For weapon/missile types, "speed" for missileSpeed, and "range" for range. I do not remember if value returned for range is in light-seconds or some other value.
thanks !
I edited the list to include those too :)
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

gunship256 wrote:I'd like to create a mod that will toggle a user-defined list of devices on/off in order to conserve power.
Yes. please. This is a great idea. Hitting B,2,B,3,B,4,B,6,B,7 gets a bit tedious after the 20th, 30th, 50th time etc. :lol:
Stupid code. Do what I want, not what I typed in!
Post Reply