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.
function Button1_OnClick(GUIControl *control, MouseButton button)
{
mouse.Mode = eModeUseinv;
cEgo1.ActiveInventory = soda;
}
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):
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..
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.
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.
The line is ran.
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.
The option is set to true.
And nothing is keeping the mouse from changing.
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.