Forum

> > CS2D > Scripts > tile(x/32,y/32,'walkable) error
Forums overviewCS2D overview Scripts overviewLog in to reply

English tile(x/32,y/32,'walkable) error

14 replies
To the start Previous 1 Next To the start

old tile(x/32,y/32,'walkable) error

kalis
User Off Offline

Quote
hey guys
i going to make new lua and post in unrealsoftware
but i got error
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
npc = {}

npc.x = (map('xsize')*32) / 2
npc.y = (map('ysize')*32) / 2
npc.img = image('gfx/sprites/flare3.bmp',npc.x,npc.y,1)
npc.times = 0
npc.rot = 0


addhook("second","times")
function times()
	if npc.times > 0 then
		npc.times = npc.times - 1
	end
	if npc.times == nil then
		npc.times = 0
	end
end



addhook("always","move")
function move()
	if npc.img ~= 0 then
		if npc.times == 0 then
			if npc.rot < 360 then
				npc.rot = npc.rot + 1
			elseif npc.rot > 360 then
				npc.rot = npc.rot - 360
			end
			local rot = math.rad(npc.rot - 180)
	                	npc_x = npc.x - math.sin(rot) * math.random(1,3)
        	  	 	npc_y = npc.y + math.cos(rot) * math.random(1,3)
        	  	 		if tile(npc.x/32,npc.y/32,'walkable') then
        	  	 			if npc_x < map('xsize')*32 and npc_y < map('ysize')*32 then
							npc.x = npc_x
							npc.y = npc_y
						end	
					else
						rot2 = math.rad(npc.rot + 180)
	                			npc.x = npc.x - math.sin(rot2) * 16
						npc.y = npc.y + math.sin(rot2) * 16
        	  	 		end
						imagepos(npc.img,npc.x,npc.y,rot)
		end
	end
end

---how to set my image to go orther way ? ---
---when it went on wall --

old Re: tile(x/32,y/32,'walkable) error

kalis
User Off Offline

Quote
no my code work
but when it on wall
car.x and car.y ( cant run )
how to ? make car.x + car.y run orther street ?
i have some problem with my ENG

old Comment

buraxia3
User Off Offline

Quote
I was know those sins, cosses 2 month ago
edited 1×, last 07.09.11 02:11:52 pm

old Re: tile(x/32,y/32,'walkable) error

DannyDeth
User Off Offline

Quote
@Factis:
Sinus = part of the upper respiratory system.
Sine = trigonometric function usually abbreviated to 'sin'

Cosinus = Non-existent word, AFAIK
Cosine = trigonometric function usually abbrevviated to 'cos'

Next, to address Kalis' problem... could you please explain EXACTLY what you want to do, write carefully and use your full vocabualry, it's extremely hard to understand what you are saying.

EDIT: floor your x/32 and y/32 so that they are exact tile values, that may be the problem.. though I'm not sure what you really are talking about.

old Re: tile(x/32,y/32,'walkable) error

Apache uwu
User Off Offline

Quote
HAHAHA lol @ spelling fail


It's actually pretty funny when you see 2 people with grammar problems.

I think the solution is to use negative angles. I'm not sure may have to edit this post but images are -180-0-180, not 0-360. I'm not sure.

old Re: tile(x/32,y/32,'walkable) error

kalis
User Off Offline

Quote
i check idea of text tual
lol it worked
thank text tual

ok how i can make health of env_NPC ?
with lua/script
edited 2×, last 08.09.11 09:26:03 am

old Re: tile(x/32,y/32,'walkable) error

kalis
User Off Offline

Quote
hey guys
when spawn NPC
sometimes ,cant spawn NPC
because near wall
but it give me a lot of spam on console
how to turn off spam ?

spam :
1
ERROR : spawnobject - wrong tile properties

And i dont want spawn NPC out map =.=

old Re: tile(x/32,y/32,'walkable) error

DC
Admin Off Offline

Quote
read the error message. wrong tile properties. this means that the tile at this position is not suitable for NPCs.

simply don't try to spawn NPCs on walls/obstacles/deadly tiles! it doesn't work.

old Re: tile(x/32,y/32,'walkable) error

Bowlinghead
User Off Offline

Quote
May you can add this:
1
if tile(x,y,"walkable") and tile(x,y,"frame")>=1 then

If its walkable (No Walls/Obstacles/Dyn Walls) and if the frame is 1 or higher (it means, if there is nothing (background) then there spawn nothing).
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview