Forum

> > CS2D > Scripts > Paint Lua Error(Making)
Forums overviewCS2D overview Scripts overviewLog in to reply

English Paint Lua Error(Making)

17 replies
To the start Previous 1 Next To the start

old Paint Lua Error(Making)

kalis
User Off Offline

Quote
why error =.=
i dont know
attaempt to call a nil value

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--paint-----
---cz2d.forumtl.com---
--lua by kalis --


function Array(size,value)
	local array = {}
	for i = 1, size do
		array[i]=value
	end
	return array
end


paint = Array(32,0)
image_paint = Array(32,0)

function paintmenu(id)
	menu(id,"Menu Paint,Paint,Off Paint")
end

addhook("serveraction","action")
function action(id,a)
	if a == 1 then
		menu(id,"Menu Paint,Paint,Off Paint")
	end
end


addhook("menu","menupaint")
function menupaint(id,title,key)
	if title == "Menu Paint" then
		if key == 1 then
			if paint[id] == 0 then 
				msg2(id,"You Can Paint Now, Run = Paint!")
				paint[id]=1
			end
		elseif key == 2 then
			if paint[id]==1 then
				paint[id] = 0
				msg2(id,"Paint is close!")
			end
	
		end
		return 1
	end
end

addhook("move","startpain")
function startpaint(id,x,y)
r = math.random(1,255)
b = math.random(1,255)
g = math.random(1,255)
color = math.random(1,2)
image_paint[id] = image("gfx/sprites/dark.bmp",x,y,0)
	if paint[id]==1 then 
		if color == 1 then 
			imagecolor(image_paint[id],r,b,g) 
		end
		if color == 2 then 
			imagecolor(image_paint[id],r,b,g) 
		end
	end
end
help pls

old Re: Paint Lua Error(Making)

DannyDeth
User Off Offline

Quote
It always gives the line number, and I can assure you, if you had made many Lua scripts and were actually experienced you wouldn't have to ask for help in such a simple script. And it should also tell you which variable/array/function is nil. Now just give the variable/array/function name or give the line number, sheesh, this is really simple stuff.

old Re: Paint Lua Error(Making)

gUtZ
User Off Offline

Quote
I think I found the source of this problem.

1
2
addhook("move","startpain")
function startpaint(id,x,y)

Change "startpain" to "startpaint".

old Re: Paint Lua Error(Making)

kalis
User Off Offline

Quote
cool thanks it small error
thanks men

hey all i want to know

imagescale(id,x,y)          Changes image scale factors (in other words: the image size)

i will add imagescale(id,x,y,s)
"s" is size?
edited 1×, last 10.05.11 07:17:19 am

old Re: Paint Lua Error(Making)

DannyDeth
User Off Offline

Quote
@Heocon:
S is scale. Not size. What this is, can be said:
1 = 100% of image size ( normal size )
2 = 200% of image size ( double size )
0.5 = 50% of image size ( half size )

And so the list goes on.

old Re: Paint Lua Error(Making)

kalis
User Off Offline

Quote
hey
you can help me ?

make size of image

     if title == "Menu Paint" and player(id,"health")>0 then
          if key == 1 then
and msg2(id,"write x and y of image")
this is scale x and y
and image will spawn with sizex~ sizey

old Re: Paint Lua Error(Making)

DannyDeth
User Off Offline

Quote
Wait...
Imagescale doesn't work like that Sorry, my mistake. ( but you kinda caused the error, to be honest ).

Imagescale works by inputting an x and y value, which the image is sized to. My bad.

old Re: Paint Lua Error(Making)

kalis
User Off Offline

Quote
why i see in RPG tibia lua
i can edit size =.= of iamge

ok cant
i going post lua now
make some screen!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview