Table of Contents

Class CmdArgs

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll

The arguments from a client or sever command

public class CmdArgs
Inheritance
CmdArgs
Inherited Members
Extension Methods

Constructors

CmdArgs()

Creates a new instance of the CmdArgs util with no arguments

public CmdArgs()

CmdArgs(string)

Creates a new instance of the CmdArgs util

public CmdArgs(string joinedargs)

Parameters

joinedargs string

CmdArgs(string[])

Creates a new instance of the CmdArgs util

public CmdArgs(string[] args)

Parameters

args string[]

Properties

this[int]

Returns the n-th arugment

public string this[int index] { get; set; }

Parameters

index int

Property Value

string

Length

Amount of arguments passed

public int Length { get; }

Property Value

int

Methods

AppendSingle(string)

Adds an arg to the end

public void AppendSingle(string arg)

Parameters

arg string

Clone()

public CmdArgs Clone()

Returns

CmdArgs

PeekChar(char?)

Returns the first char of the first argument

public char? PeekChar(char? defaultValue = null)

Parameters

defaultValue char?

Returns

char?

PeekWord(string)

Removes the first argument and returns it

public string PeekWord(string defaultValue = null)

Parameters

defaultValue string

Returns

string

PopAll()

Returns all remaining arguments as single merged string, concatenated with spaces

public string PopAll()

Returns

string

PopBool(bool?, string)

Tries to retrieve arg at given index as boolean, or null if not enough arguments or not an integer
'true', 'yes' and '1' will all be interpreted as true. Parameter trueAlias (with default value 'on') allows one additional word to be used to signify true. Anything else will return false.

public bool? PopBool(bool? defaultValue = null, string trueAlias = "on")

Parameters

defaultValue bool?
trueAlias string

Returns

bool?

PopChar(char?)

Remove the first character from the first argument and returns it

public char? PopChar(char? defaultValue = null)

Parameters

defaultValue char?

Returns

char?

PopCodeBlock(char, char, out string)

public string PopCodeBlock(char blockOpenChar, char blockCloseChar, out string parseErrorMsg)

Parameters

blockOpenChar char
blockCloseChar char
parseErrorMsg string

Returns

string

PopDouble(double?)

Tries to retrieve arg at given index as int, or null if not enough arguments or not an integer

public double? PopDouble(double? defaultValue = null)

Parameters

defaultValue double?

Returns

double?

PopEnum<T>(T)

Tries to retrieve arg at given index as enum value or default if not enough arguments or not part of the enum

public T PopEnum<T>(T defaultValue = default)

Parameters

defaultValue T

Returns

T

Type Parameters

T

PopFlexiblePos(Vec3d, Vec3d)

Retrieves a player position with following syntax: [coord] [coord] [coord] whereas [coord] may be ~[decimal] or =[decimal] or [decimal] ~ denotes a position relative to the player = denotes an absolute position no prefix denots a position relative to the map middle

public Vec3d PopFlexiblePos(Vec3d playerPos, Vec3d mapMiddle)

Parameters

playerPos Vec3d
mapMiddle Vec3d

Returns

Vec3d

PopFlexiblePos2D(Vec3d, Vec3d)

Retrieves a player position with following syntax: [coord] [coord] [coord] whereas [coord] may be ~[decimal] or =[decimal] or [decimal] ~ denotes a position relative to the player = denotes an absolute position no prefix denots a position relative to the map middle

public Vec2i PopFlexiblePos2D(Vec3d playerPos, Vec3d mapMiddle)

Parameters

playerPos Vec3d
mapMiddle Vec3d

Returns

Vec2i

PopFloat(float?)

Tries to retrieve arg at given index as float, or null if not enough arguments or not a float

public float? PopFloat(float? defaultValue = null)

Parameters

defaultValue float?

Returns

float?

PopInt(int?)

Tries to retrieve arg at given index as int, or null if not enough arguments or not an integer

public int? PopInt(int? defaultValue = null)

Parameters

defaultValue int?

Returns

int?

PopLong(long?)

Tries to retrieve arg at given index as long, or null if not enough arguments or not a long

public long? PopLong(long? defaultValue = null)

Parameters

defaultValue long?

Returns

long?

PopUntil(char)

public string PopUntil(char endChar)

Parameters

endChar char

Returns

string

PopVec3d(Vec3d)

public Vec3d PopVec3d(Vec3d defaultValue = null)

Parameters

defaultValue Vec3d

Returns

Vec3d

PopVec3i(Vec3i)

Tries to retrieve 3 int coordinates from the next 3 arguments

public Vec3i PopVec3i(Vec3i defaultValue = null)

Parameters

defaultValue Vec3i

Returns

Vec3i

PopWord(string)

Removes the first argument and returns it, scans until it encounters a white space

public string PopWord(string defaultValue = null)

Parameters

defaultValue string

Returns

string

Push(string)

public void Push(string joinedargs)

Parameters

joinedargs string

PushSingle(string)

Adds an arg to the beginning

public void PushSingle(string arg)

Parameters

arg string