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 - strazer

#1241
You're welcome. :)

To check if the player entered text at all, you could do:

Code: ags

  //...
  if (StrComp(plrname, "") != 0) { // if player entered text
    StrCopy(character[EGO].name, plrname); // copy text from variable to character's name
  }
  //...
#1242
  string plrname; // define string variable that will hold the new name
  InputBox("Hello, what's your name?", plrname); // ask for name and store it in the variable
  // you might want to add some checks here, in case the user entered no text for example
  StrCopy(character[EGO].name, plrname); // copy text from variable to character's name
  Display("Well, nice to meet you %s", character[EGO].plrname); // display the character's name
    // i.e. the above should be character[EGO].name

Alternatively, in this particular script,

  Display("Well, nice to meet you %s", plrname); // display the variable's text

would also work since at that point the variable and the character's name contain the same text. However, when the function ends, the local string variable is destroyed and you have to use character[EGO].name instead (i.e. in other functions).
#1243
Could you post the script you're using?

If you use the interaction editor, be sure to make the door opening a child action of the conditional:

Use inventory on object 1
- If inventory item was used (key)
-- Change object 1's graphic to an open door

If you do it like this

Use inventory on object 1
- If inventory item was used (key)
- Change object 1's graphic to an open door

, the action will be performed regardless of whether the conditional is true or not.
#1244
I would probably do it like this:

Painting (object 0)
Safe door (object 1)
Money bag (object 2)
(Open safe: Part of room background)

Set their baselines accordingly so that the painting is in front of the safe door, and the safe door in front of the money bag.

- Interact with object 0 -> Move object 0 to the side, for example, or change graphic to a tilted painting, whatever
- Use inventory on object 1 -> If inventory item was used (key) -> Change object 1's graphic to an open door
- Interact with object 2 -> Turn off object 2 -> Add money item to inventory
#1245
QuoteThe code is in the "Interact object" section of inventory item #19. It used to be in "Use inventory on object", but it didn't do anything.

That only works if the mouse is in UseInv mode, i.e. the active inventory item is the mouse cursor. That's how it's usually done.
Are you sure your mouse was in UseInv mode when you tried this?

QuoteThen when I USE item 19, the cursor just changes to item 19's graphic instead of running the interaction.

So do I understand correctly that you want to combine items by interacting with them when another item is active?
As I said, the usual way is to use the active inventory item (UseInv mode) on another item.

QuoteI'm trying to do a simple thing where you use one inventory item on another to get a third item.

Here's a step-by-step solution the usual (UseInv) way:

You need three inventory items:

Item A
Item B
Item C: The combined one

- "Inventory items" pane -> Select Item A -> "Interaction..." button
- "Use inventory on this item" -> "Run script"
Code: ags

  if (player.activeinv == ITEMB_NUMBER) { // if item B used on item A
    LoseInventory(ITEMA_NUMBER); // remove item A from player's inventory
    LoseInventory(ITEMB_NUMBER); // remove item B from player's inventory
    AddInventory(ITEMC_NUMBER); // add combined item to player's inventory
  }


- "Inventory items" -> Item B -> "Interaction..."
- "Use inventory on this item" -> "Run script"
Code: ags

  if (player.activeinv == ITEMA_NUMBER) { // if item A used on item B
    LoseInventory(ITEMA_NUMBER); // remove item A from player's inventory
    LoseInventory(ITEMB_NUMBER); // remove item B from player's inventory
    AddInventory(ITEMC_NUMBER); // add combined item to player's inventory
  }


Btw, which AGS version are you using?
In AGS v2.62 and below, "player" is just an alias for "character[EGO]" and is not actually the current player character. So if your player character is not named "EGO", your script may not work correctly.
AGS v2.7 always keeps "player" updated with the current player character.
#1246
Beginners' Technical Questions / Re: SaveDir?
Wed 18/05/2005 22:06:16
CJ removed your other thread in the Tech Forum which contained a suggestion by Pablo I think it was:
Make sure that the shortcut's starting directory points to the game folder and not the desktop or whatever (Right mouse click -> "Properties..." on the shortcut icon).
#1247
QuoteSo, when the mouse is RELEASED over a GUI element (not just anywhere on the GUI) the interface_click is triggered, regardless of the mouse button.

Yes, but the interface_click function is triggered regardless of whether the mouse is over a GUI control or not. That's why you use the
  if (interface == INVENTORY) {
and
  if (button == 0) {
parts to check for the GUI and GUI control that the mouse button has been clicked on.

Edit:
(Btw, the default parameter names of the interface_click function, "interface" and especially "button", are bit confusing I think, that's why I renamed them to "guiid" and "controlid" in my earlier example.)
-

Quoteon_mouse_click is triggered with RIGHTINV and LEFTINV anytime you click within an inventory window (or perhaps just when you actually click on an inventory item that's actually there)

The latter, yes.
Keep in mind that the on_event function is also run in this case (before the on_mouse_click function).

(Just for reference: "Handle inventory clicks in script" has to be checked in General settings for RIGHTINV/LEFTINV to work.)

Edit 2:

Another thing: In AGS v2.7, each GUI control (except inventory windows it seems) can have its own event handler function where you can check the mouse button:
  function MyButton_Click(GUIControl *control, MouseButton button) {
for example.
#1248
I would like that.

Btw, we have a similar tracker entry in which intermalte suggested the same thing.
#1249
The Rumpus Room / Re: Happy Birthday Thread!
Wed 18/05/2005 12:20:13
Happy Birthday, Rich!
#1250
Quote from: Worm III on Wed 18/05/2005 01:16:44
What I would like explained to me is why are the mouse clicks I have to capture in on_event are not triggering on_mouse_clicks?

When the mouse is clicked over a GUI, interface_click is called instead of on_mouse_click.
This is just how AGS works. A bit inconsistent I guess.

Quote from: Worm III on Wed 18/05/2005 01:16:44
I tried using "IsButtonDown" inside the interface, but it just never took.

The interface_click function is triggered when the mouse button is released so by the time the function runs, IsButtonDown always returns 0.
That's why the on_event function is needed to store the pressed mouse button before the interface_click function runs. on_event/GUI_MDOWN runs when the mouse button is pressed down.

Quote from: Worm III on Wed 18/05/2005 01:16:44
Why is on_event needed vs on_mouse_click and stuff in general.

Since you can't check the mouse button in interface_click (see above), we need to save the clicked mouse button in on_event first.

Quote from: Worm III on Wed 18/05/2005 01:16:44
(strazer, can you simplify this?)

Your code is fine. An alternative is this:

Code: ags

int ignore_interface_click = 0;

function on_event(int event, int data) {

  if (event == GUI_MDOWN) {

    if (IsButtonDown(RIGHT)) {
      ignore_interface_click = 1;
      SetNextCursorMode();   
    }
    else ignore_interface_click = 0;

  }

}


function interface_click(int interface, int button) {

  if (ignore_interface_click == 1) return;

  //  .... other stuff here.....

}


Here's basically how I do it in my game:

Code: ags

// main global script file

int GUIMouseButton; // stores mouse button clicked on gui

//on_mouse_click function here

function on_event(int event, int data) {
  //...

  if (event == GUI_MDOWN) { // if mouse clicked over a gui

    if (IsButtonDown(LEFT)) GUIMouseButton = LEFT; // if left mouse button pressed, store it in variable
    else if (IsButtonDown(RIGHT)) { // if right mouse button pressed
      GUIMouseButton = RIGHT; // store button in variable
      on_mouse_click(RIGHT); // call on_mouse_click function for default right mouse button action (SetNextCursorMode)
    }
    else GUIMouseButton = MIDDLE; // if any other mouse button pressed, store as middle mouse button

  }

  //...
}


function interface_click(int guiid, int controlid) {
  //...

  if (guiid == THEGUINAME_A) {
    if (controlid == THECONTROLNUMBER_A) {
      // do stuff
    }
  }

  if (GUIMouseButton != LEFT) return 0; // allow only left mouse button for the following GUIs

  if (guiid == THEGUINAME_B) {
    if (controlid == THECONTROLNUMBER_B) {
      // do stuff
    }
  }

  //...
}
#1251
I've also never been there before, so I'll be spending some time in #ags soon.
I would be happy to meet you, Ashen.
#1252
QuoteHow do I know what triggers those characters?

Those characters are special control characters and don't correspond to any letter (line breaks, feeds and so on). Look up any ASCII table on the net to see what they are.
I think you can display them like this:
  Display("%c", 12);
but you can not use them in messages directly.
See also this tracker entry.
#1253
Hm, I don't know what "WMPlug" is.

You could open the file with Audacity and export it again (File -> Export As Wav...) to make sure it's uncompressed (by default Audacity's Wav export format is uncompressed).
#1254
I'd like to come. Where is Staines exactly and how far is it from airport London/Stansted? It's cheap with Ryanair.
#1255
AGS Beginners FAQ
Particulary 6.
AGS only supports uncompressed wave files, maybe this wav is compressed with ADPCM or something.

Edit:

I just read your edit.
Try right-clicking in WMP and choose "Properties..." or "Filters" or something (I run Linux, therefore I can't check).
#1257
Agreed.
But if you really, really have to, try Inno Setup.
#1258
In the future, please try to explain in more detail what functions you use, where you use them and under what circumstances the problem occurs.
It's hard to help you sometimes since you tend to describe your problems with a single short sentence, not providing any details of what the problem is or what you want to happen exactly.

Anyway, here's a guess:
Keep in mind mouse coordinates are screen coordinates, so if you do for example:

  player.Walk(mouse.x, mouse.y);

this won't work properly in scrolling rooms since the Walk function expects room coordinates.
So you have to take the current viewport position into account:

  player.Walk(GetViewportX() + mouse.x, GetViewportY() + mouse.y);

Edit
#1260
QuoteProbably the issue was that all my dialog is written as DialogRequests, so I had to dump script strings too.

As far as I know, the translation source also contains script strings of selected functions like Character.Say, .SayBackground and so on.
But you're right, it can't be re-imported so it's of limited use.
SMF spam blocked by CleanTalk