Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

SpawnProjectile still expecting "type"

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
TheOriginalCj
Moderator
Moderator
Posts: 177
Joined: Tue Mar 15, 2016 10:28 pm
Title: Lifetime Sentence to SF Wiki
SFD Alias: RedneckJed
Started SFD: PreAlpha 1.1.0
Location: USA
Gender:
Contact:

SpawnProjectile still expecting "type"

Post by TheOriginalCj » Tue Apr 12, 2016 11:40 pm

Written like so:
IObject ratatat = Game.SpawnProjectile(6,LeftNut.GetWorldPosition(), new.Vector2(108));

Column 74 is giving me the Type Expected error (CS1031)

So... Whaddup?
0 x
Superfighters Wiki Founder
The Superfighters Wiki
Join the Wiki!
Danger Ross wrote: What are you doing here wiki-slave?! GET BACK TO WORK!

User avatar
ShutDownMan
Fighter
Fighter
Posts: 32
Joined: Sat Mar 19, 2016 7:17 pm
Title: Yeah, science!
SFD Alias: ShutDownMan, Devil Shut
Started SFD: 1.2.something
Location: Hu3, Brazil
Gender:
Age: 24
Contact:

Post by ShutDownMan » Wed Apr 13, 2016 12:23 am

Simple, this function returns you void and not IObject '-'
0 x
~ShutDownMan

User avatar
TheOriginalCj
Moderator
Moderator
Posts: 177
Joined: Tue Mar 15, 2016 10:28 pm
Title: Lifetime Sentence to SF Wiki
SFD Alias: RedneckJed
Started SFD: PreAlpha 1.1.0
Location: USA
Gender:
Contact:

Post by TheOriginalCj » Wed Apr 13, 2016 2:05 am

ShutDownMan wrote:Simple, this function returns you void and not IObject '-'
The Error is in char 74, not 1. It's still asking for the type.

EDIT: Clarifying the error, it seems to be Vector2 that's sending the error, perhaps it's not compatible in this command?
0 x
Superfighters Wiki Founder
The Superfighters Wiki
Join the Wiki!
Danger Ross wrote: What are you doing here wiki-slave?! GET BACK TO WORK!

User avatar
ShutDownMan
Fighter
Fighter
Posts: 32
Joined: Sat Mar 19, 2016 7:17 pm
Title: Yeah, science!
SFD Alias: ShutDownMan, Devil Shut
Started SFD: 1.2.something
Location: Hu3, Brazil
Gender:
Age: 24
Contact:

Post by ShutDownMan » Wed Apr 13, 2016 3:21 am

Ýeah, I just saw an error before it appeared =P

There's a lot of wrong things there, so I think it's better I show you the right way to set up a SpawnProjectile:
In this example:

Code: Select all

public void ActivateShooter(TriggerArgs args){
	IObject obj01 = Game.GetFirstObject("Object01") as IObject;
	IObject obj02 = Game.GetFirstObject("Object02") as IObject;

	if(obj02 != null){ // if object01 still exists
		Vector2 pos01 = obj01.GetWorldPosition();
		Vector2 pos02 = obj02.GetWorldPosition();

		Vector2 direction = pos02 - pos01;

		Game.SpawnProjectile(ProjectileItem.M60, pos01, direction);
	}

}
You can see that the first argument is put in this way: ProjectileItem.M60
There's no problem if you put ProjectileItem.6, but I find the first way better when debugging code.

The second argument is just the position of the "shooter", and the third argument is the subtraction of the position of the second object from the first one.

Hope I helped, at least a bit.
0 x
~ShutDownMan

User avatar
TheOriginalCj
Moderator
Moderator
Posts: 177
Joined: Tue Mar 15, 2016 10:28 pm
Title: Lifetime Sentence to SF Wiki
SFD Alias: RedneckJed
Started SFD: PreAlpha 1.1.0
Location: USA
Gender:
Contact:

Post by TheOriginalCj » Wed Apr 13, 2016 6:11 am

You didn't only help a bit, you helped alot. Thanks for the help ShutDownMan.

EDIT: As a side note, the Numeric ID for ProjectileItem does not work. You have to use the ID of the weapon.
1 x
Superfighters Wiki Founder
The Superfighters Wiki
Join the Wiki!
Danger Ross wrote: What are you doing here wiki-slave?! GET BACK TO WORK!

chelog
Fighter
Fighter
Posts: 10
Joined: Sun Mar 20, 2016 10:45 am
Title: 0110111101101011
SFD Alias: chelog
Started SFD: The first public version
Location: Saint-Petersburg, Russia
Gender:
Age: 27
Contact:

Post by chelog » Thu Apr 28, 2016 1:04 am

TheOriginalCj wrote:EDIT: As a side note, the Numeric ID for ProjectileItem does not work. You have to use the ID of the weapon.
Shut was a lil' wrong (or he may mistype). Actually, you can use just 6 instead of ProjectileItem.M60. But the thing that if Gurt changes numerical index of projectiles in future, your script may spawn some other projectile instead of M60 one. So you'd better use Enumerations as ShutDownMan said.
1 x

Post Reply