Hi everyone, hope you're all doing well. :)
Trying to do something that should be really simple:
1. Play an audio file of some loud wind.
2. After about 2 seconds, to make the wind sound decrease its volume gradually from 100% to about 50%.
3. Play a speech file.
I tried doing it manually but then read that the Tween module can be used for this. However, when I import it to my project, the moment I test my game (without writing any code related to the module yet), it gives me this error message and takes me the module script:
Tween1.asc(1275): Error (line 1275): Undefined token 'inventory'
The code in line 1275 is: inventory[this.RefID].SetProperty(this.StringRef, _value);
If I remove the module and test my game it runs successfully. It's only when the module script is present in the top of the Scripts tree that it gives this error.
Any help would be appreciate. And if there's another recommended way to achiving what I'm after I'm open to hear and learn.
Thanks!
The standard "inventory" array is generated only if you have at least 1 inventory item.
Create 1 dummy item in your game, and this problem will be solved.
This refers to few other arrays too, the problem is explained here in more detail:
https://adventuregamestudio.github.io/ags-manual/GlobalArrays.html
Oh, got it. Thanks
@Crimson Wizard!
Quote from: Crimson Wizard on Sat 12/08/2023 00:40:51The standard "inventory" array is generated only if you have at least 1 inventory item.
Create 1 dummy item in your game, and this problem will be solved.
This refers to few other arrays too, the problem is explained here in more detail:
https://adventuregamestudio.github.io/ags-manual/GlobalArrays.html
It occurs to me that if AGS #defined a constant to indicate whether each built-in array existed, it would make it possible to write more robust modules that avoided/worked around this problem.
Alternatively, AGS should always declare an inventory array. If there are no inventory items, simply make it empty.
I mean, the problem is evidently that you cannot have 0-length arrays.
Of course, if 4.0 moves towards making it possible to create new items etc. programmatically, a very different approach is probably needed in any case, so this may not be a long-term issue.
This is possible in a bunch of languages like PHP or JavaScript where you can declare an empty array by assigning [].
It doesn't seem to be possible in C++ though.
Since inventory items start at ID 1 anyway, inventory[0] seems to be a dummy item. Why not define the array with a length of 1 then, if no items exist?
And if you create items programmatically, there should still be a global array where you can iterate over all items, so I don't think inventory[] is going to disappear?
Quote from: Khris on Mon 14/08/2023 16:48:10And if you create items programmatically, there should still be a global array where you can iterate over all items, so I don't think inventory[] is going to disappear?
In that case there can't be a static array, so if anything it will have to be a Vector or something, and the problem goes away.
I wonder if the solution is to support zero-sized static arrays in AGS script...
In practice it already supports instances of zero-sized structs.
(Although the new compilers throws a warning when this happens)