i checked mafia man's script but its too complex
Forum
CS2D Scripts Image on wallImage on wall
19 replies 1
i checked mafia man's script but its too complex
Place image entity and set offset Y as 32 (so it's one tile below). Make a name <name> (example 'potato'). Make your breakable entity and in trigger field, enter <name> (in my example it's 'potato')
build
objectkill
edited 1×, last 21.08.14 06:04:56 pm
To easy.
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
img = image("path/of/the/image.png",0,0,0) addhook("build","a") function a(id,t,x,y,mode,oid) 	imagepos(img,x*32+16,y*32+16,0) end addhook("objectkill","b") function b(oid,id) 	freeimage(img) end
This is too simple and probably sucks but you asked how it's done so...
Rainoth has written
That's how build hook works. It proceeds only when you finish building. If you want the image to appear during construction, you need buildattempt hook.
no dude... i have azlready builded walls from map those pics need to get on them in startround
VADemon has written
X-Files again, do you only want images on buildings added with env_building ?
image from map wont work for me for some complex reason i need codes ! and this codes need to go on walls which is already builded, so build or buildattempt hooks wont work for my plan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
img = {} addhook("startround","a") function a(mode) 	local ID = 0 	for x = 0,map("xsize") do 		for y = 0,map("ysize") do 			if tile(x,y,"wall") then 				ID = ID + 1 				img[ID] = image("path/image.png",0,0,0) 				imagepos(img[ID],x*32+16,y*32+16,0) 			end 		end 	end end
add additional checks if you want it to work with breakable entities.
Rainoth has written
add additional checks if you want it to work with breakable entities.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
img = {} addhook("startround","a") function a(mode) 	local ID = 0 	for x = 0,map("xsize") do 		for y = 0,map("ysize") do 			if tile(x,y,"wall") then 				ID = ID + 1 				img[ID] = image("path/image.png",0,0,0) 				imagepos(img[ID],x*32+16,y*32+16,0) 			end 		end 	end end
add additional checks if you want it to work with breakable entities.
its cool but what about removing image ?
im afraid it could remove all images on walls with breakiig one wall
1
2
3
4
2
3
4
addhook("objectkill","b") function b(oid,id) freeimage(img) end
1
2
3
2
3
for i = 1,ID do 	freeimage(img[i]) end
i dont want to remove all
i hope im clear
this code just putting an image on wall now i need to remove that after break
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
img = {} addhook("startround","a") function a(mode) local ID = 0 for x = 0,map("xsize") do for y = 0,map("ysize") do if tile(x,y,"wall") then ID = ID + 1 img[ID] = image("path/image.png",0,0,0) imagepos(img[ID],x*32+16,y*32+16,0) end end end end
What you want is possible, I gave you basic stuff for image handling, now just sort out how to do it with entities.
1