Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: nightmarer on Sun 10/10/2021 23:15:09

Title: Global Script house keeping
Post by: nightmarer on Sun 10/10/2021 23:15:09
Hello.

My global script is growing and growing, and now it is so long that it is really difficult to read.
How it would be the best solution to keep all the Character and inventory interactions in separated scripts?

Regards.
Title: Re: Global Script house keeping
Post by: Slasher on Tue 12/10/2021 04:38:14
Use Modules...
Title: Re: Global Script house keeping
Post by: Khris on Tue 12/10/2021 07:39:26
You should find a bunch of existing topics about this; the general idea is to use CallRoomScript or modules to distribute the code among other scripts.
Title: Re: Global Script house keeping
Post by: fernewelten on Tue 12/10/2021 18:50:35
The trouble with modules is, a lot of event functions must reside in GlobalScript.asc, the character and inventory events among them.
You can, of course, do something like

Code (ags) Select
function cEgo_UseInv()
{
    EgoUseInv();
}

move EgoUseInv() into some script module and let EgoUseInv() do the real work. But the stub that calls EgoUseInv() will still muddle up GlobalScript.asc.
Title: Re: Global Script house keeping
Post by: nightmarer on Tue 12/10/2021 22:09:09
I see, then I don't have too much to do.