This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

A way to skip parameters in method

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Locked
jamisco
Superfighter
Superfighter
Posts: 67
Joined: Sun Nov 06, 2016 11:34 pm
Title: Da God
SFD Account: Jamisco
SFD Alias: Jamisco
Started SFD: either late 2015 or early 2016
Location: Somewhere in the east of the United states
Gender:
Age: 105

A way to skip parameters in method

Post by jamisco » Tue Jul 18, 2017 10:55 pm

take the method .. Player.AddCommand(new PlayerCommand(CommandType, TargetbjectID, delayTime))
say i want to input just commandtype and the delay time, how would i skip the TargetObjectID?
0 x
Is it better to be feared or respected... please, is it too much to ask for both?

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 27

Post by JakSparro98 » Wed Jul 19, 2017 9:29 pm

jamisco wrote:
Tue Jul 18, 2017 10:55 pm
take the method .. Player.AddCommand(new PlayerCommand(CommandType, TargetbjectID, delayTime))
say i want to input just commandtype and the delay time, how would i skip the TargetObjectID?
Player Command has many constructors, their parameters cannot be bypassed but you can fill some with useless data, if for instance i use the one with PlayerCommand (PlayerCommandType action, Vector2 worldPosition, Int delayTime = 0) I will fill like that:
player.AddCommand(new PlayerCommand(PlayerCommandType.WaitLand,Vector2.Zero,20000));

Normally WaitLand doesn't use Vector2 type, so I guess this parameter will be ignored.
1 x

jamisco
Superfighter
Superfighter
Posts: 67
Joined: Sun Nov 06, 2016 11:34 pm
Title: Da God
SFD Account: Jamisco
SFD Alias: Jamisco
Started SFD: either late 2015 or early 2016
Location: Somewhere in the east of the United states
Gender:
Age: 105

Post by jamisco » Thu Jul 20, 2017 4:09 am

i see, so how would you by pass target object id
0 x
Is it better to be feared or respected... please, is it too much to ask for both?

kirill240
Fighter
Fighter
Posts: 18
Joined: Mon Jan 09, 2017 1:01 pm
SFD Account: Mr.A woman's heart

Post by kirill240 » Sun Jul 23, 2017 12:17 pm

jamisco wrote:
Thu Jul 20, 2017 4:09 am
i see, so how would you by pass target object id
If the TargetObjectID command does not affect the result of execution, then write any (better than 0) or use null
1 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Thu Aug 03, 2017 4:10 pm

The PlayerCommand has several constructor overloads. Use the most appropriate one. Sending in the wrong parameters won't do anything if it can't be applicable.

Code: Select all

/*
 // Example use:
 IPlayer player = Game.CreatePlayer(Vector2.Zero);
 player.AddCommand(new PlayerCommand(PlayerCommandType.StartMoveToPosition, new Vector2(100f, 0f))); // player will start to move to world position X = 100
 player.AddCommand(new PlayerCommand(PlayerCommandType.Walk)); // player will walk instead of run
 player.AddCommand(new PlayerCommand(PlayerCommandType.WaitDestinationReached)); // wait for destination reached
 player.AddCommand(new PlayerCommand(PlayerCommandType.Jump, PlayerCommandFaceDirection.Left)); // jump after destination reached and face left
 player.AddCommand(new PlayerCommand(PlayerCommandType.WaitLand)); // wait to land after jump
 player.AddCommand(new PlayerCommand(PlayerCommandType.Dive, PlayerCommandFaceDirection.Left)); // dive to the left
 // other actions
 player.AddCommand(new PlayerCommand(PlayerCommandType.StartTakeCover, Game.GetSingleObjectByCustomID("BarrelWithCustomID").UniqueID)); // take cover behind object with custom ID "BarrelWithCustomID" (this also makes the player move to the cover if the player is too far away).
 player.AddCommand(new PlayerCommand(PlayerCommandType.DrawHandgun)); // draws the handgun slot if the player has a handgun
 player.AddCommand(new PlayerCommand(PlayerCommandType.StartCrouch)); // makes the player start crouching (until PlayerCommandType.StopCrouch is called)
*/
2 x
Gurt

Locked