How can I get this code to work?

Started by ginanubismon, Thu 02/04/2009 19:07:48

Previous topic - Next topic

ginanubismon

This is for an unusual came I am cooking up and when I had tried to compile the test room I get an error saying that the display code is wrong, there is there anything I am doing wrong?

And as an extra note I wanted this code to become active as soon as the character enters the room, is there a way to do so with having to click anything?



// room script file
function hHotspot1_Any_Click;
Display ("You are walking in the middle of the forest when a monster pops up.");
Display ("Press A to fight. Press B to flee. Press C to Hump.");
if (presskey(a)){
  Display("Grabbing a stick you fend off the monster until it gives up and leaves.");
if (presskey(b)){
  Display ("While running away the monster eats your head, sucks to be you.");
If (presskey(c)){
  Display("You sick bastard, the police is called and you are arrested for the attempted assualt on a monster.");
function hHotspot1_AnyClick()
{

}
"I shall call thee, Roger Ellison David Nicouli Etcher Calvin Kevin Sue in honor of what kind of a big jack@$$ you had been to guys like me." ADR -01 Jabberwock Type on fanfiction writers.

Khris

The function exists two times and the brackets are screwed up.
To run code directly after the player has entered the room, add the room's "player enters room - after fadein" event and put the Display code in there.
(Note that you can't react to the first key press since it only makes AGS remove the Display message.
Well, you can using the room's rep_ex and IsKeyPressed() but I wouldn't recommend it to a beginner.)

I'd use an Overlay to display the message, or a GUI with a label.

To react to keypresses, add the on_key_press function to the room script:

Code: ags
// room script

function on_key_press(int k) {
  if (k == 'A') {    // note the capital A, but this doesn't mean the player has to press shift-A!
    Display("Bla");
    player.ChangeRoom(...);
  }
  if (k == 'B') {
    ...
  }
  ...
}


If the player's going to have to decide between several paths in one room, you need to include a variable to be able to tell which question the player answered e.g. "a" to.

SMF spam blocked by CleanTalk