Adventure Game Studio | Forums

AGS Support => Advanced Technical Forum => Topic started by: nightmarer on 10 Oct 2021, 23:15

Title: Global Script house keeping
Post by: nightmarer on 10 Oct 2021, 23:15
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 12 Oct 2021, 04:38
Use Modules...
Title: Re: Global Script house keeping
Post by: Khris on 12 Oct 2021, 07:39
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 12 Oct 2021, 18:50
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: Adventure Game Studio
  1. function cEgo_UseInv()
  2. {
  3.     EgoUseInv();
  4. }
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 12 Oct 2021, 22:09
I see, then I don't have too much to do.