Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Baguettator

#101
I'm really sorry, and thanks a lot for helping !

OK, so as for ever, it's always the last thing you look at that hides the mistake :)

So, this function is crashing the game :

Code: ags
for (int i=0 ; i<NB_REGLES ; i++)
    {
      if (String.IsNullOrEmpty(this.nomobjectif[i])==false || String.IsNullOrEmpty(this.texteobjectif[i])==false)
      {
      String temp=this.nomobjectif[i];
      for (int j=0 ; j<TOTAL_EVENTS_TXTSTANDARDS ; j++)
      {
        if (events_txtstandards[j].txthaut!=null && temp.IndexOf(events_txtstandards[j].txthaut)>=0) temp=temp.Replace(events_txtstandards[j].txthaut, events_txtstandards[j].txthautcode, eCaseSensitive);
        if (events_txtstandards[j].txtbas!=null && temp.IndexOf(events_txtstandards[j].txtbas)>=0) temp=temp.Replace(events_txtstandards[j].txtbas, events_txtstandards[j].txtbascode, eCaseSensitive);
      }
      regleobj=regleobj.Append(e);
      regleobj=regleobj.Append(balise_trad[0]);
      regleobj=regleobj.Append(temp);
      regleobj=regleobj.Append(balise_trad[0]);
      
      temp=this.texteobjectif[i];
      for (int j=0 ; j<TOTAL_EVENTS_TXTSTANDARDS ; j++)
      {
        if (events_txtstandards[j].txthaut!=null && temp.IndexOf(events_txtstandards[j].txthaut)>=0) temp=temp.Replace(events_txtstandards[j].txthaut, events_txtstandards[j].txthautcode, eCaseSensitive);
        if (events_txtstandards[j].txtbas!=null && temp.IndexOf(events_txtstandards[j].txtbas)>=0) temp=temp.Replace(events_txtstandards[j].txtbas, events_txtstandards[j].txtbascode, eCaseSensitive);
      }
      regleobj=regleobj.Append(e);
      regleobj=regleobj.Append(balise_trad[0]);
      regleobj=regleobj.Append(TranscriptionLineBreak(temp, true));
      regleobj=regleobj.Append(balise_trad[0]);
      }
    }

Here, I get the data "nomobjectif" and "texteobjectif" of the map, I look at it if there is some standard text into it (events_txtstandards.txthaut), if yes, I replace it by a "mark" (events_txtstandards.txthautcode), then I look at the next one.

Perhaps multiple loops with IndexOf functions (where the string looked for is a large string, more than 100 characters sometimes) gets the engine crashing ?

Example of the struct events_txtstandards :

Code: ags
void Events_TxtStandards::CreerTxtStandards(int ID)
{
  // OBJ COULEUR
  if (ID==0) // bleu
  {
    this.txthaut=GetTranslation("Vous venez de trouver la clé bleue !");
    this.txtbas=GetTranslation("Placez l'Objectif Bleu sur la Fiche du Survivant qui a pris cet Objectif. Il ne prend pas de place dans l'Inventaire, et peut être échangé de la même manière qu'une carte Équipement.[[Un Survivant qui possède l'Objectif Bleu peut dépenser 1 Action pour ouvrir la Porte Bleue silencieusement et sans autre équipement requis.");
    this.txthautcode="[STANDARD_TXTOBJBLEU_HAUT]";
    this.txtbascode="[STANDARD_TXTOBJBLEU_BAS]";
  }
}

It's to save some place into .txt files, so texts that are redundant (like for rules that could be similar in many maps) are replaced by what I call "marks" (don't know the exact word in english).

I'm really sorry, because I thought I had fully debugged the function, but I forgot something... And just now I saw that it crashes at this place and not another one. Perhaps these maps have many rules, and the loops are crashing the game because too many things in one function ..?

Also I'm sorry if now, it's not the good thread to discuss about it... Because it doesn't seem an AGS bug anymore.

:(
#102
I used a Display function before to look at the string, it displays correctly what is intended.

I tried to make a file in another function, the file has the same name, and tried to write something into it, it worked. In the function, it didn't work.

As I said before, I tried to avoid the first iteration of ".WriteRawLine" (by putting a // before it), and it crashed the same way at the second iteration. The first string was something like String.Format("%s%s%s%s", and arguments), and in a display function, it displays with no error.

I have no idea of what's happenning...

EDIT : I tried to write the same file from another place (small function in o_key_press for debug), with the same string that is intended to be written in first position in my function, and it works. So the problem comes from my function. But it works for 95% of the maps, and not for 4 of them... Without any reason. The best thing should be I  send you my game, and if oyu can debug it better than me, great ! But I did all I could do and all you told to me. If you have any idea...
#103
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 ?
#104
I tried with a compiled game, and it crashed for the same files, without any message. It just closed itself.

My case is :

Let's say I have 100 maps. I want to store their data in .txt files, 1 file per map. When I launch my function, it works perfectly for 96 maps, and for 4 of them (always the same), the game crashes as described before.

The code is a bit long, so perhaps I shouldn't share it here for convenience...

I'm going to try debug for it.

EDIT : really strange, the file is created, but at the first occurence of "File.WriteRawLine", it crashes. I tried to create a file with the same name at another place, write inside it (only one simple line for debug), it works. If I try to write with my real function in a file with the same name at another place, it crashes too. So it seems my function doesn't work with these 4 maps.

The main thing I changed in my game is turning "true" the option "use old style keyboard handling". Will try with it turned false.

EDIT 2 : With that option set to "false", same result, it crashes. Very weird thing...

EDIT 3 : of course, I already used a lot this function, and it never crashed before. And I didn't update AGS recently.
#105
Hi !

I'm using a function to write some data in .txt files. But recently the game crashes when I launch that function, without any error message. It just says "the game engine does not appear to have shut down properly. If the problem persists, post the problem on the tech forum".

My version is 3.6.1.21.

is there any way to know what happenned ? Should I send you my project ?

I post here because perhaps it is a problem in AGS 3.6, and not in my code. Because the function worked for more than a hundred of files, but the engine crashed for only 4 files.

EDIT : It seems my game opened the file (created it if it didn't exist), but didn't write anything inside because I can only see a blank .txt file. So the crash seems to be just before the WriteRawLine function, but the opening seemed to not bug.
#106
Well at least for me, creating Dynamic Sprites using PNG files could be very useful :)
#107
Well, using PNG files will be always easier, this way you don't need to save a BMP file in a "magic pink" background to "emulate" a transparent background. It would be a quality-of-life improvement I presume ?

EDIT : also, I'm always working with PNG files, never with BMP files. But perhaps I'm a lonely bad guy :)

Anyway, the proposal milestone of AGS 4 looks great ! Have you got any release date for a fully achieved version ?
#108
@eri0o Yes that's exactly what I'm going to do : the undo/redo lists are string dynamic arrays, each time you perform an action, it's added to the dynamic array !
#109
Yeah, the Save method could be a bit long if you have many things in your savegame (variables, GUIs etc...)

So the String method is better. No need to load from another file, as it would be slower than reading a string.

Thanks guys :) The discussion can continue if you need to argue ;)
#110
Hi,

I'm making a game that in fact is a map editor for a tabletop game, using tokens to place.

I would like to make a cancel/redo function, as in any program, so if I do something badly, I can cancel the thing I just did, or I could redo what I just canceled.

I'm asking here, because I don't know how it is implemented in other programs, and I would like to know what would be the best way to make it in AGS.

For now, I'm thinking about memorizing the action I just did in a string (a String[] that could increase in size, memorizing infinitely the actions), using tags to mean what action I did, and how. I'm not sure if it's the best thing...?

Any idea is welcome :)
#111
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...
#112
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.
#113
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.
#114
Thanks I know I will have you switch to the \n solution. Long work again :)

But how backspace is translated in my example below ? \n ?

If I have this String in my BlocNote :

Code: ags
Yo.

It's me.

And I do :

Code: ags
String s=BlocNote.Text;
int p=s.IndexOf("\n");

Is p equal to 3 ?
#115
Oh, question... Not really linked to this thread, but...

With this BlocNotes, I can use the "enter" key to go to next line. Like in Word program or similar. Nice. So I can write :

Code: ags
Yes I use the enter key twice.

And here it is.

Then, I create a String that gets the text from my Blocnote (wordpad). How the "jump line" character is "translated" into the String ? Because if I make :

Code: ags
String s=BlocNote.Text; // gives the text I wrote before to s

File *f.Open($SAVEGAMEDIR$/myfile.txt, eFileWrite);
f.WriteRawLine(s);
f.Close();

In the file, I will see :
Code: ags
Yes I use the enter key twice.

And here it is.
(the same as in my BlocNote)

But perhaps it should be better to have :
Code: ags
Yes I use the enter key twice.[[And here it is.

because later I will use File.ReadRawLineBack() functions, and I want to read the full text, not only the first line.

I hope I'm clear, as you have understood english is not my native language :S
#116
Quote from: eri0o on Mon 01/04/2024 21:46:13I would say having more modules is always nice, so it would be nice if you could share, later, with the author's permission. :)

The module is available at the french forum of AGS : (you need to login to download it)
https://adventuregamestudio.1fr1.net/forum (in "modules" section, "Module Bloc-Notes")

If you want to try it, I could send you the scripts I fixed. the author has not logged in since more than 1 year, so perhaps he won't see my message... :(

EDIT : just saw that the author is Kitai, registered in this forum too, and perhaps you know him, or you have talked with him by the past !
#117
OK, so I managed to change the code of the module, and now it works with on_text_input ! So nice !

Thanks a lot !

I don't know if there's any Text Writer Module for AGS, but this one is working very well ! There's only 1 minor bug I couldn't fix yet, but nothing important. If needed, I could share the module in this forum (with author autorization of course) ?
#118
OK I see. As the code of the module uses on_key_press to handle actions and not only the printable characters, I will stay with on_key_press.

Is there any problem to turn options on for the unicode compatibility ? It won't "hurt" my game nor its functions ?
#119
OK, but sorry, now I don't really see the difference between "printable characters" and "others one"...? Why should I need both functions ? In this case, it's better to use one ?
#120
I will have a look soon if  I have the option on or off.

So the new function on_text_input is called like on_key_press, and works the same ? (the link by erioO is dead, doesn't work).

Does this function works with Ctrl+Key or Alt+Key ? If you could give me an example, it would be very kind :)
SMF spam blocked by CleanTalk