Forum

> > CS2D > Scripts > Image on wall
Forums overviewCS2D overview Scripts overviewLog in to reply

English Image on wall

19 replies
To the start Previous 1 Next To the start

old Image on wall

X-Files
User Off Offline

Quote
is it possible to adding image on wall and removing after break ?
i checked mafia man's script but its too complex

old Re: Image on wall

Rainoth
Moderator Off Offline

Quote
You don't have to do it with lua, you can do it in map editor.
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')

old Re: Image on wall

X-Files
User Off Offline

Quote
alright, but if its not so hard can someone give me an example to do this with codes ?

old Re: Image on wall

XoOt
Super User Off Offline

Quote
Why do you want to script it when it could be easily done in map editor.

old Re: Image on wall

X-Files
User Off Offline

Quote
@user XoOt: its not satisfy exactly what is in my mind, hard to explain and i need codes to do this

old Re: Image on wall

Rainoth
Moderator Off Offline

Quote
1
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...

old Re: Image on wall

Rainoth
Moderator Off Offline

Quote
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.

old Re: Image on wall

X-Files
User Off Offline

Quote
user 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

user VADemon has written
user X-Files again, do you only want images on buildings added with cs2d entity 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

old Re: Image on wall

Rainoth
Moderator Off Offline

Quote
1
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.

old Re: Image on wall

X-Files
User Off Offline

Quote
user Rainoth has written
1
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
addhook("objectkill","b")
function b(oid,id)
     freeimage(img)
end

old Re: Image on wall

Rainoth
Moderator Off Offline

Quote
Nope that won't work. Those walls will be considered a part of map and not entities. What you did by the way is freeimage of a table... which is not an image. It's a table (lol). if you want to free everything, you should do
1
2
3
for i = 1,ID do
	freeimage(img[i])
end

old Re: Image on wall

X-Files
User Off Offline

Quote
@user Rainoth: dude all i need a code which is remove the image of wall after breaking
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
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

old Re: Image on wall

Rainoth
Moderator Off Offline

Quote
You at least tried doing it yourself?
What you want is possible, I gave you basic stuff for image handling, now just sort out how to do it with entities.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview