Hi there!
Let me introduce myself a bit. I've been playing around with the Powder Toy for at least 3 years now. However, I always hesitated to make an account here for some strange reason, until now.
That would be enough about me, time to get to the point.
In the link below I present the Lua code for my first element - IODN (technically speaking, it's 2 elements, but they refer to the same substance in different states). It bases off the real element Iodine (hence the name and properties).
When coding this element, I took a peek at a few other element codes for reference (I'm just a beginner), but I tried to write my own, I didn't simply copy-paste everything as it goes. I hope this isn't an issue.
Edit: The code has been improved!
Properties:
- Doesn't melt/freeze, it sublimes/deposits (113.7°C) instead, i.e. goes directly from solid to gas phase and vice-versa*
- Undergoes a solid-gas phase equilibrium. It depends on the given temperature, and at room temp. it will be roughly equal to 75% solid / 25% gas. Below -6°C and above 113.7°C it'll cease to change phases.**
- Will heat up and vigorously react with some metals, to be specific, BRMT and IRON, to form SALT. The former is more violent (for best results, mix the two powders evenly), while with the latter GIOD has to be heated to at least 400 degrees to initiate the reaction. The reaction now also proceeds at room temperature, but it's still comparatively slower than the BRMT reaction.
- On contact with NEUT will turn into its radioactive isotope, which in turn will decay into NBLE and ELEC over time.***
I experienced some lagging when adding a sized amount of either element (solid or gas). This may be due to some unnecessarily complex scripts involved (I'm a noob, so this is quite possible) or my ancient PC, or perhaps both.
I also wanted to assign a slightly different color (lighter/darker) to each particle, but I didn't know how to script it, none of my attempts have resulted in the desired effect. I've now implemented this in the new code.
If you have any ideas how to improve the script, suggestions, comments, criticism, feel free to tell me.
Changes:
- added graphics function for random particle colour
- reaction with IRON, as stated above, is now slightly more energetic.
- changed code layout a bit, made it more compact and simpler in places
- electrons from radioactive decay have a more randomized speed
* Actually, there is a liquid phase of the real element - well, leaving it out saved some scripting for me, as in real life it appears very briefly under standard pressure and almost immediately vaporises.
** I don't know if the lower temp. threshold is correct, I wasn't able to find any documentation on this.
*** There is a small problem with this, the NEUTs will react with the emitted ELECs to form HYGN. This sort of ruins the effect. Is there a way to disable certain reactions from the update function without changing the source?
Thanks!
The code has been changed a bit, more info in the OP.
I'm pretty sure the counter-process is called either desublimation or depositing.