Jump to content
_SCAR

Side from String?

Recommended Posts

Is there any way to retrieve the side from string? I mean something like:

sideFromString "WEST";  ==> returns west (side, not string)

 

Share this post


Link to post
Share on other sites

Answering myself, but not sure if this is "clean":

_side = [] call compile "WEST";

 

Share this post


Link to post
Share on other sites

I would just use a switch statement and return the particular side.
Using call compile is abit unnecessary and i avoid using it so can make more secure BE Filters. Espeically if you are allowing the player is allowed to type in the side.

  • Like 1

Share this post


Link to post
Share on other sites

Since sides are finite and can't be created dynamically, why not just use the good ole keys n values routine?

 

_input = "WEST";

_keys = ["WEST","EAST","INDEPENDENT","CIVILIAN"];
_values = [west,east,independent,civilian];

_output = _values select (_keys find _input);

 

Cheers

  • Like 4

Share this post


Link to post
Share on other sites

Thank you, I'll need to add a few (blufor, opfor, resistance) but I think you're right. 

Share this post


Link to post
Share on other sites
On 9/18/2017 at 4:11 AM, _SCAR said:

Thank you, I'll need to add a few (blufor, opfor, resistance) but I think you're right. 

 

west/blufor are the same and interchangeable.

Same goes for east/opfor and resistance/independent.

 

Edit: just saw the date, added additional info anyway due to a "like".

 

Cheers

Edited by Grumpy Old Man

Share this post


Link to post
Share on other sites

Why not just use SIDE then use str to make it string? You can also use "call compile" to do the same but vice versa. Or did I misunderstand completely? :grinning:

Share this post


Link to post
Share on other sites
17 hours ago, HazJ said:

Why not just use SIDE then use str to make it string? You can also use "call compile" to do the same but vice versa. Or did I misunderstand completely? :grinning:

 

Agreed, there's probably a more convenient way to begin with.

Having the requirement of getting a side from an input string there's only a few solutions, heh.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×