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

#181
Exactly as me,I used long ago and it worked perfectly !
#182
Before I was with 3.5.1 (not the last patch), and it worked perfectly for me. It's only since 3.6.0.25.
#183
@eri0o it's the version I'm using ! ;)
#184
Hi !

About my text problems, it seems that I fixed that (or it fixed itself), I didn't understand well what happenned, so maybe it was my fault, I don't know. If I encounter another similar problem, I will post it :)

I tried to change the game translation, and it seems that the texts don't update when the function Game.ChangeTranslation is called. For example, I change my game from french to english, nothing happenned (texts still in french), but when the mouse went on a button, suddenly its text changed to the english one. Labels were not translated and the mouse didn't do anything on them. Surely because their image doesn't update when mouse is on them (and buttons do update).

Is it a problem with the Beta 3.6.0.25 ?
#185
Yes, it crashed. And it displayed incorrectly :)

As you have seen, the files contains many lines (each line containing informations about 1 character, written each one between a ";"). When I displayed the text, I saw that each É or characters like that was badly displayed. I displayed the text at each occurence of my function, and at some point, it crashed (saying the error I mentionned before).

I changed the É with E, it worked. And then, I changed the E to É, and it worked too...!!

Well, it worked for one file. For another, the É are displayed in game by ^ .

Strange...?
#186
Quote from: Crimson Wizard on Mon 30/05/2022 19:38:37
Quote from: Pax Animo on Mon 30/05/2022 17:30:23
Hey there,

Something odd is going on when having two characters SayBackground at the same time.

There seem to be a bug there. There will be a temp build with a fix here in roughly 20-30 minutes:
https://cirrus-ci.com/task/5199731981811712
EDIT: ready


Quote from: Baguettator on Mon 30/05/2022 18:28:57
So I debugged it and I found what happenned : in one of the file (the one who made the game crashing), there were some "É" characters. And this made the game crash during the substring function.

Could you please post a file? I'd really prefer to test real case rather than trying to reproduce this by luck.
EDIT: well, i tried to put random É in the file, but nothing happened.

Quote from: Baguettator on Mon 30/05/2022 18:28:57
The thing is : why ? The file is in UTF-8, and the game too.

The file format does not have a direct relation to the game. File can be read differently, what matters is how it is read and what you do with the data in script. Whether engine works correctly too.

Thanks for helping !

Did you displayed the String (with the Display function) that you obtained each time with the ReadRawLineback function ? I remember that all the É characters were not correctly displayed (something like ^A"< you know when the character is not properly read).

I will send you my files later (something like tomorrow or monday, I don't have any time before). Remember that in my code, I use a function which locates the ";" characters, and extract the informations between two ";". So it could be that each É or È was putting a new ";" and so it breaks the code.
#187
Quote from: Crimson Wizard on Sun 29/05/2022 12:04:45
Code: ags
nouvelle=s.Substring(r, rr-r); // Error indicates : String.Substring : invalid length


So it fails at Substring?

I tested your code with random "n" to trigger "if (c==n)" condition, and there was no errors. I guess "n" means a line. Could you tell at which "n" it happens, does it occur at any or particular lines?

I need to narrow the situation down to know which exactly conditions cause this error.

EDIT: actually, I ran this code in a loop, from n = 0 to 500, and met no error... tried in both ASCII and UTF-8 mode.

So I debugged it and I found what happenned : in one of the file (the one who made the game crashing), there were some "É" characters. And this made the game crash during the substring function.

The thing is : why ? The file is in UTF-8, and the game too. Or I'm misundersting something ? (which is surely the main reason of my problems I think ;) ).
#188
Hmm, the file is located in the savegame directory (so in windows 10 : "saved games/[my game's directory]".

Here is the function that needs to read the file to save the attribute of something in the game (like a character for example) when the game is launching :

Code: ags
File *f=File.Open("$SAVEGAMEDIR$/cartesinvasion.txt", eFileRead);
  int c=1;
  while (!f.EOF)
  {
    String s=f.ReadRawLineBack();
    if (c==n)
    {
      String t="";
      this.nom=LectureStringCustom(s, 1);
      t=LectureStringCustom(s, 2);
      this.famille=t.AsInt;
      t=LectureStringCustom(s, 3);
      this.valeur[0]=t.AsInt;
      t=LectureStringCustom(s, 4);
      this.typezombie[0]=t.AsInt;
      t=LectureStringCustom(s, 5);
      this.valeur[1]=t.AsInt;
      t=LectureStringCustom(s, 6);
      this.typezombie[1]=t.AsInt;
      t=LectureStringCustom(s, 7);
      this.valeur[2]=t.AsInt;
      t=LectureStringCustom(s, 8);
      this.typezombie[2]=t.AsInt;
      t=LectureStringCustom(s, 9);
      this.valeur[3]=t.AsInt;
      t=LectureStringCustom(s, 10);
      this.typezombie[3]=t.AsInt;
      t=LectureStringCustom(s, 11);
      if (t.AsInt==1) this.egouts=true;
      else this.egouts=false;
      t=LectureStringCustom(s, 12);
      if (t.AsInt==1) this.reactivation=true;
      else this.reactivation=false;
      t=LectureStringCustom(s, 13);
      if (t.AsInt==1) this.litsbleus=true;
      else this.litsbleus=false;
      t=LectureStringCustom(s, 14);
      if (t.AsInt==1) this.litsverts=true;
      else this.litsverts=false;
    }
    c++;
  }
  f.Close();


Here is the function that read the informations. Each information is separated in the file by a ";". So between each ";", there is 1 information.

Code: ags
String LectureStringCustom(String s, int pos)
{
  String e=";";
  int r, rr;
  String nouvelle;
  for (int i=0 ; i<pos ; i++)
  {
    int p=s.IndexOf(e);
    if (i==pos-2) r=p+1;
    if (i==pos-1)
    {
      rr=p;
      nouvelle=s.Substring(r, rr-r); // Error indicates : String.Substring : invalid length
    }
    s=s.ReplaceCharAt(p, 'm');
  }
  
  return nouvelle;
}


I have to say that before I tried AGS 3.6 beta 5 (I was before on AGS 3.6.0.15), everything was OK.

Any idea ? Thanks a lot for helping ;)
#190
Hi there !

I just tried the new version (beta 5), and I tried to change the text format in the general settings pannel : I switched from ANSII to UTF-8. As I'm french, with special characters like éàÉÈ I thought it was better do to that. But when I change the format, the game crashes during a function that "reads" some txt files. It seems the txt files can't be read, so the functions like ReadRawLineBack return an empty string (so it crashes in my function). These txt files are in UTF-8 format.

Any idea why it happens ?
#191
Hmm Khalibri, what are you talking about ? What do you want to do ?
#192
Hi there !

I have a question about the function DrawingSurface.DrawString(). I tried to draw this String :

"Hey man.[How are you ?"

And it has drawn :

"Hey man.[How are you ?"

Em... It was intended to be drawn :

"Hey man.
How are you ?"

Is it a problem in AGS ? Or is there a way to do that ? It would be so nice to be able to do that without "cheating" another way :)
#193
Thanks Crimson for your answer ! Indeed, it could be SO NICE to have the autocomplete working well, at least for my situation... Let me know :)
#194
Sorry, I didn't thought about it. Excuse me for that...

But I think this is not offtopic : I don't know if it's a problem, but it's a bit annoying for me : in my struct to manage the maps in my game, I have plenty of functions to set up the map. I have a huge function that creates the chosen map (with if/else conditions). The problem is that when my function becomes to big, and if I write something like that :

    function Cartes::Create(int c)
    {
      this.PlaceTokenA(
      // the PlaceTokenA function has parameters like "int tile, int x, int y, int rotation" etc...
    }

Normally, when I hit the "(", AGS shows me the order of the parameters below the editor's text. But it doesn't if the function is too big (I think after a hundred or so lines long). It's a bit annoying because sometimes I have to look in the script in which order are the parameter of the function (like PlaceTokenA), it's a lost of time. Any idea why it happens ? Is it possible to correct it ?

For me, it's a problem, like a problem of memory or I don't know what...
#195
Quote from: Crimson Wizard on Sat 05/02/2022 22:08:32
You can put multiple variables in a managed struct and pass the instance of that struct as 1 parameter. There may be other solutions, depending on the situation: what the function is for, how do you use it, maybe it can be replaced with just a struct and setting struct members instead? But this is a general scripting topic.

I really don't understand how a managed struct can replace several function parameters, but the thing is I created functions to place some tokens in a map (like a tabletop game), and sometimes 1 function is to set the different possibilities of placement for 1 token. So, for each possibility, I need to tell which tile, which x coordinate of the tile, and which y coordinate of the tile. 3 parameters per possibility. In this case, my function can get only 4 possibilities. Of course I can set up a way to stock these possibilities, then recall the same function with other parameters and increase the number of possibilities, that's what I did. But it could be useful to have a greater limit. Or maybe I'm wrong ?

Quote from: Crimson Wizard on Sat 05/02/2022 22:08:32
It's currently possible to script your own label or list box that uses several fonts and colors, with DrawingSurface and DynamicSprite functions.
In theory it's possible to implement some kind of a "rich text" control in the engine too, for example one that draws text using html-like tags, but that's a serious work that requires some good design decision first. We have already planned to wrap 3.6.0 version up, and now working towards finishing priority major features. The other features added were ones that cover problems that are too inconvenient for scripting and simple enough to do quickly in the engine at the same time.
If there's an actual interest in such engine feature, you may post it in the engine suggestions forum section, or our issue tracker on github.

Hmm seems complicate for me to do so. Is there any module for that kind of things, existing for the 3.6 ? Or any method to do the same ?

Also, I already mentionned it, but got no answer : I don't know if it's a problem, but it's a bit annoying for me : in my struct to manage the maps in my game, I have plenty of functions to set up the map. I have a huge function that creates the chosen map (with if/else conditions). The problem is that when my function becomes to big, and if I write something like that :

Code: ags
function Cartes::Create(int c)
{
  this.PlaceTokenA(
  // the PlaceTokenA function has parameters like "int tile, int x, int y, int rotation" etc...
}


Normally, when I hit the "(", AGS shows me the order of the parameters below the editor's text. But it doesn't if the function is too big (I think after a hundred or so lines long). It's a bit annoying because sometimes I have to look in the script in which order are the parameter of the function (like PlaceTokenA), it's a lost of time. Any idea why it happens ? Is it possible to correct it ?
#196
Hmm I didn't follow you in your thoughts... I used your formula (with cos and sin) to calculate the width/height of the token after rotating (45° or multipliers), then I simply do that :

Code: ags
//34=width when it's not rotated, 30 is the height when not rotated
int l=FloatToInt(Maths.Cos(Maths.DegreesToRadians(45.0))*IntToFloat(34) + Maths.Sin(Maths.DegreesToRadians(45.0))*IntToFloat(30));
int h=FloatToInt(Maths.Sin(Maths.DegreesToRadians(45.0))*IntToFloat(34) + Maths.Cos(Maths.DegreesToRadians(45.0))*IntToFloat(30));
int x, y; // x is the original x position for the top leftcorner of the token, y is the y position of the top leftcorner
int xporte, yporte; // Also the original coordinates of the token
// The tile width and height are equal to 250
if (nouveau==right) // the tile rotates to right, so 90°
{
  xporte=250-y-h;
  yporte=x;
}
else if (nouveau==down) // the tile rotates to down, so 180°
{
  xporte=250-x-l;
  yporte=250-y-h;
}
else if (nouveau==left) // the tile rotates to left, so 270°
{
  xporte=y;
  yporte=250-x-l;
}
#197
I presume that if I only talk about 45° multipliers (45, 135, 225 and 315), these dynamicsprites should have the same width/heights ?
#198
Thanks a lot Crimson !

I already scripted all the tokens with their top-left corner coordinate (which is the way AGS works for buttons, and tokens are represented by buttons), and it should be very long to change it now... Maybe one day :) Surely it should be better, but it works perfectly for now.

I'm working on the rotation of the tile, will see if it works with the new formula.
#199
Because I use a script to calculate coordinates for tokens (to place on maps, like a tabletop game). And I have "stored" the possible coordinates for the different tiles.

So for example I can place my square at the 1st position of the tile A, with a "up" rotation, and it will automatically set it to x and y coordinates according to my script.

But if I rotate the tile, I have to rotate the tokens too. So they change their rotation (up becomes right for a 90° rotation, or becomes down for a 180° rotation, etc), and their coordinates. To change their coordinates, I need to know their width and height. I have to script it during a time when DynamicSprites are NOT created yet. So I can't use DynamicSprite.Width etc

Is the formula too complex ?
#200
OK thanks !

I just wanted to know the formula to calculate the new height/width of the dynamic sprite.

Is the formula well-known ? I have to use it in scripts, with many things that have different heights and widths, so I need the generical approach.
SMF spam blocked by CleanTalk