Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 12,400 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Multiple Buttons using 1 function #285994
08/22/09 07:31
08/22/09 07:31
Joined: May 2009
Posts: 37
S
shiznitIII Offline OP
Newbie
shiznitIII  Offline OP
Newbie
S

Joined: May 2009
Posts: 37
Hi guys! I need help on how to pass the button number if i'm using one function for several buttons in the same panel. I hope you can help me.

PANEL* charac_pan =
{
layer = 3;
pos_x = 0;
pos_y = 0;
button (10, 0, "horse1.tga", "horse1.tga", "horse3.tga", create_entity1, NULL, NULL);
button (120, 0, "pig1.tga", "pig1.tga", "pig2.tga", create_entity1, NULL, NULL);
button (230, 0, "bat1.tga", "bat1.tga", "bat2.tga", create_entity1, NULL, NULL);
flags = OVERLAY | SHOW;
}

Re: Multiple Buttons using 1 function [Re: shiznitIII] #285999
08/22/09 08:51
08/22/09 08:51
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Its built in, just not easily found in the manual.
Looking at your code you want to 'share' the funtion "create_entity1"
Do so like this. (NO changes required in panel definition)
Code:
function create_entity1(var button_number)
{
   // "button_number" now contains the button number that was pressed,
   // starting with 1. In this case "1" would be the horse button.
   ...
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Multiple Buttons using 1 function [Re: EvilSOB] #286014
08/22/09 11:56
08/22/09 11:56
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
also you could/should carry the PANEL param too,

Code:
function create_entity1(var button_number, PANEL panel_id)
{
   switch(button_number){
      case 1: //button 1
         //do
      break;

      case 2: //button 2
         //do
      break;

      default: //all other buttons not already caught
      break
   }
}

hope this helps

Re: Multiple Buttons using 1 function [Re: MrGuest] #286596
08/26/09 05:23
08/26/09 05:23
Joined: May 2009
Posts: 37
S
shiznitIII Offline OP
Newbie
shiznitIII  Offline OP
Newbie
S

Joined: May 2009
Posts: 37
thanks a lot for the tip! you guys helped a lot


Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1