script for new gui inventory and commands

Started by dikla, Wed 01/09/2004 19:16:31

Previous topic - Next topic

dikla

here is what i need:
i want to make a new gui inventory and commands (like: open, close, save .restore, pick up, look, talk, go, quit).
i made a gui that is a long rectangle divided to two: one is long rectanagle (which is the inventory) and the othe is
9 squeres in each is written like the above (go, look ect.).
the rectangale is from side to side of the screen at the bottom.
suppose each command of the 9 squere is a button. and the gui is GUI4.
I tried to give the right command in the global script but i could not do it.
i search the forums but all i have found was the inventory gui, or something with the mouse functions.

please can you help me and right for me the right script?
you dont have to write all the script just two buttons and how i make the inventory squere to work since all the commands are not seperated, and used both to the inventory and the game.

also pls right which script i have to erase.

hope it is not too much

thank you

dikla

Scorpiorus

Something as the following...

function interface_click(int interface, int button) {

   if (interface == YOUR_GUI) {


      if (button == 0) {   // go
         SetCursorMode(MODE_WALK);         
      }

      if (button == 1) {   // look
         SetCursorMode(MODE_LOOK);         
      }


      if (button == 2) {   // talk
         SetCursorMode(MODE_TALK);         
      }


   }

...
// the rest of the interface_click script

}


As to how separate commands, just set a mouseover image for each button. Draw the image as a button with a square selector around the edges.

dikla

Thank you i try and let you know how it goes. i think i will have more problems may be.
thanks as always nice to have you back
dikla

X-Hunter Blackzero

How can the script recognize button names such as if (button == x)
when they are not initialized earlier.   So if my buttons are NOT arranged in a line, ( mine are arranged in a diamond- shape)  How do i decide which button == 0, 1, 2 etc?

strazer

GUI controls are numbered in the order they were created. You can see the number of a control in the GUI editor ("GUI 0 Control 2" for example).
Keep in mind that the controls might get renumbered when you delete a control. So in AGS v2.7, it's safer to give every control a name and check it like this:

Code: ags

function interface_click(int gui_id, int control_id) {

  if (gui_id == gYourgui.ID) {

    if (control_id == btnWalk.ID) {
      mouse.Mode = eModeWalkTo;
    }
    else if (control_id == btnLook.ID) {
      mouse.Mode = eModeLookAt;
    }
    //...and so on

  }

}

(Notice that I have renamed the variable names from "interface" to "gui_id" and "button" to "control_id" to avoid confusion.)

But as of AGS v2.7, each control can have its own event handler function, so you don't necessarily need interface_click anymore. Just give the control a name and double-click on it, then enter the command that should get executed when that control is clicked.

SMF spam blocked by CleanTalk