How to equip Inventory by clicking a GUI button.[Solved]

Started by Icey, Mon 25/04/2011 02:22:55

Previous topic - Next topic

Icey

I have searched the manual and can't seem to find how to do this. I have a button on a GUI which the player can click on to equip the inventory to the player. What I mean by this is that I need the mouse to change to the inventory mode.

Code: ags

function Button1_OnClick(GUIControl *control, MouseButton button)
{
  mouse.Mode = eModeUseinv;
cEgo1.ActiveInventory = soda;
}






monkey0506

#1
Is cEgo1 your current player character?

Also, are you aware that you can use the player keyword directly instead of having to reference the character name (especially useful if your game has more than one playable character):

Code: ags
function Button1_OnClick(GUIControl *control, MouseButton button)
{
  mouse.Mode = eModeUseinv;
  player.ActiveInventory = soda;
}


..for that matter, why aren't you naming your GUI controls? Or did you just create this event before you changed the button's name?

There's a lot of simple things that can make your code more readable (especially to other people)..and you..don't seem to like doing them.

Edit: Oh, and is this code not working for you? Coz you didn't really say what the problem is, just what you're trying to do, and how you're trying to do it. The code looks fine (functional in any case). So long as cEgo1 is in fact the player and/or the current player character actually has an active inventory item set at the time..

Icey

Sorry I didn't name the GUI controls.

You know how when you have a inventory window shown & then you click on the desired item to get it's mouse cursor? That's what I am trying to do only it's a button instead of a inventory.

Every time I click the button nothing happens. I think what I am looking for is a way to set the soda item active for the player. Then I think all I would have to do is enable the other mouse modes & enable the inventory mouse mode.

monkey0506

The code you supplied is not the problem.

Is this function being called? Try throwing a Display or AbortGame call into that function and see if it's ever actually being run. Sounds to me like maybe the function just isn't linked in the control's Events pane.

Icey


Dualnames

Then that means that there's something stopping the function from updating the mouse. Perhaps a repeatedly_execute part setting the mouse mode.

Or perhaps that option in the general settings that says "Use selected inventory graphic for cursor", (it's under Inventory) is set to false.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Icey

The option is set to true.

And nothing is keeping the mouse from changing.

Code: ags

function Button1_OnClick(GUIControl *control, MouseButton button)
{

    
player.ActiveInventory = attack;
  mouse.Mode = eModeUseinv; 

}


cEgo1 wasn't the play character so it didn't process through.

SMF spam blocked by CleanTalk