Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Ashen

#2661
Well, buttons can have the value 0 but, again assuming I'm looking at the right tutorial, object 0 on your GUI would be the label. So yes, you probably want button 1 to quit, button 2 to keep on playing.

QuitGame (1); will ask you to confirm quitting (i.e. bring up the built-in Quit GUI, after your custom one), while QuitGame (0); will just quit when you press the button.
#2662
You need to be a bit more specific about:
- What code you're using.
- Where it is.
- What it's doing (i.e do you get an error message, or does it just not work).
- Which version of AGS you're using.

As far as I can tell - and assuming I'm looking at the right tutorial - the code is still good, except maybe with the more recent betas.
#2663
1.
Try replacing it with:
Code: ags

player.ActiveInventory.GetName (buffer);

I think the problem is that inventory[player.ActiveInventory]. returns the item number, whileGetName requires a Script-O-Name (e.g iKey.GetName). That's kind of how it looks from the other InventoryItem functions, anyway.

2.
Yes, it looks that way.

On an unrelated note:
Evil Valentine's day start-up screen! Evil!
#2664
TheMagician:
No problem, I figured there'd be a few bits I didn't explain properly.

1.
No, it imports the AskYesNo () function (as created in the global script, in your second quote) so it can be used anywhere in game, e.g. on hotspots, objects, etc. If you're only likely to use the function in GUIs, I don't think you even need this line.

2.
Ask is one of the options for the AnsYesNo enum. When you set response to Ask (e.g. AskYesNo (Quit, Ask);), you're telling the function that it's asking the question, rather than replying.
The 'Answer run' refers to the second time the function is called, by the GUI buttons. 'asked' is a global int storing the question that had been asked, to pass in the 'Answer run' (see below).

3.
Eeep! That's what you get for working across AGS and 2 instances of Notepad. The 'Answer' function was an earlier way I had this working, which doesn't exist any more. That bit should be:
Code: ags

if (interface == ASKGUI) {
Ã,  if (button == 1) AskYesNo (asked, Yes);
Ã,  if (button == 2) AskYesNo (asked, No);

Thanks for pointing that out! I'll edit my first post in a minute.
Yes, asked is set to quest - it's the only way I could think of to track which question had been asked.

Would it be usefull to you, if I worked out and posted the non-OO version of the script? Obviously, you wouldn't be able to use enums, but the rest of it should work, and it might give you a better idea what's going on.

EDIT: Got bored, made something else.
AskYesNo Module
Zip contains:
Ã,  Ã,  Ã,  - Importable AskYesNo module.
Ã,  Ã,  Ã,  - Documentation. Really bad documentation.
Ã,  Ã,  Ã,  - Non-OO Script, with equally bad documentation.
Enjoy.
#2665
O.K. so I was meant to be cleaning out the garage, instead I've come up with this:

In the header:
Code: ags

	enum AnsyesNo { No, Yes, Ask};
	enum Question { Overwrite, Quit, //etc};
	import function AskYesNo (Question quest, AnsYesNo response);


2. In the script:
Code: ags

	int asked;

	function AskYesNo (Question quest, AnsYesNo response) {
	Ã,  asked = quest; // Stores question for Answer run
	Ã,  if (quest == Quit) { // For example
	Ã,  Ã,  if (response == Ask) {
	Ã,  Ã,  Ã,  LblAsk.SetText ("Are you sure you want to quit?");
	Ã,  Ã,  Ã,  BtnAskYes.SetText ("Quit");
	Ã,  Ã,  Ã,  BtnAskNo.SetText ("Play");
	Ã,  Ã,  Ã,  gAskgui.Visible = true;
	Ã,  }
	Ã,  Ã,  if (response == Yes) {
	Ã,  Ã,  Ã,  QuitGame (0);
	Ã,  Ã,  }
	Ã,  Ã,  if (response == No) {
	Ã,  Ã,  Ã,  gAskgui.Visible = false;
	Ã,  Ã,  }
	Ã,  }
	}


3. In interface_click (object 0 = the label 'LblAsk', object 1 = yes button 'BtnAskYes', object 2 = no button 'BtnAskNo'):
Code: ags

	if (interface == ASKGUI) {
	Ã,  if (button == 1) AskYesNo (asked, Yes);
	Ã,  if (button == 2) AskyesNo (asked, No);
	}



A little explanation:
The function is in two parts - question and answer. If AnsyesNo is passed as 'Ask', the function sets up the ASKGUI - sets the label text and Yes/No button text (Quit/Play, Overwrite/Cancel, etc), and turns the GUI on. If AnsYesNo is passed as Yes or No (i.e. by the GUI buttons) it responds accordingly.

For convenience, I've enum-ed the possible questions and answers (Yes/No/Ask), and I've used the OO scripting style, but it should be easy to reverse engineer, if anyone wants to.

It's probably a little clunky, but it works (for me, anyway). Feel free to modify, or to ask if anything doesn't make sense.

(EDIT: Corrected interface_click script)
#2666
I thought 'Aristocrat', which might link to Trapho's 'vampire' - it's probably that the coat looks more like a frock-coat kinda thing than a lab coat, which tend to button up past the waist (in my limited experience), and not have such high collars. Also, for some reason the face reminds me of Alan Cumming. I don't know if this is a good thing or not.
#2667
I tried 'Cat' as well, and let it win when it guessed 'kitty cat', but it also has 'cat' as an option.
Anyway, I won! But it nearly had me at 29 questions:
Quote
I am guessing that it is a ladle(scoop/spoon)?
Yes , Ã,  No Ã, , Close
29. Ã,  Ã, I guess that it is a tea cup? Close. Ã, 

I was thinking 'mug'. 'Coffee mug' was on the 'Is it one of these...' list it gave me - strange that it thought a ladle was more like a teacup than a mug is.

On a similar note has anyone tried this:
http://www.smalltime.com/dictator.html
'Guess the Dictator or Sit-Com Character'. It's surprisingly good at it, too.
#2668
Key presses aren't handled when the game is paused, e.g. by a popup modal GUI, because of the first line of on_key_press:
Code: ags

function on_key_press(int keycode) {
Ã,  if (IsGamePaused() == 1) keycode=0;Ã,  // game paused, so don't react to keypresses
Ã,  //codes for other keys
}


So, assuming your Quit GUI is popup modal and that's the problem, something like:
Code: ags

function on_key_press(int keycode) {
Ã,  if (keycode==13) && (IsGUIOn(QUIT)==1) {
Ã,  Ã,  Code for the action
Ã,  }
Ã,  else if (IsGamePaused() == 1) keycode=0;Ã,  // game paused, so don't react to keypresses
Ã,  //codes for other keys
}

Anything else you wanted to happen when the game was otherwise paused should also go above else if (IsGamePaused() == 1) ....

Also, have you actually created the on_keypress function in your script, or is that just how you've typed it here? (EDIT: I thought it might be, but it doesn't hurt to check these things.) The function on_key_press already exists, so your function wouldn't do anything.
#2669
Sorry about that - looks like Candle and I posted over each other. Anyway..

So, it's just in the room script? That's why you get the 'Unexpected Command' error - commands aren't supposed to go there.
When do you want it to happen? I'm guessing it's when the character enters the room, so try putting it in one of the Player enters screen interactions - (before fadein) is probably best, otherwise you'll see him turn. If you don't know what I'm talking about, it's the red 'i' button  (or CTRL-I), next to the edit script '{}' button.
#2670
I think LeChuck means to use variables - that's the most logical way, anyway.
The example assumes you're using scripting, in which case you could just copy that code into the Use Inventory on hotspot interaction. If you're using the interaction editor, however, you need to:

1. Open the Interaction editor, and add a new action under Use inventory on hotspot - the 'Conditional - If inventory item was used', with the item number set to the number of item A.

2. Add an action under this - 'Conditional - If varaibale is set to a certain value'. Click the 'Change' button next to 'Variable:0', then the 'Edit Variables' button. Create a new variable - you can call it whatever you like, but I'll call it 'beendone'.

3. Set the conditonal to run if 'beendone' is set to 0. Now add whatever you want to happen the first time you use item A on the hotspot. Finish it off with a 'Game - Set variable' command that changes 'beendone' to 1, and a 'Stop running more commands' command.

4. Add another 'Conditional - If varaibale is set to a certain value', this one set to run if 'beendone' is set to 1. Add whatever you want to happen the second time you use the item.

5. If you want to have something different happen the 3rd, 4th, 5th, etc times, just use 'Game - Set variable' and 'Conditional - If varaibale is set to a certain value' as needed.

Overall it should look something like:

Use inventory on hotspot
  - Conditional - If inventory item was used (ITEMA)
    - Conditional - If varaibale is set to a certain value (beendone, 0)
      //whatever you want
      Game - Set variable value (beendone, 1)
      Stop running more commands
    - Conditional - If variable is set to certain value (beendone, 1)

If I haven't explained something properly, just look variables up in the manual, it should all be there.
#2671
Oops, sorry, I'd forgotten about this. Might as well get it over with:

Hear ye, hear ye, by Imperial Decree, the winner is…
Napolecat Ozwalled.

Congratulations.
#2672
Actually, I don't think it'd be that complicated. If I understand the script correctly, you just need to set the look at, use other inv on, etc commands for the items, then use the RunInventoryInteaction (item, mode) command, e.g.:

(I changed the formating slightly, to make it easier to read, but feel free to ignore that.)
Code: ags

if (button == 2) {
Ã,  if (GetCursorMode () == MODE_USE) {
Ã,  Ã,  SetActiveInventory (invbutton1);
Ã,  Ã,  SetMouseCursor (GetInvGraphic(invbutton1));
Ã,  Ã,  SetCursorMode (MODE_USEINV);
Ã,  }
Ã,  else RunInventoryInteraction(invbutton1, GetCursorMode());
}


In fact, depending on how you're handling inventory clicks (is 'Handle inventory clicks in script' checked or not?), RunInventoryInteraction(invbutton1, GetCursorMode()); might be all you need, but I'm not totally sure about that.
#2673
The first brace, the one after if (keycode==24)..., is back in there, AS WELL as the final one. Code should be:
Code: ags

function on_key_press(int keycode) { // Start of on_key_press
  // called when a key is pressed. keycode holds the key's ASCII code
  if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses
  if (keycode==17)  QuitGame(1);   // Ctrl-Q
  if (keycode==363 && GetCursorMode() != 7) Save();   // F5
  if (keycode==365) Load();  // F7
  if (keycode==367) RestartGame();  // F9
  if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode==9 && GetCursorMode() != 7) show_inventory_window();  // Tab, show inventory

  if (keycode==19)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode==22)  Debug(1,0);  // Ctrl-V, version
  if (keycode==1)   Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode==24)  Debug(3,0);  // Ctrl-X, teleport to room
  if (keycode == 372) { // Start of 'Up' arrow code
    StopMoving (MIKE); // Can't change speed while char is moving
    SetCharacterSpeed (MIKE, character[MIKE].walkspeed + 1);
  }// End of 'Up' arrow code
  if ((keycode == 380) && (character[MIKE].walkspeed > 1)) { //Start of 'Down' arrow code. 
    StopMoving (MIKE);
    SetCharacterSpeed (MIKE, character[MIKE].walkspeed - 1);
  } // End of 'Down' arrow code
} //End of on_key_press
#2674
OK, so //<-- REMOVE THIS BRACE should be //<-- THIS BRACE SHOULD BE AT THE VERY BOTTOM

Add an '}' at the end of the script,:
Code: ags

    SetCharacterSpeed (EGO, character[EGO].walkspeed - 1);
  }
} //<-- HERE

Then check it with the match brace function (Ctrl-B), just to be safe.
#2675
I think you've got an extra brace after if (keycode == 24)..., putting the new code outside the on_key_press script:
Code: ags

#sectionstart on_key_pressÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(int keycode) {
Ã,  // called when a key is pressed. keycode holds the key's ASCII code
Ã,  if (IsGamePaused() == 1) keycode=0;Ã,  // game paused, so don't react to keypresses
Ã,  if (keycode==17)Ã,  QuitGame(1);Ã,  Ã, // Ctrl-Q
Ã,  if (keycode==363 && GetCursorMode() != 7) Save();Ã,  Ã, // F5
Ã,  if (keycode==365) Load();Ã,  // F7
Ã,  if (keycode==367) RestartGame();Ã,  // F9
Ã,  if (keycode==434) SaveScreenShot("scrnshot.bmp");Ã,  // F12
Ã,  if (keycode==9 && GetCursorMode() != 7) show_inventory_window();Ã,  // Tab, show inventory

Ã,  if (keycode==19)Ã,  Debug(0,0);Ã,  // Ctrl-S, give all inventory
Ã,  if (keycode==22)Ã,  Debug(1,0);Ã,  // Ctrl-V, version
Ã,  if (keycode==1)Ã,  Ã, Debug(2,0);Ã,  // Ctrl-A, show walkable areas
Ã,  if (keycode==24)Ã,  Debug(3,0);Ã,  // Ctrl-X, teleport to room
} // <-- REMOVE THIS BRACE
if (keycode == 372) { // 'Up' arrow
Ã,  StopMoving (EGO); // Can't change speed while char is moving
Ã,  SetCharacterSpeed (EGO, character[EGO].walkspeed + 1);
}
if ((keycode == 380) && (character[EGO].walkspeed > 1)) { // 'Down' arrow. Won't go lower thatn 1, since negative values cause errors, and 0 will jump straight to the mouse.
Ã,  StopMoving (EGO);
Ã,  SetCharacterSpeed (EGO, character[EGO].walkspeed - 1);
}
#2676
SetCharacterSpeed (CHARID, speed)
SetCharacterSpeedEx (CHARID, x_speed, y_speed)

or, in the newer versions
Character.SetWalkSpeed(int x_speed, int y_speed)

What exactly do you want to do?
If you want it to be changeable by the player, you'll also need the character[CHARID].walkspeed variable, e.g.:
Code: ags

//on keypress
if (keycode == 372) { // 'Up' arrow
  StopMoving (EGO); // Can't change speed while char is moving
  SetCharacterSpeed (EGO, character[EGO].walkspeed + 1);
}
if ((keycode == 380) && (character[EGO].walkspeed > 1)) { // 'Down' arrow. Won't go lower thatn 1, since negative values cause errors, and 0 will jump straight to the mouse.
  StopMoving (EGO);
  SetCharacterSpeed (EGO, character[EGO].walkspeed - 1);
}


Of course, it could be done with GUI buttons or a slider, or whatever.
#2677
I think you want to use the GOT_SCORE parameter of the on_event function. By default, I don't think on_event exists in the script, so you'll have to create it if you haven't already. Something like:

Code: ags

function on_event (int event, int data) {
Ã,  if (event == GOT_SCORE) { // Called whenever score changes
Ã,  Ã,  if (game.score == game.total_score ) { // fairly self-explainatory
      Display ("Congratulations, you've won.");
Ã,  Ã,  Ã,  NewRoom (300);
      // Or whatever you want to happen
Ã,  Ã,  }
Ã,  }
}


It can go anywhere in the global script, provided it's not inside another function.
#2678
Maybe they're setting their readers up for a big joke on April 1st, when they say something true, and no-one believes them.
#2679
Read the next but one post, after the sketch.

Your bullshit meter was right to be a-shakin'.
#2680
Words and pictures. Words and pictures.
Here are the pictures:

Now give me words.
SMF spam blocked by CleanTalk