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 - Crimson Wizard

#3261
Quote from: rongel on Wed 05/01/2022 20:39:31Just curious to know what kind of impact things like these have on the gameplay.

Computers today are quite fast, and even if game runs at 60 fps there's a lot it may do in one frame without slowing down.
Recalculating text's width and changing button's position won't have any noticeable impact.
Still, my advice is to try not to do obviously wrong things, as bad habits persist, and excessive script work may once accumulate to something serious.

AGS does not have much diagnostic features builtin, but there's a "infinite FPS" mode that may be turned on. It will run the game updates as frequent as it can, and displaying fps counter on screen.
To turn "infinite fps" mode you need to run your game exe from command line as "game.exe --fps". Then during the game press Ctrl + E to toggle the mode. In simple games FPS may easily reach thousands.
This mode is useful to see the impact of some actions, as with very high fps numbers it will be easier to spot a relative difference. For example, a difference between 60 and 59 fps may not catch your attention, but if it drops from, say 1500 FPS to 500 in some room, that may be a reason to wonder what is happening.
#3262
Quote from: arj0n on Wed 05/01/2022 18:23:15
Do you have an example of a case where the 'game fixing its data files' may not work?

If the data files are located in read-only location, either technically cannot be written to or player does not have enough permissions on their system to write there.


Anyway, tbh, overwriting whole file only to let engine read it again properly, sounds like an overkill.

What about reading a file first, and then reading last character separately if it was not read? You can compare the length of the returned String with the length of the file and if it's shorter - then read the rest yourself.
#3263
Quote from: rongel on Wed 05/01/2022 16:36:27
I tried to use GetTextWidth command to count the characters from the label, but got nowhere.

Why not? please tell what you did and what happened.
#3264
Quote from: arj0n on Wed 05/01/2022 15:23:03
My workaround is very close to your suggestion: In stead of always adding an extra linebreak I now first read the last char of the selected file, and if this is not a LF then WriteRawChar (10).

Well, this works so long as the file is writeable by the game; but the game fixing its data files may not work in some circumstances.
#3265
Well, there are modules that do that, you have to setup objects in script though.
For instance, this is the recent one: https://www.adventuregamestudio.co.uk/forums/index.php?topic=57489.0



It's of course technically possible to have this in the engine itself, and may be quite easy to do on its own, but one have to come with a good concept of how this suppose to work, because room objects in AGS have multiple functionalities that may contradict parallax effect, so it's important to figure out the design first.
#3266
Strictly speaking it's Game.Camera.X.
If you want to keep using old command, go to General Settings -> Backward Compatibility -> Script compatibility level: set to some level < 3.5.0.

For the futher information:

1. These old commands are still present in the manual, and if you look in their articles, they usually have something like "This function is obsolete since AGS X.X.X, use function N instead".
2. Every time there's a major release there's an article in the manual called "Upgrading to X.X.X". If any commands were changed this is explained there. For example viewport/camera changes are explained in "Upgrading to 3.5.0": https://adventuregamestudio.github.io/ags-manual/UpgradeTo35.html
3. Also now we have a full table of obsolete functions with their replacements for quicker reference:
https://adventuregamestudio.github.io/ags-manual/ObsoleteScriptAPI.html
#3267
@Icey, you need to read the description given in the first post (under the spoiler), it explains how to setup "PxPos" custom properties.

Custom properties are the way to add new values to game objects. Topic covering custom properties may be found in the manual: https://adventuregamestudio.github.io/ags-manual/CustomProperties.html
#3268
Screen.Viewport.X/Y is where the room is displayed on screen (0,0 by default) and is defined in screen coordinates.
Game.Camera.X/Y is which part of the room is currently visible (can scroll around the room) and is defined in room coordinates.

If Water_light is a Room Object, then it's position is set in room coordinates.

So likely, you need to write
Code: ags

Water_light.X = Game.Camera.X;
Water_light.Y = Game.Camera.Y + 559;


EDIT: the eri0o's solution from below might also work.
#3269
Quote from: Cassiebsg on Sun 02/01/2022 23:43:50
Yes, though I think the way it works now is somewhat misleading and requires ppl to know how it works. It's really not clear.
It would be nice to not have things not running "hidden & automaticly" in the BG.

Suppose, I could add a command into a context menu saying "Update from source", and maybe a checkbox in Preferences to switch autoupdate off. Would that be better?

1. If we have this as an option, I may immediately see a problem: this lets Editor work in two "modes", where in the first the AudioCache is synced with the sources, and in the second it is not. In the second case AudioCache is detached and a kind of source itself, and audio files in it are separate variants from the ones in the source.
As a consequence, in the first "mode" the AudioCache folder is safe to delete, because it's supposedly just a copy of sources, and automatically restoring from sources is always wanted.
In the second "mode" it will NOT be safe to delete, as it's not an automatic copy, but a separate variant, not necessarily identical to the source, and automatically restoring from sources may not be wanted.
I'm concerned that this will increase the amount of trouble finding out how the editor works, and will make advising users difficult, because you will have to know which "mode" they are working on. For instance, right now I always say that it's safe to delete AudioCache / not store it inside the source control repository, so long as you have originals in the initial location, because editor will restore the cache from sources. If the above change is made, I would have to double check whether user autosyncs or not syncs AudioCache with the sources.

2. So, let's suppose that the more "proper" way would be to completely remove the autosyncing. In which case we have "mode two", where AudioCache cannot be safely deleted unless user is absolutely certain that the sources contain the variant they need for this game. Of course this also will screw everyone who is used to work with sources, editing them and expecting that the game catches them up. As well as will make storing source audio files inside the project folder unnecessarily increasing the project size, as Snarky mentioned above.

3. The third alternative, which just came to my mind, is this: if the source files are located in the relative location inside the game folder, then they are autosynced. Because if user put them into the project, they likely want these to be used automatically.
Otherwise (if they are somewhere outside) - they are not autosynced.
Again, I have no idea if this is convenient. Good systems are simple systems, that work one way.




I should also mention, that at least some developers (including me) would like to move towards having all the game resources directly in the game folder, so that there are no intermediate "caches", then a user may work with files directly in a specifically designated folder.
I.e. right now there's a change to room formats in works, that stores rooms split into its components, with backgrounds, masks etc as separate files that may be edited at will using any external editor (image editors etc).
#3270
Ok, so eri0o is back now, and we continue to update Android tasks, so there's some hope :).
#3271
Quote from: Pajama Sam on Sun 02/01/2022 03:50:39
Something must be wrong with the sound type that I made because after using a different type in the script it worked.Could you try to find out whats wrong with the sound type.Here is the game
https://www.mediafire.com/file/00qgxweicquzs4n/OceanBound.7z/file

So, apparently there's both a mistake in game AND mistake in the engine.

In the game you reserve 8 channels for your sound types (Ambient: 1, Music: 1, Sound: 5, talk: 1), but engine only can give you 7 (because 1 is reserved for the speech). So you are trying to reserve 1 channel more than available.

However, there's some mistake in the engine, and it places your "talk" type sound on a special "hidden" channel which is normally used for some internal purposes (when crossfading tracks).
Both Game.IsAudioPlaying, and Game.StopAudio do not check that "hidden" channel because it's outside of normal channels. So they never detect and stop your sound.

The solution for now is to reduce one of the previous type, like, make Sound type to have 4 channels instead.

But the engine definitely has some bug that lets you force a sound onto the channel with index above 7, which also may lead to crashes if it's higher than 8. I could swear that I fixed this engine bug before, but maybe I fixed it in 3.6.0.
EDIT: right, it was fixed in 3.6.0. I might make another patch to 3.5.1, while 3.6.0 is still in works, as this is quite an annoying bug and may make it difficult to understand what's going on.
#3272
Quote from: Pajama Sam on Sun 02/01/2022 00:56:28
I checked to see if its under the right type and it is.

How do you check this? Just in case, the audio type is set in the sound clip's property, or sound folder's property, but it is not the name of the sound folder.

Quote from: Pajama Sam on Sun 02/01/2022 00:56:28
And I placed this into on key press.Im not sure what you mean by event handler.I dont see a function by that name in globalscript.

"event handler" is a function that is called on some event. on_key_press is one of the possible event handlers. It is added by hand (some game templates already have it in global script).
https://adventuregamestudio.github.io/ags-manual/Globalfunctions_Event.html
#3273
I may confirm that this code works in a simple test game, so, as eri0o suggested, I'd first of all check if your clips actually have the correct audio type set.
Secondly, maybe double check how they are started, and if there's some code that quickly restarts them right after they were stopped.

On the other hand, the usual way to handle key presses is on_key_press function. Is there a reason why you are not using that, but IsKeyPressed in rep-exec-always?
#3274
Quote from: Snarky on Fri 31/12/2021 09:35:14
I would like to request similar functionality for audio clips. Sometimes you need to update the audio for whatever reason (for example to adjust the volume for consistency), and currently this requires a whole sequence of steps to replace the clip in AGS (or the "hack" of overwriting the file in the AudioCache). It would also be useful if a missing AudioCache directory could be automatically recreated from the source files (to save space with source control tracking).

I believe all this must work already, with editor checking audio timestamps of the source files. AudioCache is also supposed to be fully recreated if missing, so long as the source files can be found on their remembered locations.
Does it not?

I only remember that there has been a bug occuring under certain conditions:
https://github.com/adventuregamestudio/ags/issues/778


PS I remember to never keep AudioCache under the source control for all of my team projects, and it always worked iirc.

PPS In regards to sprites, we have a ticket for "recreate sprite file" feature, and I believe it's doable, with the exception for the sprites imported from clipboard (when you do Ctrl+C/Ctrl+V from a image editor), as these cannot have a source file reference.
#3275
In AGS currently the sounds are modified by accessing the channel they are played on.
At the moment it is possible to change Volume and Speed.

Here's the related articles in the manual:
https://adventuregamestudio.github.io/ags-manual/AudioChannel.html



Quote from: Pajama Sam on Fri 31/12/2021 18:40:33
so you cant play a sound in repeatedly execute.

You can, but if you do that unconditionally, then it will start over every game frame.
What Snarky said is that your script logic should be fixed, for example to not replay same sound until the previous instance has stopped.

EDIT: or, alternatively, you may play looping sound as Sound.Play(eAudioPriorityNormal, eRepeat), and stop it when the player releases the key.
#3276
Quote from: Pajama Sam on Sat 01/01/2022 05:17:50
Code: ags

function object_AnyClick()
{
   Sound.FadeIn=-or+ number;
   Sound.FadeOut=-or+ number;
}


By "fade" do you mean volume? You may adjust the volume from the channel returned from Play function.
Code: ags

AudioChannel *chan = aSound.Play();
...
// later
...
chan.Volume += 1;


More info in the manual: https://adventuregamestudio.github.io/ags-manual/AudioChannel.html


Quote from: Pajama Sam on Sat 01/01/2022 05:17:50
I would also like to suggest making the scripting text size adjustable in prefrences.

Scripting text may be changed with Ctrl + Mouse Wheel, the only problem at the moment is that it does not save, so you have to do it every time.
I guess it should be possible to save the script font size in user settings.
#3277
Normally, if the audio type runs out of channels, then it either replaces one of the active sounds with the new one, or does not play a new one at all (this depends on clip priority setting).
Game crash would mean that something is wrong.

Regarding game upload, there is a number of free file host services, personally I know Dropbox, Mediafire and Google drive, but there should be many more.
#3278
I think that the number of channels is an issue in the first place because of how AGS system works: right now is made so that the channel always have a one individual clip bound to it, and also the script channel directly corresponds to the sound source object in the sound library we're using.

If this system was changed to something different, e.g. allowing multiple clip playbacks going into the same channel, then the channel number would be much less of an issue (or not at all). For example, the above case of piano simulation could be rather solved if there was a Sound Mixer API, where you could merge multiple sounds on the same output channel (guess the meaning of a "channel" would change also in such case).

So I believe that instead of keeping increasing sound channels in its current form, it might be more optimal to redesign the system into something that allows more flexibility with the sound.

There has been a topic opened couple of years back, but unfortunately everything is postponed:
https://www.adventuregamestudio.co.uk/forums/index.php?topic=56079.0


Quote from: Pajama Sam on Fri 31/12/2021 00:55:28
If the user was to make a chord or play too fast before the channels freed up the game would crash.

It should not crash, unless there's some mistake either in script or in the engine. Could you post an example of the game that crashes?
#3279
Quote from: arj0n on Thu 30/12/2021 16:11:58
note:
As a test, if I add an empty line after the last line (after the title line) the
complete title, including the last character, is correctly read. But that would
not be a solution for my problem as these files are (and should be) exported
without adding an extra empty line.

Oh, I did not notice this at first.

I think it should also be possible to use File.ReadRawChar() and read byte by byte until the line break to get a line. Thus essentially scripting your own "Read Line".
This will be relatively slower (because of the many function calls in script) so may not be a good solution if files are very large.
#3280
This is a known bug, someone else recently discussed this on AGS Discord.

The workaround is to always add an extra linebreak at the end of the file.

This seems to be fixed in 3.6.0.
SMF spam blocked by CleanTalk