Keycode not working for a french keyboard ?

Started by Baguettator, Mon 01/04/2024 12:50:36

Previous topic - Next topic

Baguettator

Sorry, you are right, I meant "linebreak"...

I checked, effectively, the "linebreaks" in the string are represented with the \n symbol. Obviously it doesn't appear in .txt files.

So I'm going to replace the \n by something like [LINEBREAK] before generating the string in the .txt file, because I need the string to stay in a single line.

eri0o

You can just escape the slash using "\\n". And then on reading you unscape it again.

I am trying to think if there's already some in-ags way to escape things and unscape. Can't quite remember right now, if there isn't it may make sense to think about this to add in the future.

Crimson Wizard

Quote from: Baguettator on Thu 04/04/2024 08:23:01I checked, effectively, the "linebreaks" in the string are represented with the \n symbol. Obviously it doesn't appear in .txt files.

In files it becomes a special symbol which is not printed, but emulated by a text viewer/editor by wrapping the line.
But it is still possible to read it back.

Quote from: Baguettator on Thu 04/04/2024 08:23:01So I'm going to replace the \n by something like [LINEBREAK] before generating the string in the .txt file, because I need the string to stay in a single line.

I'm curious, why do you need whole text to be in exactly one line?

Baguettator

Quote from: Crimson Wizard on Thu 04/04/2024 12:41:08I'm curious, why do you need whole text to be in exactly one line?
Because, for simplicity, I store each parameter one by line. So for the name of a map, it's one line. For its story, another line. At each line's beginning, I have a keyword that tells which parameter it is. Like that : (for title, story, and positions of zombie tokens on the map)

Code: ags
TITLE//My title//
STORY//Mystory//
ZOMBIETOKENS//210//150//200//170//

// is a separator, I have a function that reads things between them.

Crimson Wizard

Quote from: Baguettator on Thu 04/04/2024 14:35:17
Quote from: Crimson Wizard on Thu 04/04/2024 12:41:08I'm curious, why do you need whole text to be in exactly one line?
Because, for simplicity, I store each parameter one by line.


// is a separator, I have a function that reads things between them.

Oh I see.
Well, an alternative to replacing linebreaks would be to support multiline content between separators (or have begin/end tags)

Baguettator

Yeah, already have it. Sometimes I have to separate things inside the line for multiple reasons. I have different separators : // for parameters, [BREAK] for scripts' parts...

Really perfect to let it on one line only, as I won't have to change the whole code too :)

Is the function String.Replace has a .IndexOf(const LookingForText) in it ? I mean, if not, I could add it to my custom function, it could save time for engine, if the text has no \n, instead of verifying each string fully...

Crimson Wizard

Quote from: Baguettator on Fri 05/04/2024 06:06:42Is the function String.Replace has a .IndexOf(const LookingForText) in it ? I mean, if not, I could add it to my custom function, it could save time for engine, if the text has no \n, instead of verifying each string fully...

These functions do exactly same search, there's no way around it but checking the whole string for the given sequence of characters. You will only do duplicate work by calling IndexOf before Replace.

Baguettator

Question about old style keyboard handling :

In my game, I use many things in on_key_press function, like :

Code: ags
function on_key_press(eKeyCode keycode)
{
  if (keycode==eKeyCtrlF)
   // do something
}

If I turn the option "Use old style keyboard handling" false, CtrlF won't do anything anymore... Is it normal ? How can I deal with that ?


SMF spam blocked by CleanTalk