http://powdertoy.co.uk/Wiki/api.php?action=feedcontributions&user=ChargedCreeper&feedformat=atomThe Powder Toy - User contributions [en]2024-03-28T19:56:49ZUser contributionsMediaWiki 1.30.0http://powdertoy.co.uk/Wiki/index.php?title=Element_Properties&diff=5659Element Properties2015-07-04T19:59:53Z<p>ChargedCreeper: /* Properties */</p>
<hr />
<div>Each element in TPT has properties associated with it that apply to all particles of that type on the screen. This is a list of all those properties (for use in both C++ and Lua)<br />
<br />
== Properties ==<br />
{|<br />
| '''Identifier'''|| Identifier string, used for lua and internal stuff. Formatted like DEFAULT_PT_XXXX.<br />
|-<br />
| '''Name'''|| Name, it is recommended to use 4 letters, but less works. 5 or more will probably not fit on the buttons.<br />
|-<br />
| '''Color'''|| Default color, in hexadecimal (RRGGBB). In the deco editor, it will tell you the color in hex, ignore the initial FF, and use the 6 digits after for this. The initial FF is the alpha or transparency part of 32-bit color.<br />
|-<br />
| '''MenuVisible'''|| If it's visible in the menu, if 0 then it is hidden and can only be produced with reactions or lua.<br />
|-<br />
| '''MenuSection'''|| The menu section it's in. See below for a list of possible values.<br />
|-<br />
| '''Enabled'''|| If 0, it cannot be created or seen in any way, not even lua. It will just disappear if somehow created. Used for removed elements, you should leave this 1.<br />
|-<br />
| '''Advection'''|| How much the particle is accelerated by moving air. Normally 0 for solids, and up to 1 for other elements. It can be negative, ANAR and DEST do this so it goes towards pressure.<br />
|-<br />
| '''AirDrag'''|| How much air the particle generates in the direction of travel. Generally is very small, 0.04f creates a lot of positive air (- creates negative pressure)..<br />
|-<br />
| '''AirLoss'''|| How much the particle slows down moving air (although not as big an effect as a wall). 1 = no effect, 0 = maximum effect. Solids are generally above 0.90f, along with most other elements too.<br />
|-<br />
| '''Loss'''|| How much velocity the particle loses each frame. 1 = no loss, .5 = half loss. Solids have it at 0. Only a few have it at 1, like energy particles, and old moving sponge.<br />
|-<br />
| '''Collision'''|| Velocity is multiplied by this when the particle collides with something. Energy particles have it at -0.99f, everything else is -0.01f or 0.0f. This property does not do much at all.<br />
|-<br />
| '''Gravity'''|| How fast the particle falls. A negative number means it floats. Generally very small, most gasses are negative, everything else is usually less than 0.04f.<br />
|-<br />
| '''Diffusion'''|| How much the particle "wiggles" around (think GAS or HYGN). Set at 0, except for gasses, which is a positive number. Up to 3 (or higher) for a large amount of wiggle, GAS is 0.75f, HYGN is 3.00f.<br />
|-<br />
| '''HotAir'''|| How much the particle increases the pressure by. Another property only for gasses, but VENT/VACU have theirs at (-)0.010f. Usually it's an extremely small number, sometimes as small as 0.000001f.<br />
|-<br />
| '''Falldown'''|| How does the particle move? 0 = solid, gas, or energy particle, 1 = powder, 2 = liquid.<br />
|-<br />
| '''Flammable'''|| Does it burn? 0 = no, higher numbers = higher "burnage". Something like 20 is WOOD, while C-4 is 1000. Some are a few thousand for almost instant burning.<br />
|-<br />
| '''Explosive'''|| Does it explode? 0 = no, 1 = when touching fire, 2 = when touching fire or when pressure > 2.5. Yes, those are the only options, see FIRE.cpp or somewhere in Simulation.cpp to modify how they work. You MUST set the Flammable property also for this to have any effect.<br />
|-<br />
| '''Meltable'''|| Does it melt? 1 or higher = yes, 0 = no. This is actually only used when heat sim is off, to make it actually melt use element transitions.<br />
|-<br />
| '''Hardness'''|| How much does acid affect it? 0 = no effect, higher numbers = higher effect. Generally goes up to about 50.<br />
|-<br />
| '''Weight'''|| Heavier elements sink beneath lighter ones. 1 = Gas. 2 = Light, 98 = Heavy (liquids 0-49, powder 50-99). 100 = Solid. -1 is Neutrons and Photons.<br />
|-<br />
| '''Temperature'''|| What temperature does it have when spawned? Temperature is in Kelvin (Kelvin = degrees C + 273.15). R_TEMP+273.15f gives room temperature.<br />
|-<br />
| '''HeatConduct'''|| 0 - no heat transfer, 255 - maximum heat transfer speed.<br />
|-<br />
| '''Description'''|| A short one sentence description of the element, shown when you mouse over it in-game.<br />
|-<br />
| '''State'''|| What state is this element? Options are ST_NONE, ST_SOLID, ST_LIQUID, ST_GAS. Powders use solid, energy particles and some other random things use none.<br />
|-<br />
| '''Properties'''|| Does this element have special properties? At the minimum you need to put the state here too, see below for possible properties (add them together with +).<br />
|-<br />
| '''LowPressure'''|| If the element drops below this pressure it will transition (set to IPL to never transition).<br />
|-<br />
| '''LowPressureTransition'''|| The element to transition into when pressure is below the threshold (set to NT to never transition).<br />
|-<br />
| '''HighPressure'''|| If the element goes above this pressure it will transition (set to IPH to never transision).<br />
|-<br />
| '''HighPressureTransition'''|| The element to transition into when pressure is above the threshold (set to NT to never transition).<br />
|-<br />
| '''LowTemperature'''|| If the element drops below this temperature it will transition (set to ITL to never transition).<br />
|-<br />
| '''LowTemperatureTransition'''|| The element to transition into when temperature is below the threshold (set to NT to never transition).<br />
|-<br />
| '''HighTemperature'''|| If the element goes above this temperature it will transition (set to ITH to never transition).<br />
|-<br />
| '''HighTemperatureTransition'''|| The element to transition into when temperature is above the threshold (set to NT to never transition).<br />
|-<br />
| '''Update'''|| The update function. This is what controls how your element reacts with other elements.<br />
|-<br />
| '''Graphics'''|| The graphics function, This controls any fancy effects. If your element is only one solid color, you don't need this.<br />
|}<br />
<br />
== Menu sections ==<br />
These are used for the <tt>MenuSection</tt> property.<br />
; SC_WALL<br />
; SC_ELEC<br />
; SC_POWERED<br />
; SC_SENSOR<br />
; SC_FORCE<br />
; SC_EXPLOSIVE<br />
; SC_GAS<br />
; SC_LIQUID<br />
; SC_POWDERS<br />
; SC_SOLIDS<br />
; SC_NUCLEAR<br />
; SC_SPECIAL<br />
; SC_LIFE<br />
; SC_TOOL<br />
; SC_DECO<br />
<br />
== .Property Constants ==<br />
These are used for the <tt>Properties</tt> property.<br />
; TYPE_PART<br />
: Used in powders.<br />
; TYPE_LIQUID<br />
: Used in liquids.<br />
; TYPE_SOLID<br />
: Used in solids / misc elements.<br />
; TYPE_GAS<br />
: Used in gasses.<br />
; TYPE_ENERGY<br />
: Used in energy particles.<br />
; PROP_CONDUCTS<br />
: Allows an element to automatically conduct SPRK, requires PROP_LIFE_DEC.<br />
; PROP_BLACK<br />
: Elements with this property absorb photons of any color.<br />
; PROP_NEUTPENETRATE<br />
: Elements with this property allow neutrons to go through it.<br />
; PROP_NEUTABSORB<br />
: Element will absorb neutrons.<br />
; PROP_NEUTPASS<br />
: Element can be displaced by neutrons (observe behavior of wood with neutrons to see).<br />
; PROP_DEADLY<br />
: Element will kill stickmen and fighters.<br />
; PROP_HOT_GLOW<br />
: Element will glow red when it approaches it's melting point.<br />
; PROP_LIFE<br />
: Unused.<br />
; PROP_RADIOACTIVE<br />
: Element will have a radioactive glow, like URAN or PLUT. Also, deadly to stickmen.<br />
; PROP_LIFE_DEC<br />
: The "life" property of particles will be reduced by 1 every frame.<br />
; PROP_LIFE_KILL<br />
: Particles will be destroyed when the "life" property is less than or equal to zero.<br />
; PROP_LIFE_KILL_DEC<br />
: When used with PROP_LIFE_DEC, particles will be destroyed when the "life" property is decremented to 0. If already at 0 it will be fine.<br />
; PROP_SPARKSETTLE<br />
: Allows sparks/embers to contact without being destroyed.<br />
; PROP_NOAMBHEAT<br />
: Prevents particles from exchanging heat with the air when ambient heat is enabled.<br />
; PROP_DRAWONCTYPE<br />
: Set its ctype to another element if the element is drawn upon it (like what CLNE does).<br />
; PROP_NOCTYPEDRAW<br />
: When this element is drawn upon other elements, do not set ctype (like STKM for CLNE).</div>ChargedCreeperhttp://powdertoy.co.uk/Wiki/index.php?title=Element_Properties&diff=5658Element Properties2015-07-04T19:59:27Z<p>ChargedCreeper: /* Properties */</p>
<hr />
<div>Each element in TPT has properties associated with it that apply to all particles of that type on the screen. This is a list of all those properties (for use in both C++ and Lua)<br />
<br />
== Properties ==<br />
{|<br />
| '''Identifier'''|| Identifier string, used for lua and internal stuff. Formatted like DEFAULT_PT_XXXX.<br />
|-<br />
| '''Name'''|| Name, it is recommended to use 4 letters, but less works. 5 or more will probably not fit on the buttons.<br />
|-<br />
| '''Color'''|| Default color, in hexadecimal (AARRGGBB). In the deco editor, it will tell you the color in hex, ignore the initial FF, and use the 6 digits after for this. The initial FF is the alpha or transparency part of 32-bit color.<br />
|-<br />
| '''MenuVisible'''|| If it's visible in the menu, if 0 then it is hidden and can only be produced with reactions or lua.<br />
|-<br />
| '''MenuSection'''|| The menu section it's in. See below for a list of possible values.<br />
|-<br />
| '''Enabled'''|| If 0, it cannot be created or seen in any way, not even lua. It will just disappear if somehow created. Used for removed elements, you should leave this 1.<br />
|-<br />
| '''Advection'''|| How much the particle is accelerated by moving air. Normally 0 for solids, and up to 1 for other elements. It can be negative, ANAR and DEST do this so it goes towards pressure.<br />
|-<br />
| '''AirDrag'''|| How much air the particle generates in the direction of travel. Generally is very small, 0.04f creates a lot of positive air (- creates negative pressure)..<br />
|-<br />
| '''AirLoss'''|| How much the particle slows down moving air (although not as big an effect as a wall). 1 = no effect, 0 = maximum effect. Solids are generally above 0.90f, along with most other elements too.<br />
|-<br />
| '''Loss'''|| How much velocity the particle loses each frame. 1 = no loss, .5 = half loss. Solids have it at 0. Only a few have it at 1, like energy particles, and old moving sponge.<br />
|-<br />
| '''Collision'''|| Velocity is multiplied by this when the particle collides with something. Energy particles have it at -0.99f, everything else is -0.01f or 0.0f. This property does not do much at all.<br />
|-<br />
| '''Gravity'''|| How fast the particle falls. A negative number means it floats. Generally very small, most gasses are negative, everything else is usually less than 0.04f.<br />
|-<br />
| '''Diffusion'''|| How much the particle "wiggles" around (think GAS or HYGN). Set at 0, except for gasses, which is a positive number. Up to 3 (or higher) for a large amount of wiggle, GAS is 0.75f, HYGN is 3.00f.<br />
|-<br />
| '''HotAir'''|| How much the particle increases the pressure by. Another property only for gasses, but VENT/VACU have theirs at (-)0.010f. Usually it's an extremely small number, sometimes as small as 0.000001f.<br />
|-<br />
| '''Falldown'''|| How does the particle move? 0 = solid, gas, or energy particle, 1 = powder, 2 = liquid.<br />
|-<br />
| '''Flammable'''|| Does it burn? 0 = no, higher numbers = higher "burnage". Something like 20 is WOOD, while C-4 is 1000. Some are a few thousand for almost instant burning.<br />
|-<br />
| '''Explosive'''|| Does it explode? 0 = no, 1 = when touching fire, 2 = when touching fire or when pressure > 2.5. Yes, those are the only options, see FIRE.cpp or somewhere in Simulation.cpp to modify how they work. You MUST set the Flammable property also for this to have any effect.<br />
|-<br />
| '''Meltable'''|| Does it melt? 1 or higher = yes, 0 = no. This is actually only used when heat sim is off, to make it actually melt use element transitions.<br />
|-<br />
| '''Hardness'''|| How much does acid affect it? 0 = no effect, higher numbers = higher effect. Generally goes up to about 50.<br />
|-<br />
| '''Weight'''|| Heavier elements sink beneath lighter ones. 1 = Gas. 2 = Light, 98 = Heavy (liquids 0-49, powder 50-99). 100 = Solid. -1 is Neutrons and Photons.<br />
|-<br />
| '''Temperature'''|| What temperature does it have when spawned? Temperature is in Kelvin (Kelvin = degrees C + 273.15). R_TEMP+273.15f gives room temperature.<br />
|-<br />
| '''HeatConduct'''|| 0 - no heat transfer, 255 - maximum heat transfer speed.<br />
|-<br />
| '''Description'''|| A short one sentence description of the element, shown when you mouse over it in-game.<br />
|-<br />
| '''State'''|| What state is this element? Options are ST_NONE, ST_SOLID, ST_LIQUID, ST_GAS. Powders use solid, energy particles and some other random things use none.<br />
|-<br />
| '''Properties'''|| Does this element have special properties? At the minimum you need to put the state here too, see below for possible properties (add them together with +).<br />
|-<br />
| '''LowPressure'''|| If the element drops below this pressure it will transition (set to IPL to never transition).<br />
|-<br />
| '''LowPressureTransition'''|| The element to transition into when pressure is below the threshold (set to NT to never transition).<br />
|-<br />
| '''HighPressure'''|| If the element goes above this pressure it will transition (set to IPH to never transision).<br />
|-<br />
| '''HighPressureTransition'''|| The element to transition into when pressure is above the threshold (set to NT to never transition).<br />
|-<br />
| '''LowTemperature'''|| If the element drops below this temperature it will transition (set to ITL to never transition).<br />
|-<br />
| '''LowTemperatureTransition'''|| The element to transition into when temperature is below the threshold (set to NT to never transition).<br />
|-<br />
| '''HighTemperature'''|| If the element goes above this temperature it will transition (set to ITH to never transition).<br />
|-<br />
| '''HighTemperatureTransition'''|| The element to transition into when temperature is above the threshold (set to NT to never transition).<br />
|-<br />
| '''Update'''|| The update function. This is what controls how your element reacts with other elements.<br />
|-<br />
| '''Graphics'''|| The graphics function, This controls any fancy effects. If your element is only one solid color, you don't need this.<br />
|}<br />
<br />
== Menu sections ==<br />
These are used for the <tt>MenuSection</tt> property.<br />
; SC_WALL<br />
; SC_ELEC<br />
; SC_POWERED<br />
; SC_SENSOR<br />
; SC_FORCE<br />
; SC_EXPLOSIVE<br />
; SC_GAS<br />
; SC_LIQUID<br />
; SC_POWDERS<br />
; SC_SOLIDS<br />
; SC_NUCLEAR<br />
; SC_SPECIAL<br />
; SC_LIFE<br />
; SC_TOOL<br />
; SC_DECO<br />
<br />
== .Property Constants ==<br />
These are used for the <tt>Properties</tt> property.<br />
; TYPE_PART<br />
: Used in powders.<br />
; TYPE_LIQUID<br />
: Used in liquids.<br />
; TYPE_SOLID<br />
: Used in solids / misc elements.<br />
; TYPE_GAS<br />
: Used in gasses.<br />
; TYPE_ENERGY<br />
: Used in energy particles.<br />
; PROP_CONDUCTS<br />
: Allows an element to automatically conduct SPRK, requires PROP_LIFE_DEC.<br />
; PROP_BLACK<br />
: Elements with this property absorb photons of any color.<br />
; PROP_NEUTPENETRATE<br />
: Elements with this property allow neutrons to go through it.<br />
; PROP_NEUTABSORB<br />
: Element will absorb neutrons.<br />
; PROP_NEUTPASS<br />
: Element can be displaced by neutrons (observe behavior of wood with neutrons to see).<br />
; PROP_DEADLY<br />
: Element will kill stickmen and fighters.<br />
; PROP_HOT_GLOW<br />
: Element will glow red when it approaches it's melting point.<br />
; PROP_LIFE<br />
: Unused.<br />
; PROP_RADIOACTIVE<br />
: Element will have a radioactive glow, like URAN or PLUT. Also, deadly to stickmen.<br />
; PROP_LIFE_DEC<br />
: The "life" property of particles will be reduced by 1 every frame.<br />
; PROP_LIFE_KILL<br />
: Particles will be destroyed when the "life" property is less than or equal to zero.<br />
; PROP_LIFE_KILL_DEC<br />
: When used with PROP_LIFE_DEC, particles will be destroyed when the "life" property is decremented to 0. If already at 0 it will be fine.<br />
; PROP_SPARKSETTLE<br />
: Allows sparks/embers to contact without being destroyed.<br />
; PROP_NOAMBHEAT<br />
: Prevents particles from exchanging heat with the air when ambient heat is enabled.<br />
; PROP_DRAWONCTYPE<br />
: Set its ctype to another element if the element is drawn upon it (like what CLNE does).<br />
; PROP_NOCTYPEDRAW<br />
: When this element is drawn upon other elements, do not set ctype (like STKM for CLNE).</div>ChargedCreeperhttp://powdertoy.co.uk/Wiki/index.php?title=Lua_API:Elements&diff=5583Lua API:Elements2015-05-04T15:54:46Z<p>ChargedCreeper: </p>
<hr />
<div>The Elements API Methods and constants for modifying and creating elements. If you want to add an update function or graphics function, use Update and Graphics properties. See the properties section for an example.<br />
== Methods ==<br />
<br />
=== elements.allocate === <br />
number elements.allocate(string group, string name)<br />
Use this function to create a new element. This function will return the id of your element, and create a unique identifier that can be used to modify the properties later. The identifier is in the form GROUP_PT_NAME, where group is the name of the mod or script (or just anything unique, like your username), and name is the name of the element. For example, elements.allocate("mymod", "virus") would create the identifier MYMOD_PT_VIRUS.<br />
<br />
The identifier is added as a constant in the elements table, so elements.MYMOD_PT_VIRUS would be equivalent to the new element's id, and can be used as the elementID argument to any of the functions below.<br />
<br />
The new element is created with all the default properties, and won't be visible until you modify it to show up in the menu.<br />
<br />
Returns -1 on failure (there are no free spaces to create a new element).<br />
<br />
=== elements.free === <br />
elements.free(number elementID)<br />
Free a previously allocated element, so it will disappear from the game. The element id will be freed and can used later by another script. elementID must be a non-default element (i.e you cannot free the default WATR element)<br />
<br />
=== elements.loadDefault ===<br />
elements.loadDefault()<br />
Resets all elements to the original state. This will also erase any elements created with any scripts, only the default elements will be available.<br />
<br />
elements.loadDefault(number elementID)<br />
Reset an element to its original state before it was modified<br />
<br />
=== elements.element ===<br />
table elements.element(number elementID)<br />
Returns a table containing all of an element's properties (Name, Description, etc)<br />
<br />
elements.element(number elementID, table properties)<br />
Sets the properties from the given table onto the element.<br />
<br />
These two functions are useful for copying or templating from already present elements, for example<br />
<syntaxhighlight lang="lua"><br />
local myNewElement = elements.allocate("wiki", "expl")<br />
elements.element(myNewElement, elements.element(elements.DEFAULT_PT_WATR))<br />
elements.property(myNewElement, "Name", "EXPL")<br />
elements.property(myNewElement, "Description", "This is an example element from the Wiki")<br />
</syntaxhighlight><br />
In this example, the element properties for our new element (EXPL) are copied from WATR<br />
<br />
<syntaxhighlight lang="lua"><br />
local star = elements.allocate("ELEMENT", "STAR")<br />
elements.element(star, elements.element(elements.DEFAULT_PT_DMND))<br />
elements.property(star, "Name", "STAR")<br />
elements.property(star, "Description", "STAR. Enough Pressure Makes It Explode Into LAVA.")<br />
elements.property(star, "Colour", 0xFFFFFF)<br />
elements.property(star, "MenuSection", elem.SC_SOLIDS)<br />
elements.property(star, "HotAir", -0.009)<br />
elements.property(star, "Weight", 333)<br />
elements.property(star, "Temperature", 4556)<br />
elements.property(star, "HighPressure", 200)<br />
elements.property(star, "HighPressureTransition", elements.DEFAULT_PT_LAVA)<br />
local function graphics1(i, colr, colg, colb) <br />
return 1,ren.FIRE_ADD,255,100,155,210,255,255,255,255<br />
end<br />
tpt.graphics_func(graphics1, star)<br />
</syntaxhighlight><br />
Another Example, from an actual script. For more info on graphics functions, see the legacy api page<br />
<br />
=== elements.property ===<br />
object elements.property(number elementID, string property)<br />
Gets the value of an element property<br />
<br />
elements.property(number elementID, string property, object value)<br />
Sets the value of an element property<br />
<br />
== Properties ==<br />
After creating an element, you can modify many properties. Be sure to at a minimum set set Name, Description, Color, MenuVisible, and MenuSection. <br />
<br />
For more information on what properties there are to use in elements.property, and how to use them, see this page: [[Element_Properties]]<br />
<br />
<br />
"Update" and "Graphics" are special properties, these can be used to set the update functions or graphics functions. Use a function as the value of the property to set. They are not included in the tables created with elements.element, and the functions can't be returned with elements.property either. This means copying all of an elements properties using elements.element will not set these two for the new element. For example:<br />
<syntaxhighlight lang="lua"><br />
local function funcUpdate(i,x,y,s,nt)<br />
<br />
end<br />
<br />
local function funcGraphics(i, colr, colg, colb)<br />
<br />
end<br />
<br />
elements.property(ELEM, "Update", funcUpdate) <br />
elements.property(ELEM, "Graphics", funcGraphics)<br />
</syntaxhighlight><br />
== Constants ==<br />
Any of these constants can be accessed with elements.<constant name here><br />
<br />
=== Element identifiers ===<br />
All of the default element identifiers are prefixed with <code>DEFAULT_PT_</code>, for example, the identifier for WATR is <code>DEFAULT_PT_WATR</code>. Do not assume all elements identifiers are the same as their names, TNT has the identifier BANG, for example. To find an elements identifier, you can check the source file for any given element in <tt>src/simulation/elements/</tt>.<br />
<br />
=== States ===<br />
There are just 3 constants for element state (Used in the "State" property of elements)<br />
; ST_NONE<br />
: Used by some "unusual" elements such as Photons<br />
; ST_SOLID<br />
; ST_LIQUID<br />
; ST_GAS<br />
These values do not alter the physical properties of elements, but instead are used internally for identification. Powders use the solid state.<br />
<br />
=== Properties ===<br />
More info on the properties can be found here: [[Element_Properties]]<br />
; TYPE_PART<br />
; TYPE_LIQUID<br />
; TYPE_GAS<br />
; TYPE_SOLID<br />
; TYPE_ENERGY<br />
; PROP_CONDUCTS<br />
; PROP_BLACK<br />
; PROP_NEUTPENETRATE<br />
; PROP_NEUTABSORB<br />
; PROP_NEUTPASS<br />
; PROP_DEADLY<br />
; PROP_HOT_GLOW<br />
; PROP_LIFE<br />
; PROP_RADIOACTIVE<br />
; PROP_LIFE_DEC<br />
; PROP_LIFE_KILL<br />
; PROP_LIFE_KILL_DEC<br />
; PROP_SPARKSETTLE<br />
; PROP_NOAMBHEAT<br />
; PROP_DRAWONCTYPE <br />
; PROP_NOCTYPEDRAW <br />
<br />
=== Menu sections ===<br />
These are used for the menusection property<br />
; SC_WALL<br />
; SC_ELEC<br />
; SC_POWERED<br />
; SC_SENSOR<br />
; SC_FORCE<br />
; SC_EXPLOSIVE<br />
; SC_GAS<br />
; SC_LIQUID<br />
; SC_POWDERS<br />
; SC_SOLIDS<br />
; SC_NUCLEAR<br />
; SC_SPECIAL<br />
; SC_LIFE<br />
; SC_TOOL<br />
; SC_DECO<br />
SC_CRACKER and SC_CRACKER2 are not accessible from lua or in the game, but have id numbers of 15 and 16<br />
<br />
=== Flags ===<br />
set in parts[i].flags<br />
; FLAG_STAGNANT<br />
: Used by liquids and powders to speed up simulation by moving them less<br />
; FLAG_SKIPMOVE<br />
: Given to PHOT by PLCN and PBCN to fix gaps in lasers, only useable by energy particles<br />
; FLAG_WATEREQUAL<br />
: Used internally for water equalization<br />
; FLAG_MOVABLE<br />
: Can be used to re-enable moving sponge<br />
; FLAG_PHOTDECO<br />
: Re-enables deco on photons for compatibility. Defined as the same value as FLAG_MOVABLE (they only apply to different elements)<br />
<br />
[[Category:Lua]]</div>ChargedCreeperhttp://powdertoy.co.uk/Wiki/index.php?title=Lua_API:Elements&diff=5582Lua API:Elements2015-05-04T15:51:33Z<p>ChargedCreeper: /* Properties */</p>
<hr />
<div>The Elements API Methods and constants for modifying and creating elements. If you want to add an update function or graphics function, see the Legacy API, specifically the functions tpt.element_func and tpt.graphics_func<br />
== Methods ==<br />
<br />
=== elements.allocate === <br />
number elements.allocate(string group, string name)<br />
Use this function to create a new element. This function will return the id of your element, and create a unique identifier that can be used to modify the properties later. The identifier is in the form GROUP_PT_NAME, where group is the name of the mod or script (or just anything unique, like your username), and name is the name of the element. For example, elements.allocate("mymod", "virus") would create the identifier MYMOD_PT_VIRUS.<br />
<br />
The identifier is added as a constant in the elements table, so elements.MYMOD_PT_VIRUS would be equivalent to the new element's id, and can be used as the elementID argument to any of the functions below.<br />
<br />
The new element is created with all the default properties, and won't be visible until you modify it to show up in the menu.<br />
<br />
Returns -1 on failure (there are no free spaces to create a new element).<br />
<br />
=== elements.free === <br />
elements.free(number elementID)<br />
Free a previously allocated element, so it will disappear from the game. The element id will be freed and can used later by another script. elementID must be a non-default element (i.e you cannot free the default WATR element)<br />
<br />
=== elements.loadDefault ===<br />
elements.loadDefault()<br />
Resets all elements to the original state. This will also erase any elements created with any scripts, only the default elements will be available.<br />
<br />
elements.loadDefault(number elementID)<br />
Reset an element to its original state before it was modified<br />
<br />
=== elements.element ===<br />
table elements.element(number elementID)<br />
Returns a table containing all of an element's properties (Name, Description, etc)<br />
<br />
elements.element(number elementID, table properties)<br />
Sets the properties from the given table onto the element.<br />
<br />
These two functions are useful for copying or templating from already present elements, for example<br />
<syntaxhighlight lang="lua"><br />
local myNewElement = elements.allocate("wiki", "expl")<br />
elements.element(myNewElement, elements.element(elements.DEFAULT_PT_WATR))<br />
elements.property(myNewElement, "Name", "EXPL")<br />
elements.property(myNewElement, "Description", "This is an example element from the Wiki")<br />
</syntaxhighlight><br />
In this example, the element properties for our new element (EXPL) are copied from WATR<br />
<br />
<syntaxhighlight lang="lua"><br />
local star = elements.allocate("ELEMENT", "STAR")<br />
elements.element(star, elements.element(elements.DEFAULT_PT_DMND))<br />
elements.property(star, "Name", "STAR")<br />
elements.property(star, "Description", "STAR. Enough Pressure Makes It Explode Into LAVA.")<br />
elements.property(star, "Colour", 0xFFFFFF)<br />
elements.property(star, "MenuSection", elem.SC_SOLIDS)<br />
elements.property(star, "HotAir", -0.009)<br />
elements.property(star, "Weight", 333)<br />
elements.property(star, "Temperature", 4556)<br />
elements.property(star, "HighPressure", 200)<br />
elements.property(star, "HighPressureTransition", elements.DEFAULT_PT_LAVA)<br />
local function graphics1(i, colr, colg, colb) <br />
return 1,ren.FIRE_ADD,255,100,155,210,255,255,255,255<br />
end<br />
tpt.graphics_func(graphics1, star)<br />
</syntaxhighlight><br />
Another Example, from an actual script. For more info on graphics functions, see the legacy api page<br />
<br />
=== elements.property ===<br />
object elements.property(number elementID, string property)<br />
Gets the value of an element property<br />
<br />
elements.property(number elementID, string property, object value)<br />
Sets the value of an element property<br />
<br />
== Properties ==<br />
After creating an element, you can modify many properties. Be sure to at a minimum set set Name, Description, Color, MenuVisible, and MenuSection. <br />
<br />
For more information on what properties there are to use in elements.property, and how to use them, see this page: [[Element_Properties]]<br />
<br />
<br />
"Update" and "Graphics" are special properties, these can be used to set the update functions or graphics functions. Use a function as the value of the property to set. They are not included in the tables created with elements.element, and the functions can't be returned with elements.property either. This means copying all of an elements properties using elements.element will not set these two for the new element. For example:<br />
<br />
local function funcUpdate(i,x,y,s,nt)<br />
<br />
end<br />
<br />
local function funcGraphics(i, colr, colg, colb)<br />
<br />
end<br />
<br />
elements.property(ELEM, "Update", funcUpdate) <br />
elements.property(ELEM, "Graphics", funcGraphics)<br />
<br />
== Constants ==<br />
Any of these constants can be accessed with elements.<constant name here><br />
<br />
=== Element identifiers ===<br />
All of the default element identifiers are prefixed with <code>DEFAULT_PT_</code>, for example, the identifier for WATR is <code>DEFAULT_PT_WATR</code>. Do not assume all elements identifiers are the same as their names, TNT has the identifier BANG, for example. To find an elements identifier, you can check the source file for any given element in <tt>src/simulation/elements/</tt>.<br />
<br />
=== States ===<br />
There are just 3 constants for element state (Used in the "State" property of elements)<br />
; ST_NONE<br />
: Used by some "unusual" elements such as Photons<br />
; ST_SOLID<br />
; ST_LIQUID<br />
; ST_GAS<br />
These values do not alter the physical properties of elements, but instead are used internally for identification. Powders use the solid state.<br />
<br />
=== Properties ===<br />
More info on the properties can be found here: [[Element_Properties]]<br />
; TYPE_PART<br />
; TYPE_LIQUID<br />
; TYPE_GAS<br />
; TYPE_SOLID<br />
; TYPE_ENERGY<br />
; PROP_CONDUCTS<br />
; PROP_BLACK<br />
; PROP_NEUTPENETRATE<br />
; PROP_NEUTABSORB<br />
; PROP_NEUTPASS<br />
; PROP_DEADLY<br />
; PROP_HOT_GLOW<br />
; PROP_LIFE<br />
; PROP_RADIOACTIVE<br />
; PROP_LIFE_DEC<br />
; PROP_LIFE_KILL<br />
; PROP_LIFE_KILL_DEC<br />
; PROP_SPARKSETTLE<br />
; PROP_NOAMBHEAT<br />
; PROP_DRAWONCTYPE <br />
; PROP_NOCTYPEDRAW <br />
<br />
=== Menu sections ===<br />
These are used for the menusection property<br />
; SC_WALL<br />
; SC_ELEC<br />
; SC_POWERED<br />
; SC_SENSOR<br />
; SC_FORCE<br />
; SC_EXPLOSIVE<br />
; SC_GAS<br />
; SC_LIQUID<br />
; SC_POWDERS<br />
; SC_SOLIDS<br />
; SC_NUCLEAR<br />
; SC_SPECIAL<br />
; SC_LIFE<br />
; SC_TOOL<br />
; SC_DECO<br />
SC_CRACKER and SC_CRACKER2 are not accessible from lua or in the game, but have id numbers of 15 and 16<br />
<br />
=== Flags ===<br />
set in parts[i].flags<br />
; FLAG_STAGNANT<br />
: Used by liquids and powders to speed up simulation by moving them less<br />
; FLAG_SKIPMOVE<br />
: Given to PHOT by PLCN and PBCN to fix gaps in lasers, only useable by energy particles<br />
; FLAG_WATEREQUAL<br />
: Used internally for water equalization<br />
; FLAG_MOVABLE<br />
: Can be used to re-enable moving sponge<br />
; FLAG_PHOTDECO<br />
: Re-enables deco on photons for compatibility. Defined as the same value as FLAG_MOVABLE (they only apply to different elements)<br />
<br />
[[Category:Lua]]</div>ChargedCreeperhttp://powdertoy.co.uk/Wiki/index.php?title=Lua_API:Elements&diff=5581Lua API:Elements2015-05-04T15:50:12Z<p>ChargedCreeper: /* Properties */</p>
<hr />
<div>The Elements API Methods and constants for modifying and creating elements. If you want to add an update function or graphics function, see the Legacy API, specifically the functions tpt.element_func and tpt.graphics_func<br />
== Methods ==<br />
<br />
=== elements.allocate === <br />
number elements.allocate(string group, string name)<br />
Use this function to create a new element. This function will return the id of your element, and create a unique identifier that can be used to modify the properties later. The identifier is in the form GROUP_PT_NAME, where group is the name of the mod or script (or just anything unique, like your username), and name is the name of the element. For example, elements.allocate("mymod", "virus") would create the identifier MYMOD_PT_VIRUS.<br />
<br />
The identifier is added as a constant in the elements table, so elements.MYMOD_PT_VIRUS would be equivalent to the new element's id, and can be used as the elementID argument to any of the functions below.<br />
<br />
The new element is created with all the default properties, and won't be visible until you modify it to show up in the menu.<br />
<br />
Returns -1 on failure (there are no free spaces to create a new element).<br />
<br />
=== elements.free === <br />
elements.free(number elementID)<br />
Free a previously allocated element, so it will disappear from the game. The element id will be freed and can used later by another script. elementID must be a non-default element (i.e you cannot free the default WATR element)<br />
<br />
=== elements.loadDefault ===<br />
elements.loadDefault()<br />
Resets all elements to the original state. This will also erase any elements created with any scripts, only the default elements will be available.<br />
<br />
elements.loadDefault(number elementID)<br />
Reset an element to its original state before it was modified<br />
<br />
=== elements.element ===<br />
table elements.element(number elementID)<br />
Returns a table containing all of an element's properties (Name, Description, etc)<br />
<br />
elements.element(number elementID, table properties)<br />
Sets the properties from the given table onto the element.<br />
<br />
These two functions are useful for copying or templating from already present elements, for example<br />
<syntaxhighlight lang="lua"><br />
local myNewElement = elements.allocate("wiki", "expl")<br />
elements.element(myNewElement, elements.element(elements.DEFAULT_PT_WATR))<br />
elements.property(myNewElement, "Name", "EXPL")<br />
elements.property(myNewElement, "Description", "This is an example element from the Wiki")<br />
</syntaxhighlight><br />
In this example, the element properties for our new element (EXPL) are copied from WATR<br />
<br />
<syntaxhighlight lang="lua"><br />
local star = elements.allocate("ELEMENT", "STAR")<br />
elements.element(star, elements.element(elements.DEFAULT_PT_DMND))<br />
elements.property(star, "Name", "STAR")<br />
elements.property(star, "Description", "STAR. Enough Pressure Makes It Explode Into LAVA.")<br />
elements.property(star, "Colour", 0xFFFFFF)<br />
elements.property(star, "MenuSection", elem.SC_SOLIDS)<br />
elements.property(star, "HotAir", -0.009)<br />
elements.property(star, "Weight", 333)<br />
elements.property(star, "Temperature", 4556)<br />
elements.property(star, "HighPressure", 200)<br />
elements.property(star, "HighPressureTransition", elements.DEFAULT_PT_LAVA)<br />
local function graphics1(i, colr, colg, colb) <br />
return 1,ren.FIRE_ADD,255,100,155,210,255,255,255,255<br />
end<br />
tpt.graphics_func(graphics1, star)<br />
</syntaxhighlight><br />
Another Example, from an actual script. For more info on graphics functions, see the legacy api page<br />
<br />
=== elements.property ===<br />
object elements.property(number elementID, string property)<br />
Gets the value of an element property<br />
<br />
elements.property(number elementID, string property, object value)<br />
Sets the value of an element property<br />
<br />
== Properties ==<br />
After creating an element, you can modify many properties. Be sure to at a minimum set set Name, Description, Color, MenuVisible, and MenuSection. <br />
<br />
For more information on what properties there are to use in elements.property, and how to use them, see this page: [[Element_Properties]]<br />
<br />
<br />
"Update" and "Graphics" are special properties, these can be used to set the update functions or graphics functions. Use a function as the value of the property to set. They are not included in the tables created with elements.element, and the functions can't be returned with elements.property either. This means copying all of an elements properties using elements.element will not set these two for the new element. For example:<br />
<br />
local function funcUpdate(i,x,y,s,nt)<br />
<br />
end<br />
<br />
local function funcGraphics(i, colr, colg, colb)<br />
<br />
end<br />
<br />
elements.property(ELEM, "Update", funcUpdate)<br />
<br />
elements.property(ELEM, "Graphics", funcGraphics)<br />
<br />
== Constants ==<br />
Any of these constants can be accessed with elements.<constant name here><br />
<br />
=== Element identifiers ===<br />
All of the default element identifiers are prefixed with <code>DEFAULT_PT_</code>, for example, the identifier for WATR is <code>DEFAULT_PT_WATR</code>. Do not assume all elements identifiers are the same as their names, TNT has the identifier BANG, for example. To find an elements identifier, you can check the source file for any given element in <tt>src/simulation/elements/</tt>.<br />
<br />
=== States ===<br />
There are just 3 constants for element state (Used in the "State" property of elements)<br />
; ST_NONE<br />
: Used by some "unusual" elements such as Photons<br />
; ST_SOLID<br />
; ST_LIQUID<br />
; ST_GAS<br />
These values do not alter the physical properties of elements, but instead are used internally for identification. Powders use the solid state.<br />
<br />
=== Properties ===<br />
More info on the properties can be found here: [[Element_Properties]]<br />
; TYPE_PART<br />
; TYPE_LIQUID<br />
; TYPE_GAS<br />
; TYPE_SOLID<br />
; TYPE_ENERGY<br />
; PROP_CONDUCTS<br />
; PROP_BLACK<br />
; PROP_NEUTPENETRATE<br />
; PROP_NEUTABSORB<br />
; PROP_NEUTPASS<br />
; PROP_DEADLY<br />
; PROP_HOT_GLOW<br />
; PROP_LIFE<br />
; PROP_RADIOACTIVE<br />
; PROP_LIFE_DEC<br />
; PROP_LIFE_KILL<br />
; PROP_LIFE_KILL_DEC<br />
; PROP_SPARKSETTLE<br />
; PROP_NOAMBHEAT<br />
; PROP_DRAWONCTYPE <br />
; PROP_NOCTYPEDRAW <br />
<br />
=== Menu sections ===<br />
These are used for the menusection property<br />
; SC_WALL<br />
; SC_ELEC<br />
; SC_POWERED<br />
; SC_SENSOR<br />
; SC_FORCE<br />
; SC_EXPLOSIVE<br />
; SC_GAS<br />
; SC_LIQUID<br />
; SC_POWDERS<br />
; SC_SOLIDS<br />
; SC_NUCLEAR<br />
; SC_SPECIAL<br />
; SC_LIFE<br />
; SC_TOOL<br />
; SC_DECO<br />
SC_CRACKER and SC_CRACKER2 are not accessible from lua or in the game, but have id numbers of 15 and 16<br />
<br />
=== Flags ===<br />
set in parts[i].flags<br />
; FLAG_STAGNANT<br />
: Used by liquids and powders to speed up simulation by moving them less<br />
; FLAG_SKIPMOVE<br />
: Given to PHOT by PLCN and PBCN to fix gaps in lasers, only useable by energy particles<br />
; FLAG_WATEREQUAL<br />
: Used internally for water equalization<br />
; FLAG_MOVABLE<br />
: Can be used to re-enable moving sponge<br />
; FLAG_PHOTDECO<br />
: Re-enables deco on photons for compatibility. Defined as the same value as FLAG_MOVABLE (they only apply to different elements)<br />
<br />
[[Category:Lua]]</div>ChargedCreeperhttp://powdertoy.co.uk/Wiki/index.php?title=Lua_API:Elements&diff=5580Lua API:Elements2015-05-04T15:48:59Z<p>ChargedCreeper: /* Properties */</p>
<hr />
<div>The Elements API Methods and constants for modifying and creating elements. If you want to add an update function or graphics function, see the Legacy API, specifically the functions tpt.element_func and tpt.graphics_func<br />
== Methods ==<br />
<br />
=== elements.allocate === <br />
number elements.allocate(string group, string name)<br />
Use this function to create a new element. This function will return the id of your element, and create a unique identifier that can be used to modify the properties later. The identifier is in the form GROUP_PT_NAME, where group is the name of the mod or script (or just anything unique, like your username), and name is the name of the element. For example, elements.allocate("mymod", "virus") would create the identifier MYMOD_PT_VIRUS.<br />
<br />
The identifier is added as a constant in the elements table, so elements.MYMOD_PT_VIRUS would be equivalent to the new element's id, and can be used as the elementID argument to any of the functions below.<br />
<br />
The new element is created with all the default properties, and won't be visible until you modify it to show up in the menu.<br />
<br />
Returns -1 on failure (there are no free spaces to create a new element).<br />
<br />
=== elements.free === <br />
elements.free(number elementID)<br />
Free a previously allocated element, so it will disappear from the game. The element id will be freed and can used later by another script. elementID must be a non-default element (i.e you cannot free the default WATR element)<br />
<br />
=== elements.loadDefault ===<br />
elements.loadDefault()<br />
Resets all elements to the original state. This will also erase any elements created with any scripts, only the default elements will be available.<br />
<br />
elements.loadDefault(number elementID)<br />
Reset an element to its original state before it was modified<br />
<br />
=== elements.element ===<br />
table elements.element(number elementID)<br />
Returns a table containing all of an element's properties (Name, Description, etc)<br />
<br />
elements.element(number elementID, table properties)<br />
Sets the properties from the given table onto the element.<br />
<br />
These two functions are useful for copying or templating from already present elements, for example<br />
<syntaxhighlight lang="lua"><br />
local myNewElement = elements.allocate("wiki", "expl")<br />
elements.element(myNewElement, elements.element(elements.DEFAULT_PT_WATR))<br />
elements.property(myNewElement, "Name", "EXPL")<br />
elements.property(myNewElement, "Description", "This is an example element from the Wiki")<br />
</syntaxhighlight><br />
In this example, the element properties for our new element (EXPL) are copied from WATR<br />
<br />
<syntaxhighlight lang="lua"><br />
local star = elements.allocate("ELEMENT", "STAR")<br />
elements.element(star, elements.element(elements.DEFAULT_PT_DMND))<br />
elements.property(star, "Name", "STAR")<br />
elements.property(star, "Description", "STAR. Enough Pressure Makes It Explode Into LAVA.")<br />
elements.property(star, "Colour", 0xFFFFFF)<br />
elements.property(star, "MenuSection", elem.SC_SOLIDS)<br />
elements.property(star, "HotAir", -0.009)<br />
elements.property(star, "Weight", 333)<br />
elements.property(star, "Temperature", 4556)<br />
elements.property(star, "HighPressure", 200)<br />
elements.property(star, "HighPressureTransition", elements.DEFAULT_PT_LAVA)<br />
local function graphics1(i, colr, colg, colb) <br />
return 1,ren.FIRE_ADD,255,100,155,210,255,255,255,255<br />
end<br />
tpt.graphics_func(graphics1, star)<br />
</syntaxhighlight><br />
Another Example, from an actual script. For more info on graphics functions, see the legacy api page<br />
<br />
=== elements.property ===<br />
object elements.property(number elementID, string property)<br />
Gets the value of an element property<br />
<br />
elements.property(number elementID, string property, object value)<br />
Sets the value of an element property<br />
<br />
== Properties ==<br />
After creating an element, you can modify many properties. Be sure to at a minimum set set Name, Description, Color, MenuVisible, and MenuSection. <br />
<br />
For more information on what properties there are to use in elements.property, and how to use them, see this page: [[Element_Properties]]<br />
<br />
<br />
"Update" and "Graphics" are special properties, these can be used to set the update functions or graphics functions. Use a function as the value of the property to set. They are not included in the tables created with elements.element, and the functions can't be returned with elements.property either. This means copying all of an elements properties using elements.element will not set these two for the new element. For example:<br />
<br />
local function funcUpdate(i,x,y,s,nt)<br />
<br />
end<br />
<br />
local function funcGraphics(i, colr, colg, colb)<br />
<br />
end<br />
<br />
<br />
elements.property(ELEM, "Update", funcUpdate)<br />
<br />
elements.property(ELEM, "Graphics", funcGraphics)<br />
<br />
== Constants ==<br />
Any of these constants can be accessed with elements.<constant name here><br />
<br />
=== Element identifiers ===<br />
All of the default element identifiers are prefixed with <code>DEFAULT_PT_</code>, for example, the identifier for WATR is <code>DEFAULT_PT_WATR</code>. Do not assume all elements identifiers are the same as their names, TNT has the identifier BANG, for example. To find an elements identifier, you can check the source file for any given element in <tt>src/simulation/elements/</tt>.<br />
<br />
=== States ===<br />
There are just 3 constants for element state (Used in the "State" property of elements)<br />
; ST_NONE<br />
: Used by some "unusual" elements such as Photons<br />
; ST_SOLID<br />
; ST_LIQUID<br />
; ST_GAS<br />
These values do not alter the physical properties of elements, but instead are used internally for identification. Powders use the solid state.<br />
<br />
=== Properties ===<br />
More info on the properties can be found here: [[Element_Properties]]<br />
; TYPE_PART<br />
; TYPE_LIQUID<br />
; TYPE_GAS<br />
; TYPE_SOLID<br />
; TYPE_ENERGY<br />
; PROP_CONDUCTS<br />
; PROP_BLACK<br />
; PROP_NEUTPENETRATE<br />
; PROP_NEUTABSORB<br />
; PROP_NEUTPASS<br />
; PROP_DEADLY<br />
; PROP_HOT_GLOW<br />
; PROP_LIFE<br />
; PROP_RADIOACTIVE<br />
; PROP_LIFE_DEC<br />
; PROP_LIFE_KILL<br />
; PROP_LIFE_KILL_DEC<br />
; PROP_SPARKSETTLE<br />
; PROP_NOAMBHEAT<br />
; PROP_DRAWONCTYPE <br />
; PROP_NOCTYPEDRAW <br />
<br />
=== Menu sections ===<br />
These are used for the menusection property<br />
; SC_WALL<br />
; SC_ELEC<br />
; SC_POWERED<br />
; SC_SENSOR<br />
; SC_FORCE<br />
; SC_EXPLOSIVE<br />
; SC_GAS<br />
; SC_LIQUID<br />
; SC_POWDERS<br />
; SC_SOLIDS<br />
; SC_NUCLEAR<br />
; SC_SPECIAL<br />
; SC_LIFE<br />
; SC_TOOL<br />
; SC_DECO<br />
SC_CRACKER and SC_CRACKER2 are not accessible from lua or in the game, but have id numbers of 15 and 16<br />
<br />
=== Flags ===<br />
set in parts[i].flags<br />
; FLAG_STAGNANT<br />
: Used by liquids and powders to speed up simulation by moving them less<br />
; FLAG_SKIPMOVE<br />
: Given to PHOT by PLCN and PBCN to fix gaps in lasers, only useable by energy particles<br />
; FLAG_WATEREQUAL<br />
: Used internally for water equalization<br />
; FLAG_MOVABLE<br />
: Can be used to re-enable moving sponge<br />
; FLAG_PHOTDECO<br />
: Re-enables deco on photons for compatibility. Defined as the same value as FLAG_MOVABLE (they only apply to different elements)<br />
<br />
[[Category:Lua]]</div>ChargedCreeperhttp://powdertoy.co.uk/Wiki/index.php?title=Talk:Lua_API:Elements&diff=5579Talk:Lua API:Elements2015-05-04T15:45:57Z<p>ChargedCreeper: </p>
<hr />
<div>You do not have to use the legacy API for an update function. Same for the graphics function.<br />
<br />
local function funcUpdate(i,x,y,s,nt)<br />
<br />
end<br />
<br />
local function funcGraphics(i, colr, colg, colb)<br />
<br />
end<br />
<br />
<br />
<br />
elements.property(ELEM, "Update", funcUpdate)<br />
<br />
elements.property(ELEM, "Graphics", funcGraphics)<br />
<br />
--[[User:ChargedCreeper|ChargedCreeper]] 16:26, 4 May 2015 (BST)</div>ChargedCreeperhttp://powdertoy.co.uk/Wiki/index.php?title=Talk:Lua_API:Elements&diff=5578Talk:Lua API:Elements2015-05-04T15:45:34Z<p>ChargedCreeper: </p>
<hr />
<div>You do not have to use the legacy API for an update function. Same for the graphics function.<br />
<br />
local function funcUpdate(i,x,y,s,nt)<br />
<br />
end<br />
<br />
local function funcGraphics(i, colr, colg, colb)<br />
<br />
end<br />
elements.property(ELEM, "Update", funcUpdate)<br />
<br />
elements.property(ELEM, "Graphics", funcGraphics)<br />
<br />
--[[User:ChargedCreeper|ChargedCreeper]] 16:26, 4 May 2015 (BST)</div>ChargedCreeperhttp://powdertoy.co.uk/Wiki/index.php?title=Talk:Lua_API:Elements&diff=5577Talk:Lua API:Elements2015-05-04T15:29:15Z<p>ChargedCreeper: almost forgot params</p>
<hr />
<div>You do not have to use the legacy API for an update function. Same for the graphics function.<br />
<br />
local function funcUpdate(i,x,y,s,nt)<br />
<br />
end<br />
<br />
local function funcGraphics(i, colr, colg, colb)<br />
<br />
end<br />
elements.property(ELEM, "Update", funcUpdate)<br />
elements.property(ELEM, "Graphics", funcGraphics)<br />
<br />
--[[User:ChargedCreeper|ChargedCreeper]] 16:26, 4 May 2015 (BST)</div>ChargedCreeperhttp://powdertoy.co.uk/Wiki/index.php?title=Talk:Lua_API:Elements&diff=5576Talk:Lua API:Elements2015-05-04T15:26:01Z<p>ChargedCreeper: Enter a short summary [alt-b]</p>
<hr />
<div>You do not have to use the legacy API for an update function. Same for the graphics function.<br />
<br />
local function funcUpdate(i,x,y,s,nt)<br />
<br />
end<br />
<br />
local function funcGraphics()<br />
<br />
end<br />
elements.property(ELEM, "Update", funcUpdate)<br />
elements.property(ELEM, "Graphics", funcGraphics)<br />
<br />
--[[User:ChargedCreeper|ChargedCreeper]] 16:26, 4 May 2015 (BST)</div>ChargedCreeper