Usermode problem

Started by Dualnames, Sat 10/03/2007 01:24:38

Previous topic - Next topic

Dualnames

Well I want when the player selects the gun to change cursor mode to usermode1(which I call as shooting mode  since the cursor is a crosshair)
But I can't do it.
Well I used the following code:

if (player.activeinventory == igun) {
setcursormode(usermode1)
}

But when i placed it on the repeatedly execute line the obvious happened.
Well I have the following guis (an iconbar popping and an inventory gui)
and some other that pop up after shorcuts.

Help please
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)

Khris

if (player.ActiveInventory==iGun) mouse.Mode=eModeUsermode1;

(from the top of my head.)

Ashen

What's 'the obvious'?
The obvious thing to me is, you won't be able to have any other mode than eModeUsermode1 so long as the Gun is the active item. Is that the problem? Khris' code won't do anything about that, it's just your code updated to not use the old-style SetCursorMode command. If that was your problem, READ THE MANUAL for the current versions of commands - if it gives you an 'undefined token' message, either update your code or uncheck the 'Enforce object-based scripting' option on the General settings window.

If the problem is what I said (the 'not being able to change mode' thing), what do you want to happen instead? The easiest solution I can see is:
Code: ags

if (mouse.Mode == eModeUseinv && player.ActiveInventory==iGun) mouse.Mode=eModeUsermode1;

Which should set it to eModeUsermode1 when you want to use the gun, but still let you use the other modes the rest of the time.

You could also maybe change the cursor graphic for the Gun item to the crosshair, and just use eModeUseinv. That'd require a little more coding, however.
I know what you're thinking ... Don't think that.

Dualnames

Well. I made it.
I used a the isbuttondown function and figured it out.
Thanks to all
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)

Ashen

Glad you've sorted it, but can I ask how exactly?
Can you post the final, working code for anyone who might need it in the future?
I know what you're thinking ... Don't think that.

Dualnames

Quote from: Ashen on Sat 17/03/2007 22:07:44
Glad you've sorted it, but can I ask how exactly?
Can you post the final, working code for anyone who might need it in the future?


Blast that. But ok

Here it is.

First make this function at global script
Code: ags

#sectionstart user// DO NOT EDIT OR REMOVE THIS LINE
function user(int parameter) {

  if (parameter == 1) {   
  if (IsButtonDown(eMouseRight)) { 	
	     SetTimer(12,1);        
    }
    
  } 
  else if (parameter == 2) {  
        if  (IsTimerExpired(12)) {        
           SetActiveInventory(13);                     
    }

  }  
  
}
#sectionend user// DO NOT EDIT OR REMOVE THIS LINE


Then import the function via script header then add to all rooms you want at the repeatedly execute the following

Code: ags

 if (player.ActiveInventory==igun) {
        GUIOff(2);
        SetCursorMode(eModeUsermode1);
        user(1);
        user(2);
      }


This triggers when the gun is selected by the user.

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)

Khris

Seriously, I'm absolutely amazed that this code does what you want.
It looks like a wobbling 5-feet Jenga tower to me.

1. You don't need the #section stuff when adding your own functions
2. The whole stuff you've posted can be done like this:
Code: ags
if (player.ActiveInventory==igun) {
        gui[2].Visible=false;
        mouse.Mode=eUsermode1;
        if (IsButtonDown(eMouseRight) player.ActiveInventory=inventory[13];
      }

3. You are still mixing old and new code.

How about:
Code: ags
if (mouse.Mode == eModeUseinv && player.ActiveInventory==iGun) mouse.ChangeModeGraphic(CROSSHAIR_SPRITE);

SMF spam blocked by CleanTalk