Forum

> > CS2D > Scripts > Image on wall
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Image on wall

19 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Image on wall

X-Files
User Off Offline

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

alt Re: Image on wall

Rainoth
Moderator Off Offline

Zitieren
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')

alt Re: Image on wall

X-Files
User Off Offline

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

alt Re: Image on wall

XoOt
Super User Off Offline

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

alt Re: Image on wall

Rainoth
Moderator Off Offline

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

alt Re: Image on wall

Rainoth
Moderator Off Offline

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

alt Re: Image on wall

X-Files
User Off Offline

Zitieren
user Rainoth hat geschrieben
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 hat geschrieben
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

alt Re: Image on wall

Rainoth
Moderator Off Offline

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

alt Re: Image on wall

X-Files
User Off Offline

Zitieren
user Rainoth hat geschrieben
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

alt Re: Image on wall

Rainoth
Moderator Off Offline

Zitieren
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

alt Re: Image on wall

X-Files
User Off Offline

Zitieren
@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

alt Re: Image on wall

Rainoth
Moderator Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht