Rechargable battery dilemma

  • greymatter
    7th Jul 2013 Member 0 Permalink
    I want to make a rechargable battery for my mod, and tried and failed quite a number of times,
    The element is named LTHM(lithium). PSCN will charge it and NSCN will discharge it. Charge is stored as the tmp value.

    The problem is that the the charge won't spread properly. Charging and discharging one pixel of LTHM works just fine, but when 1 pixel gains or loses charge, I want all the lithium particles it is connected to to also lose or gain charge. I tried using several ways, but always ended up with some glich or the other.

    So can someone help out?
  • thepowderguy
    7th Jul 2013 Member 0 Permalink

    There is a function called sim->flood_prop that can flood fill a property so I think this is what you need.

     

    Here's the text from the wiki:

    sim->flood_prop(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype);

    What it does: Sets a property via flood-fill. (Like PROP)

    int x - Particle's x coordinate

    int y - Particle's y coordinate

    size_t propoffset - This is a value returned by the function offsetof(Particle, <property>).

    Replace <property> with what you want, for example tmp or ctype.

    void * propvalue - A reference to your property's value.

    One needs to define the value beforehand.

    For example, when you've defined int temperature = 200;, then you should use &temperature.

    StructProperty::PropertyType proptype - What kind of type the value you provided is.

    For example, if you had a temperature number (as an integer), then you could use 'StructProperty::Integer'.The types are: 'StructProperty::Integer',

    'StructProperty::Float' and 'StructProperty::Uinteger'

  • greymatter
    7th Jul 2013 Member 0 Permalink
    @thepowderguy (View Post)
    That wasn't very much understandable but let me try...

    EDIT: The function offsetof() gives me errors..what am I supposed to enter exactly?
    I tried offsetof(PT_LTHM,tmp) but got an error...
  • mniip
    7th Jul 2013 Developer 0 Permalink
    it's literally offsetof(Particle,tmp);
  • greymatter
    7th Jul 2013 Member 0 Permalink
    @mniip (View Post)
    Oh that worked. Thank you.