Forum

> > CS2D > Scripts > Make a players walk reverse
Forums overviewCS2D overview Scripts overviewLog in to reply

English Make a players walk reverse

4 replies
To the start Previous 1 Next To the start

old Make a players walk reverse

Promaster
User Off Offline

Quote
I need help with creating a curse that make a player walk reverse. Like when they want to walk up, they walks down, and instead of down they are walking up. the same goes for left and right.
edited 1×, last 14.09.17 02:06:35 am

old Re: Make a players walk reverse

Ajmin
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
posx={}

addhook("join","_j")
function _j(id)
posx[id]={}
posx[id][1]=1
end

addhook("move","_m")
function _m(id,x,y)
table.insert(posx[id],x)
local lol = x-10
if posx[id][#posx[id]]>posx[id][#posx[id]-1] then
parse("setpos "..id.." "..lol.." "..y.."")
end
end


With 1 condition which will make the player move left when he is trying to move right. Add more conditions. Laggy maybe.

old Re: Make a players walk reverse

Promaster
User Off Offline

Quote
@user Ajmin: Thank you for the answer. To be honest with you, i do not understand the why you did

1
if posx[id][#posx[id]]>posx[id][#posx[id]-1] then

Can you please add the rest condition for me.

old Re: Make a players walk reverse

Ajmin
User Off Offline

Quote
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
posx={}
posy={}

addhook("join","_j")
function _j(id)
posx[id]={}
posy[id]={}
posx[id][1]=1
posy[id][1]=1
end

addhook("move","_m")
function _m(id,x,y)
table.insert(posx[id],x)
table.insert(posy[id],y)
local nq = x-10
local sq = x+10
if posy[id][#posy[id]]==posy[id][#posy[id]-1] then
	if posx[id][#posx[id]]>posx[id][#posx[id]-1] then
		table.insert(posx[id],nq)
		parse("setpos "..id.." "..nq.." "..y.."")
	else
		table.insert(posx[id],sq)
	parse("setpos "..id.." "..sq.." "..y.."")
	end
end
local mm = y-10
local em = y+10
if posx[id][#posx[id]]==posx[id][#posx[id]-1] then
	if posy[id][#posy[id]]>posy[id][#posy[id]-1] then
		table.insert(posy[id],mm)
		parse("setpos "..id.." "..x.." "..mm.."")
	else
		table.insert(posy[id],em)
	parse("setpos "..id.." "..x.." "..em.."")
	end
end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview