Script problem with combining inventory items.

Started by markbilly, Sun 31/08/2008 14:46:27

Previous topic - Next topic

markbilly

I have this section of code to control the mouse clicks on inventory items whilst in the inventory:

Code: ags


...


else if (button == eMouseLeftInv)
{
    if (player.ActiveInventory == null)
    {
        player.ActiveInventory = inventory[ game.inv_activated ];
    }
    else if (player.ActiveInventory != null)
    {
        inventory[ game.inv_activated ].RunInteraction( eModeUseinv );
    }
}	
	
	else if (button == eMouseRightInv)
	{
    if (player.ActiveInventory == null)
    {
        inventory[ game.inv_activated ].RunInteraction( eModeLookat );
    }
}



Problem is, it doesn't allow me to combine inventory items. As far as I can see, it should... :S

Can anyone spot why??

Thanks.
 

Dualnames

#1
Code: ags

if (button == eMouseLeftInv) {
    if (player.ActiveInventory == null)   {
        player.ActiveInventory = inventory[ game.inv_activated ];
return;
    }
    else if (player.ActiveInventory != null)    {
       inventory[ game.inv_activated ].RunInteraction( eModeUseinv );
return;
    }
}
if (button == eMouseRightInv)	{
    if (player.ActiveInventory == null)    {
        inventory[ game.inv_activated ].RunInteraction( eModeLookat );
return;
    }
}


//Wondering do you have the general settings option concerning mouse clicks on inventory enabled?, this probably doesn;t affect the thing, but I'm not really sure if it does.

It's called handle clicks something.

Otherwise the return lines I've added will do the trick.
Example why it doesn;t work..

This code below will "give the player an active inventory" then check if player does have an inventory and run the interaction. That's why I've put return. Return stops the script at this point.

Code: ags

    if (player.ActiveInventory == null)   {
        player.ActiveInventory = inventory[ game.inv_activated ];
    }
    else if (player.ActiveInventory != null)    {
       inventory[ game.inv_activated ].RunInteraction( eModeUseinv );
    }


I really never use game.inv_activated... but I could rework this into a different way. Anyway, try the return additions i've had at your code and probably it will score.

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)

markbilly

I tried that, no result... :(

It may have something to do with the script I have for the normal mouse clicks??

Here is that too:

Code: ags

  else if (button == eMouseLeft) {

			if (player.ActiveInventory == null) {    
			ProcessClick(mouse.x, mouse.y, eModeWalkto);
			ProcessClick(mouse.x, mouse.y, eModeLookat);
			}
    		else {
				ProcessClick(mouse.x, mouse.y, eModeUseinv);
			}
		
	}
  else if (button == eMouseRight) {   
                        if (player.ActiveInventory == null) { 
				ProcessClick(mouse.x, mouse.y, eModeInteract);
				ProcessClick(mouse.x, mouse.y, eModeTalkto);
				}
				else
    {
        player.ActiveInventory = null;
		}
			}



Sorry, my code is always a horrid mess.
 

Khris

Just use:
Code: ags
  else if (button == eMouseLeftInv)
  {
    if (player.ActiveInventory == null) player.ActiveInventory = inventory[ game.inv_activated ];
    else inventory[ game.inv_activated ].RunInteraction( eModeUseinv );
  }

markbilly

Still exactly the same. No luck at all.

I've re-read every bit of code, and it should work! Grrr.
 

SMF spam blocked by CleanTalk