Forum

> > CS2D > Scripts > Checking the projectile
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Checking the projectile

4 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Checking the projectile

Masea
Super User Off Offline

Zitieren
Hello there. I'm going to show my another problem then I'll want to hear how can I fix it from you guys. Thanks in advance.

What am I trying to do is; before checking if there isn't any flare on the elected place, then I'm spawning a flare on the coordinates where I checked. With this script, I will achieve of making a light entity without using map editor by Lua. I know, the flare's light effect is red but who cares, screw it!

1
2
3
4
for a,b in pairs(projectilelist(1,0)) do
	if projectile(b.id,1,"exists") and projectile(b.id,1,"x") == v[3]*32+16 and projectile(b.id,1,"y") == v[4]*32+16 and projectile(b.id,1,"type") == 54 then return end
end
parse("spawnprojectile 1 54 "..(v[3]*32+16).." "..(v[4]*32+16).." 1 0")

However, since I was not laboring with this kind stuff, I couldn't do this.

Here are my questions:
1
for a,b in pairs(projectilelist(1,0)) do
• Does it check the only dropped projectiles? I mean, the projectiles which are on the ground, not the flying ones.

• The code itself doesn't work. The command works perfect though, but the above does not.

I hope you understand me and will help me as a good guy.
2× editiert, zuletzt 24.10.16 17:46:27

alt Re: Checking the projectile

Bowlinghead
User Off Offline

Zitieren
cs2d lua cmd projectilelist
Zitat
Attention: There can be multiple projectiles with the same ID (each player has its own projectile ID-space)! That's why you have to specify the ID and the player because only the combination of those two values is unique and therefore suited to address a certain unique projectile

I think you missed a
1
player(b.player,"exists") == true

alt Re: Checking the projectile

VADemon
User Off Offline

Zitieren
A glaring flare doesn't seem to be anywhere: cs2d lua cmd projectilelist cs2d lua cmd closeobjects cs2d lua cmd closeitems don't return anything.
It's only shown as projectile WHILE it's flying to the destination, once dropped and glowing it's removed from the list.

My testing code >

alt Re: Checking the projectile

DC
Admin Off Offline

Zitieren
@user VADemon: There are 2 lists for projectiles: Flying (0) and ground (1). It's the first parameter of cs2d lua cmd projectilelist. Read the reference for details.

Getting the flare on the ground works fine if you change line 7 of your test code so it gets the ground list instead of the flying projectile list
for k,proj in pairs(projectilelist(1, pid)) do

alt Re: Checking the projectile

Masea
Super User Off Offline

Zitieren
Thank you guys but eventually, I fixed it myself

My code is completely true and was working well. Excuse me, but if you guys didn't see, there is something wrong thingy as well as it's true;
1
projectile(b.id,1,"x") == v[3]*32+16 and projectile(b.id,1,"y") == v[4]*32+16
It could work but since while I'm using the spawnprojectile command which increases projectile's coordinates through it's rotation when you did use flydistance parameter for at least 1. So If I would show that variables as a number then it would be like that;
1
231 == 230 and 171 == 170
That means it shouldn't work.

By then, I changed the code and made it more evident.
1
math.floor(projectile(b.id,1,"x")/32) == v[3] and math.floor(projectile(b.id,1,"y")/32) == v[4]

Finally, it works now.
1× editiert, zuletzt 22.10.16 16:50:37
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht