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

#1
Hi there !

Simple question : if I remember well, it is possible in AGS to "force" a string to keep its basic value without using its translation, even if a translation is currently used by the player. Like doing it :

Code: ags
String a="Bonjour";

function Say(String s)
{
Display(s); // if s=a, I want to display "Bonjour", but not "Hello" even if I selected the English translation of my game
}

Is it possible in AGS ?
#2
Quote from: Crimson Wizard on Mon 18/09/2023 13:43:51@Baguettator
I used your code in a new game, and it works correctly. You may try it yourself, if you would just create a new test game from a random template.

Is this the real code you are using? Is this string variable changed anywhere else in script?

I think it's best to deal with cases like this in the tech help forums first, to let others look into your script and make sure it's not a scripting mistake.

Big Sorry... The problem was I made a mistake in the name of the "game_start" function. I forgot the "_"... So it wasn't called !

And sorry, I told about it here as I thought it was a bug from the new versions of AGS.

Thanls for help anyway !
#3
Quote from: Crimson Wizard on Fri 15/09/2023 12:27:20
Quote from: Baguettator on Fri 15/09/2023 11:08:29Hi ! I noticed a problem, I use 3.6.1.6, I have some "strings" declared at the top of my script, I give them a value in game_start function (String a="My String A" etc...), but if I have a code that asks "if (Label.Text==a)", it crashes as "a" is null.

This sounds like this may be a scripting mistake, please post an actual script example, and exact error message.

Quote from: Baguettator on Fri 15/09/2023 11:08:29EDIT : also I saw that declaring label array in game_start doesn't work (label pointers will be null if they are called later in the code)

Please post an actual script example, so that we can see what exactly you are doing.

Sorry, but in fact, it a real bug !

What I did :

Code: ags
// At the top of TopScript.asc, a Script File located higher than global Script.
String a;

function game_start()
{
  a="Test";
}

export a;

// In TopScript.ash
import String a;

// In Global Script

function on_key_press(eKeyCode keycode, int mod)
{
  if (keycode==eKeyG) Display(a); // THIS crashes because it returns a null String !
}

That's a problem !
#4
Quote from: Crimson Wizard on Fri 15/09/2023 12:27:20
Quote from: Baguettator on Fri 15/09/2023 11:08:29Hi ! I noticed a problem, I use 3.6.1.6, I have some "strings" declared at the top of my script, I give them a value in game_start function (String a="My String A" etc...), but if I have a code that asks "if (Label.Text==a)", it crashes as "a" is null.

This sounds like this may be a scripting mistake, please post an actual script example, and exact error message.

Quote from: Baguettator on Fri 15/09/2023 11:08:29EDIT : also I saw that declaring label array in game_start doesn't work (label pointers will be null if they are called later in the code)

Please post an actual script example, so that we can see what exactly you are doing.

OK sorry it's my fault, it seems I made a mistake in my code...!
#5
Hi ! I noticed a problem, I use 3.6.1.6, I have some "strings" declared at the top of my script, I give them a value in game_start function (String a="My String A" etc...), but if I have a code that asks "if (Label.Text==a)", it crashes as "a" is null.

Perhaps it has been fixed since newest versions, but I have to mention it in case of !

Of course, the call of "a" is done after "a" has been given a value, and after game_start function.

EDIT : also I saw that declaring label array in game_start doesn't work (label pointers will be null if they are called later in the code)
#6
Hi here, I continue this thread with a new math problem I need help to solve :

let's say I have a square (same width and height). Into this square, I have a point at (x,y) coordinates (the coordinates are from square's size, so the top left corner coordinates are 0,0).

If I rotate the square by "a" degrees, how can I calculate the new coordinates for the point ? (the point rotates with the square, as if they were the same thing). Is there a formula that works generally for any "a" value ? I guess there is, but I don't know which :(
#7
And so you are talking about Game Size, not about VRAM or something like that ? Because I use a lot of sprites that are saved into the game (sprites are saved in the editor, so they make the game's size huge). Perhaps the sprites once they are logged, won't need many resources for the game to work on the web ?

EDIT : my windows folder (the folder where the game is compiled) is 500Mo, and the game executable is 290Mo.
#8
Hi ! How is working the Web Compiler ? Does a big game (like 1,5Go of size) can be launched on the web ? And how it works ? It allows multiplayers, or players on different computers can see the same game at the same moment and everyone can control it ?
#9
OK, but How can I tell AGS that "I'm keeping the Mouse button down, so I want to do something, BUT I don't want to execute the script attached to a on_mouse_click" ?

The thing is I rotate a Gui Button by keeping the right mouse button down, but there is a script attached to this Button that is "if you right-click on it, it will rotate it by 45°". The problem is that rotating the button while right button is down works perfectly, but when I release it, the button is rotated by 45° because it's like a right mouse click...
#10
OK I see !

The problem could be that the engine doesn't recognize the click if the button is kept down. If I click and keep the button down, it's not a click until I leave it. Is it an AGS limitation ?
#11
Hi here !

What I want to do is to be able to :

- click on a GUIButton, and let the mouse button (left) down
- while the mouse button is down, I move the mouse down to decrease some value, and move up to increase some value
- in facts, the "value" is the angle of the sprite of the GUIButton.
- in other words, I want to do something similar to, let's say, changing the angle of an image in "Photoshop" : you select the image, then you click and hold the mouse button down on a square near the image,, and by moving the mouse up or down, you rotate the image to your taste.

I don't really know how to do this in the easiest way in AGS, I can imagine that I have to store the mouse.X and mouse.Y coordinates when I click the button and then in the repeatedly execute I look at if I'm moving up or down from there, and so I change the angle. But I think it's not the easiest way, and perhaps it's not THAT way that I can do it, so... I'm here to gather your suggestions/solutions :)

Thank you all for all the help I found here since several years learning coding !
#12
Yeah, but scripting an overlay to detect mouse clicks would be harder, isn't it ? I thought having a button is easier to detect that it's a button and I click on that, even if it doesn't have any function linked to it.
#13
Very impressive work ! I just didn't understand how to script the button when it's clicked ? How can I make it doing something ?

EDIT : and as it uses overlays, is it possible to Resize dynamically the whole window with its buttons inside ?
#14
EDIT : Crimson Wizard, you told that it's not complicated to create a button at runtime ? The biggest problem to link it to functions in script ? But does that mean that we could have AGS able to create buttons at runtime, and then we could interact with buttons using the "mouse_onclick" function, something like :

Code: ags
function onmouse_click ()
{
  GUIControl *g=GUIControl.GetAtScreen(mouse.x, mouse.y);
  if (g.Graphic==12)
  {
    //I know which token it is, so I do that
  }
}

It could be as simple as it, waiting for a long time if one day it could be possible to do more complex thing, attaching functions dynamically to controls by script. But if that simple case could be possible... could be great, isn't it ? :)
#15
Thanks for answers ! I didn't expect that it was a limitation of AGS engine, but something not too hard to update. So good news ! Even if it will take time to be achieved, I think the best thing is to wait and sometimes push the idea to ags developers :D

Thanks for the solutions and for erioo's module, it's what I thought about (I've never worked with overlays, but sounds great !). For now I'll stay with Guicontrols, as I have already implemented many things with it and it's easier to script. When Ags will be ready... I'll change :)

So, good news ! I hope to test AGS 4.0 soon !
#16
Just a big congrats to all of you who are still working on this incredible free  and rich program !! I will test AGS 4.0 as soon as I can !

I have a question that could be (or not) a suggestion for AGS development : is it possible to create during runtime new buttons or GUICOntrols or things like that ? I mean : the game could manage new buttons that have not been created in the editor, but created during playing the game ?

My idea is that I'm making a "map editor" for something, so I have to place tokens (tiles, events, starting zones, objectives, characters etc...) to create a map. I can't imagine doing this another way than using GUIControls (or characters, or room objects) to represent tokens, to easily be able to manage clicks on them to delete, rotate, move etc...

The problem is that it will necessary limit the possibilities, the number of tokens "available" because I can't have infinite GUIControls. I have to create 100 GUIControls, and I can't add more than 100 tokens for a map (for example).

So, the idea would be to be able to create new Buttons in runtime. Each time I create a token, it creates a Button that could be a copy of another one (for the scripts functions attached to them for example), and then act on them (change the graphic, the orientation etc...).

Is it a limitation of AGS Engine ? Or a limitation of engines in general ? Or something like that could be possible ?

Probably my question is stupid, as I'm not an expert like you. But perhaps... :)

Also, I hope my post is at the right place, as I thought it was a "development consideration", but sorry if it's not the case, I can delete it if necessary.

Anyway, congrats for AGS workers that make it possible to have such a program !
#17
Hmm Khalibri, what are you talking about ? What do you want to do ?
#18
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;
}
#19
I presume that if I only talk about 45° multipliers (45, 135, 225 and 315), these dynamicsprites should have the same width/heights ?
#20
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.
SMF spam blocked by CleanTalk