What's the best way to organize your scripts?

Started by Scorpio82, Fri 22/09/2006 04:30:32

Previous topic - Next topic

Scorpio82

 This is probably just because I'm a newb when it comes to programming, but in terms of AGS, is there a right way to organize all your scripts? 

At the moment, I've put together several scenes, but my programming is all over the place.  For example, in one scene, I have a character standing in a kitchen who walks over to the table and drinks his coffee when you click it on him.  This is a scene-specific animation, but as it turns out, I couldn't find a way to put this scripting right inside the room.  Instead, I had to place it in the character's interactions outside of the room script.  This may or may not be the way I'm supposed to do it, but I thought I'd check in first just in case there's a smarter and cleaner way I should be doing it.

My other problem is with display messages vs. those message windows.  In some cases, a message window is available and I can keep all my dialogue cleanly organized in an easy-to-customize list.  In other cases, the "Display a Message" can't be used because scripting needs to go with it, so then I have to place the dialogue inside an out-of-the-way and easy-to-miss-later-on "Run Script" command. 

I'm sure I'll get better at this as I go along, but if anyone can give me a heads-up on what to expect when programming AGS, that would be really helpful.

Khris

1. Characters are room-independent, so their interactions have to be in the global script. There are two ways to tidy up things a bit.
The first one is easy, use CallRoomScript(). You'd still have the character's code in the global script, but it's only one line.
The long script containing movement and the like would be back in the room script.
The other way is to cheat a bit: Display an object using the character's current sprite directly before him, then put the script in the object's interaction function. Turn off the object, then proceed to move/animate the char like before.
You can even put all character and inventory related stuff into a module to keep it out of the global script.

2. I'm not exactly sure what you mean since I don't use the Interaction editor for anything else than to add RunScript commands. Sooner or later you'll do the same, so that issue should resolve itself.

Basically, as you get more experienced, you'll come up with your own way to organize your scripts.

Scorpio82

 Ah, geez.  It's starting to make a lot more sense now.   Stupid me.  :)

All that stuff in the character and inventory interactions goes into the global script regardless.    At first I thought the global script just handled basic things like the interface, until I actually started going through it line for line.  I misread something in the reference.  That's where I was confused.  Plus I put some inventory messages in a room instead of the global script and lost them for a while.

Thanks for the tips, though - I'm sure I'll get better at this as I go along.  I'm already considering doing more things by the "Run Script" command.

SMF spam blocked by CleanTalk