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 - Joacim Andersson

#61
EDIT: I'm being stupid, read my own reply below.

I've been writing some test code to learn how AGS implements OOP. So my very first struct in AGS looks like this:
Code: ags
struct List
{
  protected int arrSize;
  protected String list[];
  protected int count;
  import writeprotected attribute int Count;
  import attribute String Items[];
  import int Add(String value);
  import function Remove(int idx);
  import int get_Count();
  protected import function set_Count();
  import String geti_Items(int idx);
  import function seti_Items(int idx, String value);
  protected import function ExpandArray();
};
Obviously, it's a try to implement a Collection object in AGS that is a bit more dynamic than to work with arrays (the code works fine BTW).

My question is why I'm required to implement the set_Count() function for a writeonly attribute, I understand that within the struct I can use this.Count but in my case I only use the count (with lowercase letters) to change the Count property. In my opinion, the set_Count() function should be voluntary to implement, AGS should be smart enough to just throw a runtime error if I ever use this.Count = someValue in my code if I haven't implemented the set_Count() function.

Another question related to my implementation above: This List struct only accepts strings. Is there any generic type in AGS that can accept any value, either a number or a String, such as an object (and I'm talking about the type here, not Room Object)?
#62
Thank you so much for your replies and explanations. I promise that this will be my last post in this thread since we got a bit off-topic.

But what is the plan for AGS, will there be more 3.x releases before 4.0 is ready?

I also hope that you guys get constructors to work properly, then I will eagerly await the release of 4.0.
#63
Does Lambda functions also exist?
#64
You're confusing me, the get_Data and set_Data (or whatever you like to call them) still have to be declared but they are automatically called when you use code like this:
Code: ags
int value = myStructInstance.Data;
value++;
myStructInstance.Data = value;
So you don't have to use this code:
Code: ags
int value = myStructInstance.get_Data();
myStructInstance.set_Date(value * 2);
So basically they work like property getter and setters in C#?

So you can also use extension methods? That's cool. I wish the documentation were a bit more extensive on all of the OOP stuff.
#65

Yeah ok, so basically you have to create a Get and a Set method (much like Java) but above it looked like the read-only data variable could be read by the int MyStruct::get_Data() method, which isn't declared. So it looks like that would be called when you use
value = myStructInstance.Data
Have I understood that correctly? If so it's still different from having a GetData() and a SetData() method.
#66
Will AGS 4 have both getter and setter properties? I would love that, to get rid of all global variables.
#67
Quote from: Crimson Wizard on Thu 21/11/2024 22:07:50"readonly" is a runtime-time constant, meaning it may be initialized by any expression, including calling a function, which result can be only calculated at runtime.
So does that mean that a readonly can be initialized once, much like a readonly in C# can be initialized in the constructor. However, since AGS doesn't have classes and constructors, does that mean that a readonly is not initialized when created like a normal int is initialized to 0?
#68
Oh, yes. of course! Thank you. You know I started my development career as a C/C++ developer, I should know this stuff, but I think I just added the trailing semicolon out of habit. Yet I have several defined macros above this line with no trailing semicolons.
#69
I have this in a scripts header file:
Code: ags
#define PLAYER_ON_PORTAL 13;
Then elsewhere I have this:
Code: ags
function PlayerOnPortal()
{
  Object* portal = Object.GetByName("oPortal");
  if (portal != null)
  {
    if (Object.GetAtRoomXY(player.x, player.y) == portal)
    {
      player.StopMoving();
      player.FaceDirection(eDirectionDown, eBlock);
      CallRoomScript(PLAYER_ON_PORTAL); 
    }
  }
}
If I replace the line CallRoomScript(PLAYER_ON_PORTAL) to CallRoomScript(13) it works, but when I try to use the defined value I get "Parse error in expr. near '13', so the parser has replaced the PLAYER_ON_PORTAL macro with the value 13, yet it doesn't work. Any help?
#70
Quote from: Crimson Wizard on Wed 20/11/2024 15:51:40However, when it does, it converts it to 8-bit, IIRC, which may not be what you like in a 32-bit color game.
Well, for this background it wouldn't have mattered.
#71
Yes, that's how I'm used to working in Visual Studio and other IDEs.
#72
I solved it. When I saved the image with Paint.net I had the Bit Depth set to Auto-detect, which I had for all other backgrounds as well, but this time it set it to 4, so I changed that to 24 and it all works.

Sorry for bothering anyone.
#73
Quote from: Crimson Wizard on Wed 20/11/2024 14:55:14E.g. there could be two different menu commands: Build Game for Debug, Build Game for Release.
or something similar.
I agree that sometimes you want to distribute a debug version, your suggestion of two different menu commands is a great idea. Then it's far less likely that you distribute a debug version by mistake.

So I change my request to that.  :smiley:
#74
This is strange. I make my backgrounds using Tiled and I've used the same spritesheets for the tiles in all rooms. I export the background as a PNG and open it in Paint.Net where I change the height of the image (instead of the 640x384 that I get from using 32x32 pixel tiles, I want 640x360, so I get the correct aspect ratio). I have done this with all my backgrounds, but when I suddenly created a new one and tried to import it into AGS room editor today, I got the error 'The background could not be imported. The error was: Unknown pixel format'. What's up with that?
#75
Today, I must open the General Settings and turn off Debug mode. It would be nice if debug mode was only on when I compile with the debugger attached (F5 key) and not otherwise. It's so easy to forget to turn Debug mode off before a release, and all the handy Debug() function calls are still available in the game.

I don't know about the complexity of this request, but I don't imagine it would be that hard to automatically inject the DEBUG definition based on how I choose to compile the project.
#76
Thank you both for the news and links. I don't want to use an alpha version of 4.0 but at least I know it's on its way, and that's great.
#77
I'm not sure if this belongs here or in the Editor Development forum, but since I'm requesting a feature of the debugger (even though the actual window would be in the Editor), I'm posting it here. Would it be possible, in some near future version of AGS, to get a watch window? When I set a breakpoint in a function and I hit it I would love to be able to see the values of all the local variables within that function. Today, I have to add extra debugging code like:
Code: ags
System.Log(eLogInfo, "myVariable = %d", myVariable);
I don't like to add too much debug code within my project.
#79
Well, the subject pretty much say it all. I want to get the position in the inventory list an InventoryItem is at, the whole reason is that in my game when you use the item in a special way, it is supposed to change. So I want to replace it with another item, but let the new item be in the same position in the list.

I've searched through the help file but we no success.
#80
I didn't use char in my actual code; I typed it wrong in the simplified example I posted here in the forum. I got that error because of the order in which the headers are added during compile time. And no, I'm not new to coding. I've been a system developer for 30 years. I also started with AGS 20 years ago; however, it's also been almost 20 years since I last used it, with an exception for about a year ago.

I got your point though.
SMF spam blocked by CleanTalk