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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
addhook("move","_move")
addhook("spawn","_spawn")
addhook("always","_always")
addhook("hit","_hit")
previous={}
direction={}
speed=5
function _spawn(id)
previous[id]={player(id,"x"),player(id,"y")}
direction[id]=nil
	 timer(2700, "timefuncI")
end
function _move(id,x,y)
if x~=previous[id][1] or y~=previous[id][2] then
if x>previous[id][1] then
direction[id]=1
elseif x<previous[id][1] then
direction[id]=0
elseif y>previous[id][2] then
direction[id]=3
elseif y<previous[id][2] then
direction[id]=2
end
parse("speedmod "..id.." -50")
end
previous[id]={x,y}
end
function _always()
for _,id in ipairs(player(0,"tableliving")) do
if direction[id]~=nil then
local x,y=0,0
if direction[id]==0 then
x=-speed
elseif direction[id]==1 then
x=speed
elseif direction[id]==2 then
y=-speed
elseif direction[id]==3 then
y=speed
end
parse("setpos "..id.." "..player(id,"x")+x.." "..player(id,"y")+y)
if x==speed then
x=16
y=0
elseif x==-speed then
x=-16
y=0
end
if y==speed then
y=16
x=0
elseif y==-speed then
y=-16
x=0
end
if tile(math.floor((player(id,"x")+x)/32),math.floor((player(id,"y")+y)/32),"wall") then
parse("setpos "..id.." "..(32*player(id,"tilex")+16).." "..(32*player(id,"tiley")+16))
parse("speedmod "..id.." 0")
direction[id]=nil
previous[id]={player(id,"x"),player(id,"y")}
end
end
end
end
function _hit()
if (source>=1) then
return 1
else
return 0
end
end
function timefuncI()
msg2(id, "©000255000Hello and welcome to our Test Subjects center.")
msg2(id, "©000255000As you may have noted, you can now move in another way.")
end