Forum

> > CS2D > Scripts > Checking the projectile
Forums overviewCS2D overview Scripts overviewLog in to reply

English Checking the projectile

4 replies
To the start Previous 1 Next To the start

old Checking the projectile

Masea
Super User Off Offline

Quote
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.
edited 2×, last 24.10.16 05:46:27 pm

old Re: Checking the projectile

Bowlinghead
User Off Offline

Quote
cs2d lua cmd projectilelist
Quote
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

old Re: Checking the projectile

VADemon
User Off Offline

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

old Re: Checking the projectile

DC
Admin Off Offline

Quote
@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

old Re: Checking the projectile

Masea
Super User Off Offline

Quote
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.
edited 1×, last 22.10.16 04:50:37 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview