Forum

> > CS2D > Scripts > tile(x/32,y/32,'walkable) error
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

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

14 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

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

kalis
User Off Offline

Zitieren
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 --

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

kalis
User Off Offline

Zitieren
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

alt Comment

buraxia3
User Off Offline

Zitieren
I was know those sins, cosses 2 month ago
1× editiert, zuletzt 07.09.11 14:11:52

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

DannyDeth
User Off Offline

Zitieren
@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.

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

Apache uwu
User Off Offline

Zitieren
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.

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

kalis
User Off Offline

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

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

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

kalis
User Off Offline

Zitieren
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 =.=

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

DC
Admin Off Offline

Zitieren
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.

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

Bowlinghead
User Off Offline

Zitieren
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).
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht