Forum

> > CS2D > Scripts > String with comma(s) in the menu
Forums overviewCS2D overview Scripts overviewLog in to reply

English String with comma(s) in the menu

7 replies
To the start Previous 1 Next To the start

old String with comma(s) in the menu

Mora
User Off Offline

Quote
Hello guys!
I have an example of the string which is:
string="Flame, pgun, etc shop"
, which taken from
entity(x,y,"trigger")

and this string i tried to place in the menu:
menu(id,"Menu,"..string..",<")

but instead of exactly copied string it splits my menu to the 3 parts(2 commas).
Is there any way to keep commas( , ), dots with quotes(".. x .."), stick( | ) and any symbol in it? such as:
string="Hello, now. -"Hello|now""

Hello, now. -"Hello|now"
and even
string="Hey, "..id..", )))(0()"

Hey, "..id..", )))(0()

old Re: String with comma(s) in the menu

DC
Admin Off Offline

Quote
Hey, no I'm sorry, the special characters used to control the cs2d lua cmd menu string behavior such as
,
and
|
can't be escaped.

The best thing you can do is to replace them with similar looking things. e.g.:
replace , with ; or .
and replace | with ¦ or /

You can do so with string.gsub e.g.:
myString = string.gsub(myString, ",", ";")

old Re: String with comma(s) in the menu

Mora
User Off Offline

Quote
Okay then. Thank you for attention.
/Since there is nothing more may be done please close it? i don't think that keep free for replies makes sense..

Admin/mod comment

There is not a single reason to close this. The author or other people might have related questions. We only close threads if it is absolutely necessary. /DC

old Re: String with comma(s) in the menu

Starkkz
Moderator Off Offline

Quote
@user DC: You could possibly add escape characters to the game for these kind of situations.
1
menu(id, "Title,Hello%, World!,Second button,Third button, etc")
So the game would interpret
%,
as a comma instead of a new button for the menu.

old Re: String with comma(s) in the menu

DC
Admin Off Offline

Quote
@user Starkkz: I agree that it would make sense but it's not a very important feature and would be quite some effort to implement. Therefore it's unlikely that I'll work on it.

(damn, should have closed the thread... )

old Re: String with comma(s) in the menu

Mora
User Off Offline

Quote
Quote
(damn, should have closed the thread... )

Remove the warn message then >: D

The problem is that current menu have two parametrs, instead of more than 9(0-9, x, ESC) and it count "comma" as a new button.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview