Forum

> > CS2D > Scripts > Roof lua fix.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Roof lua fix.

10 replies
To the start Previous 1 Next To the start

old Roof lua fix.

Mora
User Off Offline

Quote
Hello again us.
I don't remember when and where i take this code, but it's does not works, anyone know why it's?-i don't understand what it's needed.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
imh = {}
iXZone = 5.5 --posx maybe?
iYZone = 5.5 --posy maybe?
iXZoneRange = 5 --wtf this shit?
iYZoneRange = 3 --wtf this shit?

addhook ("startround","st")
function st()
	for i=1,32 do
imh=image("gfx/mora/stone.png",iXZone*32,iYZone*32,1,i)
	end
end

addhook ("movetile","mv")
function mv(id,x,y)
	if ((x>=iXZone) and (x<=(iXZone+iXZoneRange)) and (y>=iYZone) and (y<=(iYZone+iYZoneRange))) then
imagealpha(imh[id],0.5)
	else
imagealpha(imh[id],1.0)
	end
end

st()
It's says:
1
LUA ERROR: sys/lua/555.lua:19: attempt to index global 'imh' (a number value)
Thank you

old Re: Roof lua fix.

Ajmin
User Off Offline

Quote
Wrong:
1
imh=image("gfx/mora/stone.png",iXZone*32,iYZone*32,1,i)

Right:
1
imh[i]=image("gfx/mora/stone.png",iXZone*32,iYZone*32,1,i)

I am not sure if this is the complete error!

old Re: Roof lua fix.

Mora
User Off Offline

Quote
It's works, but this s**t is work so poor.
but it's possible to make it aplha only when i sten on image that are not fill by color? example of my png:
IMG:https://i9.pixs.ru/storage/1/6/9/stonepng_7897278_15979169.png

Where i've step on the image with this stones(as tiles) it's alpha self, but if i come to outside(as tiles) from colored(stone) to full transparent it's gonna alpha self.
edited 2×, last 10.02.15 04:55:21 am

old Re: Roof lua fix.

_oops
User Off Offline

Quote
you remind me my old minecraft cave zone lua script.
I'm too lazy to fix your one, so i just made new one for you (lazy to fix but make new one, seems legit)
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
--[[Cave]]--
cave={}
cave.imgpath={"gfx/Oops321/tiles/image/Cave.png"} -- image path
cave.img={}
cave.pl={}
cave.x={0,24*32} -- cave zone X coordinate (0~768)
cave.y={0,15*32} -- cave zone Y coordinate (0~480)
for id=1,32 do
cave.pl[id]=0;
end

addhook("move","cave_zone")
function cave_zone(id,x,y,m)
	if (player(id,"x")>=cave.x[1] and player(id,"x")<=cave.x[2]) and (player(id,"x")>=cave.y[1] and player(id,"y")<=cave.y[2]) then
	tween_alpha(cave.img[id],500,0.3)
	else
	tween_alpha(cave.img[id],500,1.0)
	end
end

addhook("join","cave_spawn")
function cave_spawn(id)
	if cave.pl[id]==0 then
	timer(1,"loadi")
		function loadi()
		cave.img[id] = image(cave.imgpath[1],0,1,1,id)
		imagepos(cave.img[id],352+48,256,0)
		cave.pl[id]=1
		end
	end
end

addhook("leave","cave_leave")
function cave_leave(id)
cave.pl[id]=0
end

addhook("startround","cave_imgcall")
function cave_imgcall()
	for _,id in pairs(player(0,"table")) do
		if player(id,"exists")==true then
		cave.img[id] = image(cave.imgpath[1],0,1,1,id)
		imagepos(cave.img[id],352+48,256,0)
		cave.pl[id]=1
		end
	end
end

cave_imgcall()

old Re: Roof lua fix.

Mora
User Off Offline

Quote
@user _oops: You did made it from 0? oh really thank you, but how can i add many zones?(if it is possible ofc)

old Re: Roof lua fix.

_oops
User Off Offline

Quote
well currently i have no idea to add more zone with simple and easy way.
1
2
cave.x={{0,16*32},{x*32,x*32}};
cave.y={{0,15*32},{y*32,y*32}};
make 2 dimensional array for x,y coordinates
first coordinate must be less than last coordinate E.g) first x = 12*32(384) last x = 46*32(1472)

and now make if statement on move hook
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("move","cave_zone")
function cave_zone(id,x,y,m)
	if (player(id,"x")>=cave.x[1][1] and player(id,"x")<=cave.x[1][2]) and (player(id,"x")>=cave.y[1][1] and player(id,"y")<=cave.y[1][2]) then
	tween_alpha(cave.img[id],500,0.3)
	elseif (player(id,"x")>=cave.x[2][1] and player(id,"x")<=cave.x[2][2]) and (player(id,"x")>=cave.y[2][1] and player(id,"y")<=cave.y[2][2]) then
	tween_alpha(cave.img[id],500,0.3)
	.
	.
	.
	else
	tween_alpha(cave.img[id],500,1.0)
	end
end

i didn't test it, so i'm not sure this solution will work.

old Re: Roof lua fix.

Mora
User Off Offline

Quote
Thank to all but i'll use my code with @user Ajmin: helps me, no offense @user _oops: but Your code is too hard( for me, my skills is s**t low)

old Re: Roof lua fix.

Ajmin
User Off Offline

Quote
Glad to hear that I helped

Simple error even u may fix it,if u take a detailed look .

old Re: Roof lua fix.

Mora
User Off Offline

Quote
@user Ajmin: I'm not so good at scripting, i know just a bit, but this is a normal for make own admin script/roleplay script. and just using other scripts(was not trashed) as help hints.
So thank you all, sadly that you fcked your freetime @user _oops: , i'm always said don't waste it if you make a big scripts, just say "It's big, hard ...whatever".

old Re: Roof lua fix.

_oops
User Off Offline

Quote
it's not that big and not even hard, also it took 5~10 mins to make.

old Re: Roof lua fix.

Mora
User Off Offline

Quote
@user _oops: Anyway you did take for make it for me!Thank you anyway.

/mods, admins, whoever - close topic please..
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview