View difference between Paste ID: 6HLTpTNZ and Si0b6t7J
SHOW: | | - or go back to the newest paste.
1
base = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGIJKLMNOPQRSTUVWXYZ"
2
code = "@5313671"
3
adm = "Ninguem" -- mude para seu nick
4
change = false
5
op = -1
6
mirrorX = false
7
mirrorY = false
8
grid = true
9
help = false
10
idSelect = 1
11
idMirror = 2
12
idGrid = 3
13
idGridText = 4
14
idGridOff = 6
15
idHelp = 7
16
idHelpText = 8
17
idSaveText = 9
18
idExitText = 10
19
idInfo = 11
20
popDelete = 12
21
popSave = 13
22
popExit = 14
23
contObject = 0
24
contGround = 0
25
contVamp = 0
26
contDeath = 0
27
contScore = 0
28
contSpawn = 0
29
ground = {type=0,height=16,width=16,color=0,foreground=true}
30
layer = {type=12,height=320,width=640,color=0x6a7495}
31
map = {}
32
for i = 1, 20 do
33
	map[i] = {}
34
	for j = 1, 40 do
35
		map[i][j] = -1
36
	end
37
end
38
39
tfm.exec.disableAfkDeath(true)
40
tfm.exec.disableAutoNewGame(true)
41
tfm.exec.disableAutoShaman(true)
42
tfm.exec.newGame(code)
43
44
function cont()
45
	local warnObject = ""
46
	local warnGround = ""
47
	local warnScore = ""
48
	local warnSpawn = ""
49
	contObject = 0
50
	contGround = 0
51
	contVamp = 0
52
	contDeath = 0
53
	contScore = 0
54
	contSpawn = 0
55
	for i = 1, 20 do
56
		for j = 1, 40 do
57
			if map[i][j] ~= -1 then
58
				contObject = contObject + 1
59
				if map[i][j] >= 0 and map[i][j] <= 8 then
60
					contGround = contGround + 1
61
				elseif map[i][j] == 10 then
62
					contVamp = contVamp + 1
63
				elseif map[i][j] == 11 then
64
					contDeath = contDeath + 1
65
				elseif map[i][j] == 12 then
66
					contScore = contScore + 1
67
				elseif map[i][j] == 13 then
68
					contSpawn = contSpawn + 1
69
				end
70
			end
71
		end
72
	end
73
	if contObject == 0 or contObject > 400 then
74
		warnObject = "<r>"
75
	end
76
	if contGround == 0 then
77
		warnGround = "<r>"
78
	end
79
	if contScore == 0 then
80
		warnScore = "<r>"
81
	end
82
	if contSpawn == 0 then
83
		warnSpawn = "<r>"
84
	end
85
	local info = warnObject.."Objects: "..contObject.."/400\n<n>"..warnGround.."Grounds: "..contGround.."\n<n>Item points: "..contVamp.."\nDeath points: "..contDeath.."\n<n>"..warnScore.."Score points: "..contScore.."\n<n>"..warnSpawn.."Spawn points: "..contSpawn
86
	ui.addTextArea(idInfo, info, nil, 660, 90, 130, 100, 0, 0, 0, false)
87
end
88
89
function generate()
90
	local text = string.format("%03d", contObject)
91
	for i = 1, 20 do
92
		for j = 1, 40 do
93
			if map[i][j] ~= -1 then
94
				text = text .. base:sub(i,i) .. base:sub(j,j) .. base:sub(map[i][j]+1,map[i][j]+1)
95
			end
96
		end
97
	end
98
	print("<j>Paste this XML in Tansformice Map Editor and Export as tribe house.\n<n>&lt;<font size='6px'>\n"..[[C&gt;&lt;P Ca=""H="800"L="1600"Pw="]]..text..[["/&gt;&lt;Z&gt;&lt;S/&gt;&lt;D/&gt;&lt;O/&gt;&lt;/Z&gt;&lt;/C]].."\n</font>&gt;")
99-
	tfm.exec.chatMessage("<j>Paste this XML in Tansformice Map Editor and Export as tribe house.\n<n>&lt;<font size='6px'>\n"..[[C&gt;&lt;P Ca=""H="800"L="1600"Pw="]]..text..[["/&gt;&lt;Z&gt;&lt;S/&gt;&lt;D/&gt;&lt;O/&gt;&lt;/Z&gt;&lt;/C]].."\n</font>&gt;", adm)
99+
100
101
function makeGround(x, y, op)
102
	tfm.exec.addPhysicObject(x*100+y, x*16+2, y*16+22, ground)
103
	map[y][x] = op
104
end
105
106
function eventNewGame()
107
	change = true
108
	tfm.exec.setUIMapName("Editor - " .. adm .. "\n")
109
	ui.addTextArea(idSelect, "", nil, 55, 360, 30, 30, 0, 0xffff00, 0.3, false)
110
	ui.addTextArea(idMirror, "", nil, 495, 360, 30, 30, 0, 0x0000ff, 0.3, false)
111
	ui.addTextArea(idInfo, "<r>Objects: 0/400\nGrounds: 0\n<n>Item points: 0\nDeath points: 0\n<r>Score points: 0\nSpawn points: 0", nil, 660, 90, 130, 100, 0, 0, 0, false)
112
	ui.addTextArea(idGridText, "<p align='center'><font color='#0'><b>Show grid", nil, 660, 30, 130, 20, 0, 0, 0, false)
113
	ui.addTextArea(idGrid, "", nil, 660, 30, 130, 20, 0, 1, 0.3, false)
114
	ui.addTextArea(idHelpText, "<p align='center'><font color='#0'><b>Helper friend", nil, 660, 60, 130, 20, 0, 0, 0, false)
115
	ui.addTextArea(idSaveText, "<p align='center'><font color='#0'><b>Export XML", nil, 660, 345, 130, 20, 0, 0, 0, false)
116
	ui.addTextArea(idExitText, "<p align='center'><font color='#0'><b>Exit the editor", nil, 660, 375, 130, 20, 0, 0, 0, false)
117
	for i, v in pairs(tfm.get.room.playerList) do
118
		system.bindMouse(i, true)
119
		if i ~= adm then
120
			tfm.exec.killPlayer(i)
121
		end
122
	end
123
end
124
125
function eventPopupAnswer(popup, p, a)
126
	if popup == popDelete and a == "yes" then
127
		for i = 1, 20 do
128
			for j = 1, 40 do
129
				map[i][j] = -1
130
				tfm.exec.removePhysicObject(j*100+i)
131
			end
132
		end
133
		cont()
134
	elseif popup == popSave and a == "yes" then
135
		generate()
136
	elseif popup == popExit and a == "yes" then
137
		system.exit()
138
	end
139
end
140
141
function eventMouse(p, x, y)
142
	if p == adm then
143
		if x > 10 and x < 650 and y > 30 and y < 350 then
144
			local xx = math.floor((x-10)/16)+1
145
			local yy = math.floor((y-30)/16)+1
146
			if op == -1 then
147
				tfm.exec.removePhysicObject(xx*100+yy)
148
				map[yy][xx] = op
149
			elseif contObject <= 400 then
150
				if op >= 0 and op <= 8 then
151
					ground.type = op
152
					ground.width = 16
153
					ground.height = 16
154
				else
155
					ground.width = 10
156
					ground.height = 10
157
					ground.type = 12
158
					if op == 10 then
159
						ground.color = 0xFFC300
160
					elseif op == 11 then
161
						ground.color = 0xF93801
162
					elseif op == 12 then
163
						ground.color = 0xFF00DC
164
					elseif op == 13 then
165
						ground.color = 0x78583A
166
					end
167
				end
168
				makeGround(xx, yy, op)
169
				if mirrorX then
170
					makeGround(41-xx, yy, op)
171
				end
172
				if mirrorY then
173
					makeGround(xx, 21-yy, op)
174
				end
175
				if mirrorY and mirrorX then
176
					makeGround(41-xx, 21-yy, op)
177
				end
178
			end
179
		elseif x > 660 and x < 790 then
180
			if y > 30 and y < 50 then
181
				if grid then
182
					grid = false
183
					ui.removeTextArea(idGrid, nil)
184
					tfm.exec.addPhysicObject(idGridOff, 330, 190, layer)
185
				else
186
					grid = true
187
					ui.addTextArea(idGrid, "", nil, 660, 30, 130, 20, 0, 1, 0.3, false)
188
					tfm.exec.removePhysicObject(idGridOff)
189
				end
190
			elseif y > 60 and y < 80 then
191
				if help then
192
					help = false
193
					ui.removeTextArea(idHelp, nil)
194
				else
195
					help = true
196
					ui.addTextArea(idHelp, "", nil, 660, 60, 130, 20, 0, 1, 0.3, false)
197
				end
198
			elseif y > 340 and y < 370 then
199
				if contObject <= 400 and contGround > 0 and contScore > 0 and contSpawn > 0 then
200
					ui.addPopup(popSave, 1, "<p align='center'>Ready for the flood?", adm, 250, 200, 300, true)
201
				else
202
					ui.addPopup(popSave, 0, "<p align='center'>The map can't be so. Look the informations in red.", adm, 250, 200, 300, true)
203
				end
204
			elseif y > 370 and y < 400 then
205
				ui.addPopup(popExit, 1, "<p align='center'>Exit the editor?", adm, 250, 200, 300, true)
206
			end
207
		elseif y > 360 and y < 390 then
208
			if x > 15 and x < 45 then
209
				ui.addPopup(popDelete, 1, "<p align='center'>Delete all objects?", adm, 250, 200, 300, true)
210
			elseif x > 55 and x < 85 then
211
				ui.addTextArea(idSelect, "", nil, 55, 360, 30, 30, 0, 0xffff00, 0.3, false)
212
				op = -1
213
			elseif x > 95 and x < 125 then
214
				ui.addTextArea(idSelect, "", nil, 95, 360, 30, 30, 0, 0xffff00, 0.3, false)
215
				op = 0
216
			elseif x > 135 and x < 165 then
217
				ui.addTextArea(idSelect, "", nil, 135, 360, 30, 30, 0, 0xffff00, 0.3, false)
218
				op = 1
219
			elseif x > 175 and x < 205 then
220
				ui.addTextArea(idSelect, "", nil, 175, 360, 30, 30, 0, 0xffff00, 0.3, false)
221
				op = 2
222
			elseif x > 215 and x < 245 then
223
				ui.addTextArea(idSelect, "", nil, 215, 360, 30, 30, 0, 0xffff00, 0.3, false)
224
				op = 3
225
			elseif x > 255 and x < 285 then
226
				ui.addTextArea(idSelect, "", nil, 255, 360, 30, 30, 0, 0xffff00, 0.3, false)
227
				op = 4
228
			elseif x > 295 and x < 325 then
229
				ui.addTextArea(idSelect, "", nil, 295, 360, 30, 30, 0, 0xffff00, 0.3, false)
230
				op = 8
231
			elseif x > 335 and x < 365 then
232
				ui.addTextArea(idSelect, "", nil, 335, 360, 30, 30, 0, 0xffff00, 0.3, false)
233
				op = 10
234
			elseif x > 375 and x < 405 then
235
				ui.addTextArea(idSelect, "", nil, 375, 360, 30, 30, 0, 0xffff00, 0.3, false)
236
				op = 11
237
			elseif x > 415 and x < 445 then
238
				ui.addTextArea(idSelect, "", nil, 415, 360, 30, 30, 0, 0xffff00, 0.3, false)
239
				op = 12
240
			elseif x > 455 and x < 485 then
241
				ui.addTextArea(idSelect, "", nil, 455, 360, 30, 30, 0, 0xffff00, 0.3, false)
242
				op = 13
243
			elseif x > 495 and x < 525 then
244
				ui.addTextArea(idMirror, "", nil, 495, 360, 30, 30, 0, 0x0000ff, 0.3, false)
245
				mirrorX = false
246
				mirrorY = false
247
			elseif x > 535 and x < 565 then
248
				ui.addTextArea(idMirror, "", nil, 535, 360, 30, 30, 0, 0x0000ff, 0.3, false)
249
				mirrorX = true
250
				mirrorY = false
251
			elseif x > 575 and x < 605 then
252
				ui.addTextArea(idMirror, "", nil, 575, 360, 30, 30, 0, 0x0000ff, 0.3, false)
253
				mirrorX = false
254
				mirrorY = true
255
			elseif x > 615 and x < 645 then
256
				ui.addTextArea(idMirror, "", nil, 615, 360, 30, 30, 0, 0x0000ff, 0.3, false)
257
				mirrorX = true
258
				mirrorY = true
259
			end
260
		end
261
		cont()
262
	elseif help then
263
		tfm.exec.displayParticle(0, x, y, 0, 0, 0, 0, nil)
264
	end
265
end
266
267
function eventLoop(current,remaining)
268
	if not change then
269
		tfm.exec.newGame(code)
270
	end
271
end