Forum

> > CS2D > Scripts > How to creat unwalkable tiles?
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to creat unwalkable tiles?

6 replies
To the start Previous 1 Next To the start

old How to creat unwalkable tiles?

if
User Off Offline

Quote
Like when player walks onto tile id 23,
the player returns 1.
Like tibia's water.
1
2
3
function walkable(x, y, safe, water)
	return tile(x, y, 'walkable') and (water or tile(x, y, 'frame') ~= 34) and not (safe and gettile(x, y).SAFE)
end
Don't know how it works.

---
And what is the code to make a text show on the screem without fading
edited 1×, last 16.09.11 07:06:10 pm

old Re: How to creat unwalkable tiles?

Cure Pikachu
User Off Offline

Quote
Maybe something like this, I never took the time to test it:
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
function checkwalkableframe(x,y,f)
	if tile(x,y,"walkable") and tile(x,y,"frame") == f then
		return 1
	end
	return 0
end

function initArray(m,v)
	local array = {}
	for i = 1, m do
		array[m] = v
	end
	return array
end

lastx = initArray(32,0)
lasty = initArray(32,0)

addhook("leave","resetvars")
function resetvars(i)
	lastx[i] = 0
	lasty[i] = 0
end

addhook("move","teleback")
function teleback(id,x,y)
	if checkwalkableframe(x,y,23) == 1 then
		parse("setpos "..id.." "..lastx[id].." "..lasty[id])
	else
		lastx[id] = x
		lasty[id] = y
	end
end
edited 1×, last 23.09.23 06:02:41 pm

old Re: How to creat unwalkable tiles?

if
User Off Offline

Quote
The last 4 th line has error.
table index is nil.

I just need to know how to make player return to his previous pos.
edited 2×, last 17.09.11 07:22:05 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview