PDA

View Full Version : ActorByName stupid question


frantic69
09-20-2012, 06:31 PM
Hello,

This question, I am sure, is going to be stupid but I can't my error so I would like yout help.

I just want to do something very simple. I have a basic mission. Two aircraft. One spitfire is the player aicraft. the second one is an AI aircraft.

I just want to show on the screen the IAS of the AI aircraft. I tryed this code but it doesn't work :


AiActor actor1 = GamePlay.gpActorByName("0:BoB_RAF_F_111Sqn_Early.000");
actor1AC = (AiAircraft)actor1;

I_VelocityIAS = actor1AC.getParameter(part.ParameterTypes.I_Veloci tyIAS, -1);
GamePlay.gpHUDLogCenter(I_VelocityIAS.ToString("0.00"));


Here is the information of the mission file :

[PARTS]
core.100
bob.100
[MAIN]
MAP Land$English_Channel_1940
BattleArea 150000 100000 100000 150000 1000
TIME 12
WeatherIndex 0
CloudsHeight 1000
BreezeActivity 10
ThermalActivity 10
player BoB_RAF_F_FatCat_Early.010
[GlobalWind_0]
Power 3.000 0.000 0.000
BottomBound 0.00
TopBound 1500.00
GustPower 5
GustAngle 45
[splines]
[AirGroups]
BoB_RAF_F_111Sqn_Early.01
BoB_RAF_F_FatCat_Early.02
[BoB_RAF_F_111Sqn_Early.01]
Flight0 1
Class Aircraft.SpitfireMkIIa
Formation VIC3
CallSign 30
Fuel 100
Weapons 1
Skill 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3
[BoB_RAF_F_111Sqn_Early.01_Way]
NORMFLY 223611.44 219441.60 500.00 300.00
NORMFLY 224401.69 221617.65 600.00 300.00
NORMFLY 226420.38 223833.00 800.00 300.00
NORMFLY 227804.64 224893.02 900.00 300.00
NORMFLY 228776.17 226076.11 900.00 300.00
NORMFLY 228164.13 227020.51 900.00 300.00
NORMFLY 226536.33 228066.96 900.00 300.00
NORMFLY 223687.67 227233.68 1000.00 330.00
NORMFLY 222253.65 223435.46 1200.00 350.00
NORMFLY 220974.66 211982.69 500.00 300.00
[BoB_RAF_F_FatCat_Early.02]
Flight1 11
Class Aircraft.SpitfireMkIIa
Formation VIC3
CallSign 26
Fuel 100
Weapons 1
Skill 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3
[BoB_RAF_F_FatCat_Early.02_Way]
NORMFLY 223596.35 219416.27 500.00 300.00
[CustomChiefs]
[Stationary]
[Buildings]
[BuildingsLinks]

As you can see, the AI aircraft is from the 111 suadron. It ID in the mission file is BoB_RAF_F_111Sqn_Early.01. If I am not wrong, the name to put in the script is a bit different : 0:BoB_RAF_F_111Sqn_Early.000

But, it doesn't work. Could you tell me if you have any idea. Either by modifiying my code or if you have any code that works.

Thank you

salmo
09-20-2012, 07:53 PM
It looks to me as though your assigning aircraft "0:BoB_RAF_F_111Sqn_Early.0 00" as actor1 but the aircraft in the mission is "BoB_RAF_F_111Sqn_Early.01". A line like this might help overcome the actor numbering issue:

AiActor actor1 = GamePlay.gpActorByName("0:BoB_RAF_F_111Sqn_Early.1 00");

frantic69
09-20-2012, 08:19 PM
Hello Salmo,

This is strange but I saw somewhere on internet that the name found in the mission file is not exactly the name you have to put in the script :

http://forum.sturmovik.de/index.php?topic=938.0

000 means the first group and 001 is the second in this group, 002 the third and so on.

010 means the second group and 011 is the second in this group and 0012 the third and so on

So, according to the fact that there is only one aircraft in the BoB_RAF_F_111Sqn_Early group, I thnik the Actorname should be "0:BoB_RAF_F_111Sqn_Early.000"

But is doen't work :!:

FG28_Kodiak
09-20-2012, 09:47 PM
You mistake is not the actorname, its correct, but you used

(part.ParameterTypes.I_VelocityIAS, -1);


you must use

(part.ParameterTypes.Z_VelocityIAS, -1);


BTW. The simplest way to get the actorname is in game external view, right click -> enable show object names.

podvoxx
09-21-2012, 05:00 AM
You mistake is not the actorname, its correct, but you used

(part.ParameterTypes.I_VelocityIAS, -1);


you must use

(part.ParameterTypes.Z_VelocityIAS, -1);


BTW. The simplest way to get the actorname is in game external view, right click -> enable show object names.

Parameters info:
http://www.sukhoi.ru/forum/showthread.php?t=68629&p=1896460&viewfull=1#post1896460

/// [Misc.: Machine Spatial Coordinates]
/// <para>Indicates machine position in world coordinates.</para>
/// <para>Subtype 0 shows X-coordinate;</para>
/// <para>Subtype 1 shows Y-coordinate;</para>
/// <para>Subtype 2 shows Z-coordinate.</para>
/// </summary>
Z_Coordinates,
/// <summary>
/// [Misc.: Machine Spatial Orientation]
/// <para>Indicates machine orientation, angles are in degrees.</para>
/// <para>Subtype 0 shows yaw (0 degrees point E);</para>
/// <para>Subtype 1 shows pitch (nose-up is negative);</para>
/// <para>Subtype 2 shows roll (right roll is positive).</para>
/// </summary>
Z_Orientation,
/// <summary>
/// [Misc.: Machine Overload under Acceleration]
/// <para>Indicates overload in m/s/s.</para>
/// <para>Generic subtype (-1) shows accelerometer, being 0 under normal conditions;</para>
/// <para>Subtype 0 shows acceleraton along machine's X axis;</para>
/// <para>Subtype 1 shows acceleraton along machine's Y axis;</para>
/// <para>Subtype 2 shows acceleraton along machine's Z axis.</para>
/// </summary>
Z_Overload,
/// <summary>
/// [Misc.: Machine Altitude AGL]
/// <para>Indicates machine elevation above ground level in meters.</para>
/// </summary>
Z_AltitudeAGL,
/// <summary>
/// [Misc.: Machine Altitude MSL]
/// <para>Indicates machine elevation above 0.0 Z-plane.</para>
/// </summary>
Z_AltitudeMSL,
/// <summary>
/// [Misc.: Machine's Velocity in Air]
/// <para>Indicates machine's aerial velocity.</para>
/// <para>Generic subtype (-1) shows velocity length;</para>
/// <para>Subtype 0 shows aerial flow along machine's X-axis;</para>
/// <para>Subtype 1 shows aerial flow along machine's Y-axis;</para>
/// <para>Subtype 2 shows aerial flow along machine's Z-axis.</para>
/// </summary>
Z_VelocityIAS,
/// <summary>
/// [Misc.: Machine's Velocity in World Coordinates]
/// <para>Indicates machine's absolute velocity.</para>
/// <para>Generic subtype (-1) shows velocity length;</para>
/// <para>Subtype 0 shows machine's speed along world's X-coordinate;</para>
/// <para>Subtype 1 shows machine's speed along world's Y-coordinate;</para>
/// <para>Subtype 2 shows machine's speed along world's Z-coordinate.</para>
/// </summary>
Z_VelocityTAS,
/// <summary>
/// [Misc.: Machine's Mach Factor]
/// <para>Indicates machine's aerial velocity devided by sonic speed.</para>
/// <para>Generic subtype (-1) shows velocity length;</para>
/// <para>Subtype 0 shows aerial flow along machine's X-axis;</para>
/// <para>Subtype 1 shows aerial flow along machine's Y-axis;</para>
/// <para>Subtype 2 shows aerial flow along machine's Z-axis.</para>
/// </summary>
Z_VelocityMach,
/// <summary>
/// [Misc.: Ambient Temperature]
/// <para>Indicates air temperature around machine's location, in K.</para>
/// </summary>
Z_AmbientAirTemperature,

frantic69
09-21-2012, 02:22 PM
hello guys,

Thank you very much for your help.

You are right Kodiak (one more time :)). This is not my instrument that I want to see but the AI instrument. So, I changed the I to Z and it works.

Thanks again,