-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
243 lines (208 loc) · 11.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<!DOCTYPE html>
<html>
<head>
<title>PT element derp</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<h1>Powder Toy element coder v 1.1 </h1>
// Create your own elements by copy/pasting the code below.
// Provides skeleton code and a few snippets.
// Write values to all the bright blue stuff.
// by boxmein - <a href="http://powdertoy.co.uk">Powder Toy</a> - <a href="http://powdertoy.co.uk/Wiki/W/Coding-tutorial.html">Coding tutorial</a> - <a href="http://tpt.io/@boxmein">Contact</a> - <a href="about.html">About</a> - <a href="http://github.com/boxmein/TPTElements/">on GitHub</a>
// <a href="index.html">C++ version</a> - <a href="#">Lua version</a> - <a href="c/">C version</a> - <a href="reference.html">Reference</a> - <a href="lua/lua-reference.html">Lua reference</a>
// Copy/paste everything after this after coding.
<div class="aside">- - Options - -
<a onclick="toggleComments()" href="javascript:void(0);">- Toggle comments</a>
<a onclick="clearCode()" href="javascript:void(0);">- Empty the code boxes</a>
<a onclick="chAllToName()" href="javascript:void(0);">- "BCOL" --> your element's name</a>
<a onclick="save()" href="javascript:void(0);">- Download</a>
<a href="#">- To the top!</a>
</div><div id="fullcode">
<i>// src/simulation/elements/<elementname>.cpp:</i>
#include "simulation/Elements.h"
//#TPT-Directive ElementClass Element_<b>BCOL</b> PT_<b>BCOL</b> <b>73</b>
Element_<b>BCOL</b>::Element_<b>BCOL</b>()
{
Identifier = "<b>DEFAULT_PT_BCOL</b>"; <i>// Element's name on the new lua API - it is best you leave it as such.</i>
Name = "<b id="elname">BCOL</b>"; <i>// Element's in-game name. (4 letters!). Write the NAME here to use for replacement.</i>
<i>// If you change this Name and this name ONLY, click the "BCOL ---> your element's name" button to change the rest</i>
Colour = PIXPACK(0x<b>333333</b>); <i>// Element's colour in hexadecimal. (Bits: RRGGBB)</i>
MenuVisible = <b>1</b>; <i>// Whether or not it's in a menu.</i>
MenuSection = SC_<b>POWDERS</b>; <i>// Which menu it's in.</i>
Enabled = <b>1</b>; <i>// Whether or not it's even enabled. Keep as 1 unless you have a good reason.</i>
Advection = <b>0.4f</b>; <i>// How much moving air / wind affects it. </i>
AirDrag = <b>0.04f</b> * CFDS; <i>// How much air the particle "drags" along with it. </i>
AirLoss = <b>0.94f</b>; <i>// How much it slows down moving air. 1 for no effect, 0 for full effect.</i>
Loss = <b>0.95f</b>; <i>// How much speed the particle loses every frame. 1 = no loss. 0.5 = half loss.</i>
Collision = <b>-0.1f</b>; <i>// When this particle hits something, this value is used to determine new velocity.</i>
Gravity = <b>0.3f</b>; <i>// How fast the particle falls. Negative means it floats. </i>
Diffusion = <b>0.00f</b>; <i>// How much the particle wiggles like GAS.</i>
HotAir = <b>0.000f</b> * CFDS; <i>// How much the particle increases pressure. </i>
Falldown = <b>1</b>; <i>// How does this particle move? (0 = solid. 1 = powder. 2 = liquid) </i>
Flammable = <b>0</b>; <i>// How much this particle burns. (0 = not at all. >0 = burns more.) </i>
Explosive = <b>0</b>; <i>// Does the particle explode? (0 = no. 1 = only with fire. 2 = with pressure > 2.5 or fire.)</i>
Meltable = <b>5</b>; <i>// Does it melt? (0 = no. 1 = yes)</i>
Hardness = <b>2</b>; <i>// How much acid affects the particle. (0 = not at all. >0 = more corrodable)</i>
Weight = <b>90</b>; <i>// Particle weight. Determines which sinks below which.
//(1 = gas. 2 = light. 0-49 = liquids. 50-99 = powders. 100 = solid. -1 for energy.)</i>
Temperature = <b>R_TEMP+0.0f</b> +273.15f; <i>// How hot does it spawn with? Automatically converted to Celsius. R_TEMP is 22.00° C</i>
HeatConduct = <b>150</b>; <i>// How well it transfers heat. (0 = badly. 255 = very very well) </i>
Description = "<b>Broken Coal. Heavy particles. See COAL</b>"; <i>// Element description. Is shown when mouse hovers over element.</i>
State = ST_<b>SOLID</b>; <i>// Which state the element is in. (ST_NONE = Special. ST_SOLID = Solid. ST_LIQUID = Liquid. ST_GAS = Gas.)</i>
Properties = <b>TYPE_PART</b>; <i>// Element properties. See <a href="http://tpt.io/.213774">this</a> for details.</i>
<i>// These next ones use a few special values.
// IPL = Impossible Pressure Low - use it to disable element transitions with low pressure.
// IPH = Impossible Pressure High - use it to disable element transitions with high pressure.
// NT = No Type - use it as a dummy if you don't have a transition with that value.
// ITL = Impossible Temperature Low - use it to disable element transitions with low temperature.
// ITH = Impossible Temperature High - use it to disable element transitions with high temperature.</i>
LowPressure = <b>IPL</b>; <i>// How low should pressure be to trigger a transition? (It can be any number from -255 to 255)</i>
LowPressureTransition = <b>NT</b>; <i>// What to transition to when pressure is lower than LowPressure?</i>
HighPressure = <b>IPH</b>; <i>// How high should pressure be to trigger a transition? (It can be any number from -255 to 255)</i>
HighPressureTransition = <b>NT</b>; <i>// What to transition to when pressure is higher than HighPressure?</i>
LowTemperature = <b>ITL</b>; <i>// How low should temp be to trigger a transition? (It can be any number from 0 to 10000)</i>
LowTemperatureTransition = <b>NT</b>; <i>// What to transition to when temp is lower than LowTemperature? </i>
HighTemperature = <b>ITH</b>; <i>// How high should temp be to trigger a transition? (It can be any number from 0 to 10000)</i>
HighTemperatureTransition = <b>NT</b>; <i>// What to transition to when temp is higher than HighTemperature?</i>
Update = &Element_<b>BCOL</b>::update; <i>// The name of the updating function. Change BCOL to what your element's Name is.</i>
Graphics = &Element_<b>BCOL</b>::graphics; <i>// The name of the graphics function. Change BCOL to what your element's Name is.</i>
<i>// Photon wavelengths are ANDed with this value when a photon hits an element,
// meaning that only wavelengths present in both this value and the original photon will remain in the reflected photon.
// Simply put, the color of the photon bouncing off, or what color to add to it.</i>
PhotonReflectWavelengths = <b>0x3FFFFFFF</b>;
}
<i>
/*
Keep in mind that:
#define UPDATE_FUNC_ARGS Simulation* sim, int i, int x, int y, int surround_space, int nt, Particle *parts, int pmap[YRES][XRES]
#define UPDATE_FUNC_SUBCALL_ARGS sim, i, x, y, surround_space, nt, parts, pmap
#define GRAPHICS_FUNC_ARGS Renderer * ren, Particle *cpart, int nx, int ny, int *pixel_mode, int* cola, int *colr, int *colg,
int *colb, int *firea, int *firer, int *fireg, int *fireb
#define GRAPHICS_FUNC_SUBCALL_ARGS ren, cpart, nx, ny, pixel_mode, cola, colr, colg, colb, firea, firer, fireg, fireb
#define BOUNDS_CHECK true
*/
</i>
//#TPT-Directive ElementHeader Element_<b>BCOL</b> static int update(UPDATE_FUNC_ARGS)
int Element_<b>BCOL</b>::update(UPDATE_FUNC_ARGS) <i>// Here starts the function that all reactions and movement should be in.</i>
{
<b class="code">int r, rx, ry, trade, temp;
if (parts[i]>=0) {
sim->create_part(i, x, y, PT_FIRE);
return 1;
} else if (parts[i].life < 100) {
parts[i].life--;
sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE);
}
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500))
{
if (parts[i].life>100) {
parts[i].life = 99;
}
}
if ((r&0xFF)==PT_LAVA && 1>(rand()%500))
{
if (parts[r>>8].ctype == PT_IRON) {
parts[r>>8].ctype = PT_METL;
sim->kill_part(i);
return 1;
}
}
}
/*if(100-parts[i].life > parts[i].tmp2)
parts[i].tmp2 = 100-parts[i].life;
if(parts[i].tmp2 < 0) parts[i].tmp2 = 0;
for ( trade = 0; trade<4; trade ++)
{
rx = rand()%5-2;
ry = rand()%5-2;
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion
{
int temp = parts[i].tmp2 - parts[r>>8].tmp2;
if(temp < 10)
continue;
if (temp ==1)
{
parts[r>>8].tmp2 ++;
parts[i].tmp2 --;
}
else if (temp>0)
{
parts[r>>8].tmp2 += temp/2;
parts[i].tmp2 -= temp/2;
}
}
}
}*/
if(parts[i].temp > parts[i].tmp2)
parts[i].tmp2 = parts[i].temp;
return 0;
</b>
}
//#TPT-Directive ElementHeader Element_<b>BCOL</b> static int graphics(GRAPHICS_FUNC_ARGS)
int Element_<b>BCOL</b>::graphics(GRAPHICS_FUNC_ARGS) <i>// Here starts the function all graphics and looks should be in.</i>
{
<b class="code">
*colr += (cpart->tmp2-295.15f)/3;
if (*colr > 170)
*colr = 170;
if (*colr < *colg)
*colr = *colg;
*colg = *colb = *colr;
if((cpart->temp-295.15f) > 300.0f-200.0f)
{
float frequency = 3.1415/(2*300.0f-(300.0f-200.0f));
int q = ((cpart->temp-295.15f)>300.0f)?300.0f-(300.0f-200.0f):(cpart->temp-295.15f)-(300.0f-200.0f);
*colr += sin(frequency*q) * 226;
*colg += sin(frequency*q*4.55 +3.14) * 34;
*colb += sin(frequency*q*2.22 +3.14) * 64;
}
return 0;
</b>
}
Element_<b>BCOL</b>::~Element_<b>BCOL</b>() {}
<i>/* When you can't use generator.py,
here are the lines to manually copy to ElementClasses.cpp and ElementClasses.h:
(Make sure to paste them into appropriate places - order probably matters for the
elements.push_back line, but not for the ElementClasses.h lines!)
*/
// Into ElementClasses.h:
</i>
#define PT_<b>BCOL</b> <b>73</b>
class Element_<b>BCOL</b> : public Element
{
public:
Element_<b>BCOL</b>();
virtual ~Element_<b>BCOL</b>();
static int update(UPDATE_FUNC_ARGS);
};
<i>// Into ElementClasses.cpp (into the vector definition): </i>
elements.push_back(Element_<b>BCOL</b>());
</div>
<script src="js/jquery-1.9.0.min.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-34425443-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script src="js/script.js"></script>
<script>initAll();</script>
</body>
</html>