AGS Editor & User Interface

From Adventure Game Studio | Wiki
Revision as of 13:10, 29 November 2005 by *>Dasjoe
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Editing Displaying close-ups of inventory

I have an inventory item that I want to display a close-up of when the player looks at it. How do I do this? Is there some sort of top-secret function or code that you guys are not sharing with us beginners? Let's have it, oldie!

No. Think about it a little bit. Have you read the manual and learned about GUIs yet? Although I shouldn't have to tell you this, a GUI is like a separate "window" where you can display anything from text boxes and list boxes, to buttons and labels. Buttons can also just be plain images. Basically, there are two different ways that one can do this: use a separate room, or use a GUI.

With a separate room, you will have to make sure that once you are done with the close-up room, you have code in the first room that, once you return to it, it will place you at the same place you were when you looked at the item. You might have to use global variables for this (check the manual regarding them). So basically, in the "Look at inventory" interaction script, write the command to change the current room to whatever room number you choose as the close-up room. Then, in the "Player enters room (after fade-in)" script, write the script to display a description of the item, then wait a little bit perhaps, then change rooms to the player's previous room (character[ABC].prevroom or cAbc.PreviousRoom for AGS V2.7 and newer).

When using a GUI for the close-up, it's rather simpler than using a separate room, and you can even have the close-up cover only a large portion of the room, and not replace it entirely. So, create a new GUI and put in a button that you will use as (1) an image to display the close-up, and (2) a method of getting rid of the GUI to go back to the room (by clicking on it). After you create the GUI and set the colors and settings you want, create a button and resize it to your liking. Set the image to the close-up sprite (after you import the image, of course), and set the button's property to "Run script". In your global script, you should see an interface_click function. Inside, there are a collection of if/else if commands. These check to see what GUI (interface) was active and what object (generically called button) was clicked on it. Let's say that you created GUI #6. In the code, add an else if command to check if interface passed 6 as a value. If you are only having an image/button in your GUI, you do not need any other if code to determine which button was clicked, because there is only one possibilty for that GUI. Then, insert the code that will close down the GUI. To activate the GUI, put the code in the "Look at inventory" interaction event, just like above.

Simulating 3D distance perspective with scalable walkable areas

I have X-number of walkable areas in my room, with incrementing values of scaling, to simulate realistic 3D perspective. But my character looks jerky when (s)he changes size. What can I do?

AGS has a feature called continuous scaling. Simply create one walkable area, and set the top ("rear") and bottom ("front") scaling percentage values, and your character will be scaled smoothly from small to large. TIP: AGS also shows you the percentage value at a certain Y-coordinate within the walkable area. This is great for creating a walkable-area within a walkable-area for, say, lighting effects like street lights and shadows, where you want the scaling to say consistent.

Characters walk over/through things; Characters shift suddenly sometimes

My walkable areas and walk-behind areas are finished and work fine, except for one thing: parts of my character will sometimes shift suddenly, OR will seem to walk right through things at times.

Well, since the X-Y coordinates of a character are located at the center of the bottom edge of its sprite, the feet can sometimes walk off some walkable areas (and appear to go into/through the walls), or even walk through stuff. To solve this, simply allow more room. Don't put the edges of walkable areas right at the wall; instead, leave 10 pixels or so of room between the WA edge and the wall. The same goes for walk-behind areas in the room: leave some room while making the walkable areas around the walk-behind areas so the character won't pass through the WBAs abruptly.

Deleting stuff besides sprites and frames

Can I delete stuff in the editor somehow, besides sprites and animation frames? For example, can I delete characters?

No. If this were possible, then beginners could potentially screw up their game big-time. To avoid frustration and accidents, Chris has disabled the deleting of most things. But what if you don't need that extra inventory item for now? Or what if you don't want that extra GUI you created? Although you can now delete GUIs in AGS, there is an alternative. Just set the GUI so that it never appears (Set it to "Popup Modal"), or simply never refer to the inventory item. If you can't delete it, ignore it.

To delete a GUI, just click the "Delete this GUI" button. WARNING: You must be very careful in doing this, as items in AGS are referenced by number; if you delete a GUI that is not the last in the list, the GUI IDs will be renumbered. As a result, it is possible that your game's script will refer to the wrong GUIs or even a non-existing GUI, causing crashes that end up being difficult to track. Fortunately, you have a name for each of the GUIs. If you only refer to them with their script names (i.e., you didn't type in the exact GUI IDs in your scripts), simply recompile all the rooms (Game -> Rebuild all room files) and then save the game.

You can also delete GUI objects in the editor. Just select the object and hit the DEL key. WARNING: You must be even more careful in doing this, for the same reason mentioned above. Unfortunately, currently you cannot set a name for GUI objects, so you have to fix your script manually if you really want to delete a button or a label.

Room objects can also be deleted by right-clicking now. Use the same caution as above for this feature. For fonts, characters, views, inventory items, etc., just re-use them as advised above or just leave them alone. They don't contribute much to file size anyway. Note that the deletion of items is only meant to used by experienced users, and remember to BACKUP your game before doing any such hazardous acts!

We understand the desire - the need - to "clean up" after yourself, so to speak. But keep in mind that sometimes it is better to simply leave unused items alone (or until you can reuse those slots). There is no significant increase in memory usage or filesize anyway.

As for characters, why delete them when you can just re-use them? If you have one too many character slots, just don't use that last character slot.

Reverting back to default AGS fonts

How do I EASILY revert my game to all of AGS's default fonts?

Close AGS, and then delete any files named "agsfnt??.wfn" or "agsfnt??.ttf" files from your game's main folder. Then, restart AGS and load up your game. Voila! Back to the defaults.

A newer and much easier way is to click the "Revert to defaults" button in the Fonts pane of the AGS Editor. This will revert the font choices to 0, 1, and 2 (the original SCI fonts) and will DELETE all the other fonts. As fonts above #2 are deleted, make sure you did not refer to any fonts other than 0, 1, or 2 in your game, or you will need to fix pesky crashes in your game yourself.

An explanation of split resources (".001" files, etc.)

What exactly is stored in the split ".001", ".002", etc., resource files?

Glad you asked. The split resources only contain room data. Sprite data is always stored in the basic executable.

Renaming "winsetup.exe", and its function

Is it safe to rename the "winsetup.exe" file? I DO want my game to be ultra-customizable and super-awesome, y'know!

No problem. You can rename winsetup.exe to anything you'd like; it will still work. In fact, all the winsetup.exe program does is call "game.exe -setup". That's all.

Actually, winsetup.exe is useful, as most people just playing AGS games may not know the "game.exe --setup" trick. Simply creating a batch file won't work for some Windows NT based systems. Using a Windows shortcut is not practical as you shouldn't force the player to install your game in some fixed folder. So, please, include winsetup.exe (or whatever you rename it to) when you distribute your game.

Changing dialog speech colour

How do I change the dialog speech colour? Is there some hidden text script function? Is there some hidden editor setting? Is it even possible???

The dialog options are drawn in the player character's talking colour. The highlighted option colour uses the GUI foreground colour if you are using a GUI TextWindow. Otherwise, it is hardcoded to yellow. Maybe in the future there will be a way to change this, but for now, deal with it!

Using joysticks or game controllers in AGS

Is it possible to use joysticks or gamepads for game control in AGS?

No, not currently. Sorry!

SCI fonts and creating them

I see that, in addition to TrueType fonts (TTF), AGS also supports a font format called SCI. What is it, and how would I create my own fonts using SCI?

SCI (Sierra Creative Interpreter) refers to the game engine that used such a font. SCI fonts are bitmap fonts, in that they cannot be resized like TTF fonts can.

The only standalone programme out there that creates and edits SCI fonts is Radiant's Font Editor. I haven't tried it myself, but it seems to be the only stable option for creating SCI fonts out there. Unless you want to use SCI Studio to do it, but it's a bit much to download an entire game engine just to create fonts.

Also, note that AGS can only display the first 128 characters in a SCI font set, symbols with ASCII value larger than 127 can only be displayed if you use a TTF with a translation file.

Disabling right-clicks in your game

How do I disable right-clicks in my game? Do I have to use script? Is there some other action I can take?

There are many ways to disable right clicks in your game. If you only need it done in one room, then use the following script in each of the room's main scripts:

 function on_mouse_click(int button) {
   if (button==RIGHT) ClaimEvent();
 }

This will prevent the global script's on_mouse_click function (or any other on_mouse_click function for that matter) from reacting to right-clicks. Since there is nothing else in this function, nothing will occur when the right mouse button is clicked within that room.

To disable right mouse clicks throughout the entire game (for your own interface, for example), find the on_mouse_click function in the game's global script, and find the section that detects if the right mouse button was clicked (it's the else part in case you couldn't find it), and erase everything (usually just SetNextCursorMode();) between the braces. That section should look like below:

 function on_mouse_click(int button) {
   ...
   else { // right-click, so cycle cursor
 }

Another way to disable right mouse clicks globally is to disable all the other cursor modes, so that only the WALK mode can be used.

Templates: What they are, and how to use them

What are templates and how would I implement them into my game?

Well, templates are pre-made sets of GUIs and code for your game, and are stored in files ending in ".AGT". In order to use them in a NEW game, simply copy that .AGT template file to the main AGS folder on your computer. Run the AGS Editor, start a New Game, then highlight the GUI template from the list. Enter a name for your new game, and that's it.

For a game IN PROGRESS, you will need to copy all your pre-existing characters, rooms, code, and graphics over to a newly set-up game as shown above. That's it!