Ignore:
Timestamp:
05/05/16 01:34:56 (5 years ago)
Author:
sz
Message:

Creature object updated: energy balance fields removed, transferEnergyTo() added (Framsticks v5.0rc6)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/Framclipse/com.framsticks.framclipse/res/framscript.xml

    r491 r505  
    133133                <element name="idleen" type="float"/>
    134134                <element name="energy" type="float"/>
    135                 <element name="energy_p" type="float"/>
    136                 <element name="energy_m" type="float"/>
    137                 <element name="energy_b" type="float"/>
    138135                <element name="perf" type="integer" min="0" max="2">
    139136                        <description><![CDATA[Initial value of this property is taken from Population.enableperf]]></description>
     
    323320                        </arguments>
    324321                </element>
     322                <element name="transferEnergyTo" function="true" type="float" flags="32">
     323                        <description><![CDATA[Transfers at most the requested_amount_of_energy from this creature to the recipient. Returns the amount of energy actually transferred.
     324The function will only transfer positive amounts and will not transfer more energy than this creature has, so the function is equivalent to:
     325if (this.energy>0 && requested_amount_of_energy>0)
     326{
     327  var amount = Math.min(requested_amount_of_energy, this.energy);
     328  recipient.energy += amount;
     329  this.energy -= amount;
     330}]]></description>
     331                        <arguments>
     332                                <argument name="recipient" type="Creature"/>
     333                                <argument name="requested_amount_of_energy" type="float"/>
     334                        </arguments>
     335                </element>
    325336        </type>
    326337        <type name="CreatureSettings" context="Global context">
     
    411422                <element name="idleen" type="float"/>
    412423                <element name="energy" type="float"/>
    413                 <element name="energy_p" type="float"/>
    414                 <element name="energy_m" type="float"/>
    415                 <element name="energy_b" type="float"/>
    416424                <element name="perf" type="integer" min="0" max="2">
    417425                        <description><![CDATA[Initial value of this property is taken from Population.enableperf]]></description>
     
    55395547                <element name="idleen" type="float"/>
    55405548                <element name="energy" type="float"/>
    5541                 <element name="energy_p" type="float"/>
    5542                 <element name="energy_m" type="float"/>
    5543                 <element name="energy_b" type="float"/>
    55445549                <element name="perf" type="integer" min="0" max="2">
    55455550                        <description><![CDATA[Initial value of this property is taken from Population.enableperf]]></description>
     
    57275732                        <arguments>
    57285733                                <argument name="mask" type="integer"/>
     5734                        </arguments>
     5735                </element>
     5736                <element name="transferEnergyTo" function="true" type="float" flags="32">
     5737                        <description><![CDATA[Transfers at most the requested_amount_of_energy from this creature to the recipient. Returns the amount of energy actually transferred.
     5738The function will only transfer positive amounts and will not transfer more energy than this creature has, so the function is equivalent to:
     5739if (this.energy>0 && requested_amount_of_energy>0)
     5740{
     5741  var amount = Math.min(requested_amount_of_energy, this.energy);
     5742  recipient.energy += amount;
     5743  this.energy -= amount;
     5744}]]></description>
     5745                        <arguments>
     5746                                <argument name="recipient" type="Creature"/>
     5747                                <argument name="requested_amount_of_energy" type="float"/>
    57295748                        </arguments>
    57305749                </element>
Note: See TracChangeset for help on using the changeset viewer.