Help with new elements & sparks.

  • Corpsey
    29th May 2014 Member 0 Permalink

    Sparked metal causes the plastic to ignite.

    I started making Polyethylene just to attempt to bring a new material into the game. I've noticed that the new material will catch fire when it is next to an object that has a charge or is sparking, and I'd like to remove that behavior. The material only has 2 flamability for the time being and still manages to catch fire when it's next to an object with a spark/charge.

    Is there some way I can post code here? Hmm..
    http://pastebin.com/Q7BvrZ0v
    (autorun.lua)

    Also, this script is a good example of how to get the transitions to work right out of an LUA - the trick is to define them after all of the element properties.

    The materials themselves I could use some feedback on perhaps though... especially like examples on how to balance HotAir + Loss + Air Drag + Air Loss + Advection + Gravity.

    Edit: Whoops, forgot to take out the NOAMBHEAT flag I played with last, too.

    Edited 2 times by Corpsey. Last: 29th May 2014
  • Millions
    29th May 2014 Member 1 Permalink

    Try lowering the flamability.

  • Corpsey
    29th May 2014 Member 1 Permalink

    Nice, that worked. Interesting that changing flamability would affect how the sparks interact with it... I never would have guessed.

    I guess I'll need to just script it (the solid material at least) to interact more rapidly with flame though, because I did like how flammable it was.

    Thanks.

  • h4zardz1
    29th May 2014 Member 0 Permalink
    look at OXYG code.
  • Corpsey
    30th May 2014 Member 0 Permalink

    Uh, I wouldn't even know how to unpack the game. My programming experience is minimal.

    Could someone just create some LUA snippets? like;

    'If surrrounding particles consist of (PT_Particle1)(PT_Particle2) etc..' then sim.partChangeType'

    &

    'If surrrounding particles consist of (PT_Particle1)(PT_Particle2) etc..' then sim.partCreate'

    Also other snippets such as

    'If surrrounding particles consist of (PT_Particle1)(PT_Particle2) etc..' AND particle is more than ___ temp(and/or pressure) then sim.partChangeType'

    I know there are ways to have the particles transistion with the base code but for special cases (where another element is needed) something like that may be useful.

    I can figure out the logic that I want but I don't know how to write it into code...

    http://pastebin.com/iKB0psnq

    (autorun.lua, plastic mod v0.1.3)

    This is as far as I got, all I added was the ability to break the plastic under pressure so that bombs aren't fully contained anymore. I did add some code but it's embarassingly simple and it doesn't work the way I want it to so I kind of gave up on it (and it has been removed). I'm having a lot of trouble with sim.partCreate. For the x and y field, it seems to want to treat the entire mass of material as 'the particle' instead of a per particle basis.

    sim.partCreate
    Like for example in this image, I lit the one end of the material with fire and the other end starts generating a gap.

    I kind of don't want to bombard the forums with threads every time I have a question about code, either.

    Uh, this code is garbage but it is an example of how to get the code to update on the material (otherwise the code parses once and never gets read again) although saying this in the Lua scripting forums is kind of embarassing, I figure I should share what I know :) :
    http://pastebin.com/Z3fKkG49

    Edited once by Corpsey. Last: 29th May 2014
  • jacob1
    30th May 2014 Developer 1 Permalink
    @Corpsey (View Post)
    Those scripts are actually pretty good, you are actually using elements.property properly and do some other nice things. For sim.partCreate, try passing in -1 as the first argument. It's sort of weird, but -1 just means create the particle normally, then the x, y, type args start after. -2 is used for creation from the brush (don't use this), -3 for create even if a particle is already there, and >=0 for overriding a particle at that index.

    Also, you are changing the type of the particle 4 times in a row here:
    sim.partChangeType(index, elements.DEFAULT_PT_CO2)
    sim.partChangeType(index, elements.DEFAULT_PT_CAUS)
    sim.partChangeType(index, elements.DEFAULT_PT_FIRE)
    sim.partChangeType(index, elements.DEFAULT_PT_CO2)

    I'm not sure what you are trying to do, maybe you instead want to create all of those at once (if so then use createPart with -1 or -3), or create only one randomly?

    Edit: also here is an example script I made, which is a clone of WIFI in lua: http://pastebin.com/AKp8624S . You can ignore anything about wireless[][], but the "for r in sim.neighbors(x, y, 1, 1) do" line can be very useful in speeding up lua scripts if you want that.
    Edited 2 times by jacob1. Last: 30th May 2014
  • Corpsey
    3rd Jun 2014 Member 0 Permalink

    I tried to change the particle 4 times for the sake of seeing what would happen.

    I'm not quite sure I'm understanding the createPart line yet... are you saying to have it set up like so:
    createPart-1(x,y,particle) or..? Where do these numbers go exactly?

    Edited once by Corpsey. Last: 3rd Jun 2014