Forum

> > CS2D > Scripts > setpos *32+16
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch setpos *32+16

8 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt setpos *32+16

Dynamite07
User Off Offline

Zitieren
1
2
3
4
5
6
addhook("movetile","no_move")
function no_move(id,x,y)
	if tile(x, y, 'frame') == 25 then -- 25 = tile
               parse('setpos '..id..' '..x*32+16 ..' '..y*32+16)
          end
end
Yoo all.
x/y*32+16 -- I think it would be normal if this teleport me back, but this teleport me to the center of the tile, can anyone say me why plz?

alt Re: setpos *32+16

Alistaire
User Off Offline

Zitieren
1
2
3
4
5
6
addhook("movetile","no_move")
function no_move(id,x,y)
	if tile(x, y, 'frame') == 25 then -- 25 = tile
               parse('setpos '..id..' '..x*32+16 ..' '..y*32+16)
          end
end

x = tilex position
x * 32 = tile's start in pixels
x * 32 + 16 = tile's center in pixels

You should make it a move hook, not a movetile hook;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function array(v)
	local a = {}
	for k = 1, 32 do
		a[k] = v
	end
	return a;
end

plr = {}
plr.x = array(0)
plr.y = array(0)

addhook('move', '_moveFunc')

function _moveFunc(id, x, y)
	local tilex = math.floor(x / 32)
	local tiley = math.floor(y / 32)
	if tile(tilex, tiley, 'frame') == 25 then
		parse('setpos '..id..' '..plr.x[id]..' '..plr.y[id])
	end
	plr.x[id] = x
	plr.y[id] = y
end

alt Re: setpos *32+16

Yates
Reviewer Off Offline

Zitieren
One tile is 32 by 32 pixels. So if you teleport yourself to a tile and add 16 pixels you will be in the middle of the tile. Seems obvious.

alt Re: setpos *32+16

Alistaire
User Off Offline

Zitieren
user Dynamite07 hat geschrieben
not a error, is like you are being teleported to the place where you are walking, is weird


Then why the fuck do you say it doesn't work.
Also, what is this script supposed to do? Teleport people away from tile 25, right?
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht