Q: I have a code but I don't know where to put it...help?
A: Depends on what the code is about..and how do you want it to work..So let's go through all the possible locations.
Note: I might have mispelled something. So check the manual if you get some error and tell me about it.
repeatedly_execute() //placed inside here, will make the code run every game loop.
game_start() //placed inside here, it will run once before the game starts.
on_event(eEvent,int data)//selecting a certain event and according to data value the code will run when something occurs.
Example:
function on event...
if (event == eEventRestoreGame) {
Display("Game just loaded savegame %d",data);//this will display the number of the savegame. Note that data refers to something different per event. Search the AGS manual for more info on specific events.
}
repeatedly_execute_always() //don't place anything with something blocking, because the engine will crash letting you know you did. This is a section to put stuff you want the engine to process faster. Example interface stuff.
mouse_click(MouseButton button) //this is the section that gets what mouse click you pressed. button is an enum for mouse button(emouseleft..ecc).
on_keypress(int keycode)//this is the section that gets the key pressed.
ROOM Sections:
Load()//this runs before the room is loaded.
AfterFadeIn()//this is a section that runs the code after the room has appeared and after first load.
Rep_exec()//same as repeatedly execute
Leave()//when player exits the room
First_Load()//when player enters the room for the first time.
Object/Inventory/Character/Hotspot:
The interactions available are based on mouse cursors(since those depict mouse modes).
Example:
function oDoor_Interact() {
//code here.
}
Regions:
-Walk_On/off//when player character walks on or off
-Standing//while player is standing execute code
Wednesday, January 14, 2009
Putting something in a script
Labels:
Characters,
Game Start,
Hotspots,
Interactions,
Inventory Items,
Objects,
Repeatedly Execute,
Room,
Scripting,
Sections
Opening Closing GUIS
Q: My GUI is open, my GUI is pausing the game, my GUI ate my homework..what to do?
A: Well, first of all a GUI via the interaction editor can be have four options when the game begins.
-Pause game when shown: apparently non-blocking animations and various scripts will wait till the GUI is closed. Also the GUI is non visible at the beginning of the game.
-Normal Initially On/Off: The GUI is initially on or off and doesn't pause the game when visible.
-Always Shown: Well, the GUI is initially on and doesn't close when a blocking interaction is run. Example: a Wait function. It is also initially on.
Now after selecting any of the options the way to close the GUI is placing this accordingly:
gGUI.Visible=false;//
or
gGUI.Visible=true;
A: Well, first of all a GUI via the interaction editor can be have four options when the game begins.
-Pause game when shown: apparently non-blocking animations and various scripts will wait till the GUI is closed. Also the GUI is non visible at the beginning of the game.
-Normal Initially On/Off: The GUI is initially on or off and doesn't pause the game when visible.
-Always Shown: Well, the GUI is initially on and doesn't close when a blocking interaction is run. Example: a Wait function. It is also initially on.
Now after selecting any of the options the way to close the GUI is placing this accordingly:
gGUI.Visible=false;//
or
gGUI.Visible=true;
Saturday, January 10, 2009
Closing Inv GUI when you select an item.
Q: How can I turn the inventory invisible when pick up a item from it?
A:
function repeatedly_execute() {
if ((gInventory.Visible==true) && (player.ActiveInventory!=null)) {
gInventory.Visible=false;
}
}
A:
function repeatedly_execute() {
if ((gInventory.Visible==true) && (player.ActiveInventory!=null)) {
gInventory.Visible=false;
}
}
GUI Button Sprite
Q: How can i change the GUI button sprite when some animation is rolling or an action occurring?
A: Well, either go via the interaction editor and find mouseover, pushed and normal on the interaction list of the GUI button, or script it.
button.NormalGraphic
button.MouseOverGraphic
button.PushedGraphic
Example:
Button1.PushedGraphic=10;//Where 10 is the number of the sprite in the sprites section.
A: Well, either go via the interaction editor and find mouseover, pushed and normal on the interaction list of the GUI button, or script it.
button.NormalGraphic
button.MouseOverGraphic
button.PushedGraphic
Example:
Button1.PushedGraphic=10;//Where 10 is the number of the sprite in the sprites section.
Saturday, January 3, 2009
Run Events Based on Time
Q: I want events to happen based on time, how do I do that?
A: Well, be keeping track of time. A way is by using integers.
Example:
int timer;
function repeatedly_execute() {
timer++;
if (timer==200) {
//event
}
if (timer==1000) {
timer=0;//reseting the timer back to zero, skip that if you don;t want your events to occur again and again.
}
}
A: Well, be keeping track of time. A way is by using integers.
Example:
int timer;
function repeatedly_execute() {
timer++;
if (timer==200) {
//event
}
if (timer==1000) {
timer=0;//reseting the timer back to zero, skip that if you don;t want your events to occur again and again.
}
}
Dialog Request
Q: I try to add a function on a dialog, but I got a weird error about identing lines.
A: Well, dialogs accept normal scripting only if the line is idented. That means if you want to add a function like cEgo.FaceLocation(x,y,eBlock); you have to do it like this:
@1
EGO: Hello?
cEgo.Face...//notice that there's a space before the function. It's done deliberately otherwise it won't work.
return;
Note: You can have either normal scripting and special commands that only work with dialogs at the same dialog.
A: Well, dialogs accept normal scripting only if the line is idented. That means if you want to add a function like cEgo.FaceLocation(x,y,eBlock); you have to do it like this:
@1
EGO: Hello?
cEgo.Face...//notice that there's a space before the function. It's done deliberately otherwise it won't work.
return;
Note: You can have either normal scripting and special commands that only work with dialogs at the same dialog.
Cutscenes
Q: How do I make a cutscene? Do I need one?
A: Well, if you have large intros or dialogs that you want the player to have the ability to skip, you should use cutscenes. All you need is to put a StartCutscene
example: StartCutscene(eSkipEscOnly); //will skip cutscene only if player press escape
and place an EndCutscene(); where the cutscene should stop.
A: Well, if you have large intros or dialogs that you want the player to have the ability to skip, you should use cutscenes. All you need is to put a StartCutscene
example: StartCutscene(eSkipEscOnly); //will skip cutscene only if player press escape
and place an EndCutscene(); where the cutscene should stop.
Subscribe to:
Posts (Atom)