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

#81
Quote from: Khris on Mon 18/11/2024 22:35:08This is the second time you've
a) posted code and an error message that do not go together
b) posted code that should absolutely work but mysteriously fails, then suddenly and mysteriously does work
What do you mean the second time? I'm only aware of this post about an error message. Besides I can't help that AGS throws error messages that don't make sense.

In the other thread the error message did make sense, and I got the help I needed.

However, I agree with you that forum posts should be a help for others as well as for the OP.
#82
It doesn't matter, it works now so I've marked this thread as RESOLVED. Thank you again for your help.

I can't post the whole code, it's a big part of my next game,
#83
I noticed that I had MY_VALUE defined in 2 different places, however that doesn't explain why I got a 'Undefined Symbol' error instead of a 'MY_VALUE is already defined' error. Anyhow I got it working, thanks a lot for your help.
#84
Quote from: Crimson Wizard on Mon 18/11/2024 19:07:41That should normally work, could you post actual script (relevant parts), and copy error message here?
Funny, again I edited my previous post at the same time you replied.
#85
I put the #define statement in the header of one of my scripts and tried to access it from a Room file, but got a compile time error in the Room file.

I have this (sort of) in the header of my code file:
Code: ags
import function MyFunc() // <- MyFunc exist in the associated code file for this header
#define MY_VALUE 1
Next in a room file I have this:
Code: ags
function room_AfterFadeIn()
{
  MyFunc(); // <- This will execute
  Display("%d", MY_VALUE); // <- Compile time error "undefined symbol"
}
As you can see MyFunc is imported but I can't reach MY_VALUE in the Room.
#86
Quote from: Crimson Wizard on Mon 18/11/2024 18:47:26This hidden script is processed above all others.
That makes sense. I'm trying to avoid global variables as much as possible, however some functions I want to have global access to. I also want global access to some named constants but I haven't figured out how to do that, but I've posted about that in a different thread.
#87
Quote from: Crimson Wizard on Mon 18/11/2024 18:39:06As for the AGS 3.* versions, I don't remember about "const", but the usual way to make constants there is to use "#define" preprocessor command:

Code: ags
#define MY_VALUE 1

Yes, I'm aware of that (I edited my post at about the same time you replied) but I can't seem to make them globally accessible.
#88
I'm trying to have a few constants in my code, the reason is that several of my rooms start a timer, and the on_call function gets an argument that can identify what timer has ended. I wanted to use some named constants for these values for easy maintenance of the code.

I see in the documentation that AGS has some built-in #declare constants and macros, but I don't seem to be able to define my own. I noticed that the const keyword exists, but I can still change the value of that constant, so basically the const keyword doesn't seem to do anything,
Code: ags
const int my_value = 1;
my_value = 2; // <- In my opinion this line should cause a compiler error
Display("%d", my_value); // shows 2

[Edit]
Clarification:
I know I can use #declare, but I want them to be globally accessible, and I don't know how to do that.
#89
Quote from: Crimson Wizard on Mon 18/11/2024 16:35:08Maybe not as important here, but I'd like to clarify, that this is not the order of compilation that we are discussing here, but the order of dependency.
You're correct, if you want to be pedantic about it  :smiley: but all the preprocessing is still part of the compilation process even if it's not done by the actual compiler.
#90
Quote from: Khris on Mon 18/11/2024 12:54:30Also, the word "char" is a keyword and not allowed as variable name. Changing it to "cha" makes the code work as expected.
I know that char is reserved, I wrote this directly when I posted the question and used the wrong name.

I have a separate file apart from the GlobalScript file from which I have used the import in the header and it worked fine. Re-read my own reply to my original question for more information.
#91
I'm sorry, I was wrong above. The call to the function does work from a Room script, but I also needed to call it from another script. I noticed that I had to put the import in that script's header. I'm guessing this is because of how and in what order the scripts are compiled if the header is included or not.

But if I have several of my own scripts (ergo not Room scripts) how will I know in which order they will be compiled?
#92
Edit: I solved this part but it raised another question, read my own reply post.

Hello, in my GlobalScript file, I have a function like this:
Code: ags
bool KnownNPC(Character* char)
{
  // Some code that loops through an array and checks
  // if the character is in there.
}
In the GlobalScript.ash header file I then have the import statement.
Code: ags
import bool KnownNPC(Character* char);
I then call this function from a Room script, but I get an error with the undefined symbol 'KnownNPC'. Why is that?

I have other functions in a separate script and the import statement in that header file, but I need this function in my GlobalScript.asc file for a specific reason.
#93
Thanks buddy. Since I've already released my game I'll just use my own workaround but it's good to know that for the future that this has been mended.
#94
Yeah, that's what I thought, I usually don't download release candidates or beta versions.
#95
I'm glad that you could confirm this as a possible bug. If you just come to this site to download AGS you also get version 3.5.1, I don't know if 3.6 is still in preview or what but it doesn't seem to be the current official release version.
#96
That was in the first game. Melrin: The Deciple Ordeal, but I wouldn't really call that a joke though. But I kept it in the previously posted 20 annivercery remake of that game.
#97
Thank you, his name is however Melrin not Merlin. The rin part is actually added to magicians of his land when they reach the master level of the magic art, or already when they are ready for their final apprentice test. This is not revealed in the game but 18 years ago I had a fourth Melrin game planned and in the story I wrote for that it was reviled that that was the case, however, I never finished that game, so maybe I will do it this time around.

This game was really the third in the series but I decided not to make a remake of the second part since it was a pretty short game and by far the weakest in the series. This one however was always my own favorite (if I'm allowed to have a favorite of my own games).
#98
Melrin returns and in this adventure game, he is sent out to investigate a rumor that a dragon has returned after two centuries and is now pestering the countryside.

When the game starts Melrin already has three different items in his inventory, his book of magic in which you can read how to create various spells, his cauldron in which you mix ingredients to make the spells, and a magic map on which a new location automatically appears as soon as you've heard of it and you can instantly then travel between different locations.

You have to collect various items spread around the land and often combine different items to create new ones.




It can be downloaded here.
#99
Quote from: Shadow1000 on Thu 16/02/2023 00:33:01One thing I would recommend is to proofread the captions and iron out spelling errors.
Thanks for the review. Were there any particular spelling errors that caught your eye? I'm from Sweden so not a native English speaker.
#100
Thank you, I'm currently working on the remake of my third game in this series, Melrin: The Dragon Menace, I decided to not make a remake of the second game since it was kind of short, to begin with.
SMF spam blocked by CleanTalk