Forum

> > CS2D > Scripts > Script wanted!
Forums overviewCS2D overview Scripts overviewLog in to reply

English Script wanted!

5 replies
To the start Previous 1 Next To the start

old Script wanted!

daddy_pro
User Off Offline

Quote
Hello, I am new at lua programming, so, can somebody help me or even write 1 script for me :
I need tile which will trigger smth when player comes close enough to this tile. For exaple, if player within 160 radius then do smth.

Does it requers an extra script file or its possible to do in "IF"-trigger tile?

old Re: Script wanted!

Alistaire
User Off Offline

Quote
user daddy_pro has written
I really need some help.


Professional help, I reckon.

----

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
radiusTable = {
	[1] = {
		x = 160,
		y = 160,
		r = 160,
		t = 'roflolz0r'
	},
	[2] = {
		x = 480,
		y = 320,
		r = 160,
		t = '/TeeHee'
	}
}

addhook('move', 'moveHook')

function moveHook(id, x, y)
	for k, v in pairs(radiusTable) do
		if circleArea(x, y, v.x, v.y, v.r) then
			parse('trigger '..v.t)
		end
	end
end

function circleArea(x,y,cx,cy,r)
     return (x-cx)^2+(y-cy)^2 <= r^2
end
--http://www.unrealsoftware.de/forum_posts.php?post=271595&start=0#post271627

Adjust stuff.
edited 1×, last 04.05.13 04:48:09 pm

old Re: Script wanted!

EngiN33R
Moderator Off Offline

Quote
@user Alistaire: Your code won't work correctly unless you:
1. Change the hook to movetile
2. Change the x and y coordinates in radiusTable to pixels (assuming they aren't at the moment)
Spoiler >

old Re: Script wanted!

daddy_pro
User Off Offline

Quote
Sorry, But my lvl of knowledge is low. I cant repair this script even then I know what's wrong. btw, it's for DayZ mode.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview