How do i use the right mouse click in game

Started by Dr Fred Rubacant Edison, Sat 11/11/2006 17:12:32

Previous topic - Next topic
Like in Maniac mansion  How do i use the Right mouse click to open doors


Im useing the

if (any_click_on_door (3, 3, 178, 69, DIR_UP, 21, 257, 113, DIR_LEFT) == 0) Unhandled (); 


How do i fix the door problem that KhrisMUC was talking about and the starter pack i downloaded from you didnt work  errors come up.


Im sorry im new to scripting   

Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Ashen

#1
That's not a standard AGS Command ....
From what you've said, and your other thread, I guess it's from the Maniac Mansion Mania pack?

As with any module or template you might be using, you can't really expect everyone to be familiar with the coding. So you'd either need to post in the approriate thread (if one exists, and I don't think it DOES in this case), PM the creator, or provide us with all the relevant code (in this case possibly the function declaration for any_click_on_door (), and certainly tell us where the line you quoted is).

EDIT:
As a general thing to make Right mouse clicks do something other than cycle the cursor mode, you'd need to edit the on_mouse_click function in the Global Script. You'd need to add to or change the conditions so whatever you wanted to happen on a Right-Click happens. By default it's this but:
Code: ags

  else {   // right-click, so cycle cursor
    mouse.SelectNextMode();
  }


But I couldn't say what it is (or what it NEEDS to be) with the MMM code.
I know what you're thinking ... Don't think that.

Khris

The starter pack I linked to doesn't work with every AGS version. Instead of "errors come up", please tell which version you've used and which errors you got (state the exact error message(s)).

To add your own doors that work with a right click, you'll have to add them to a function in the global script that looks like this:
Code: ags
function VariableExtensions (string location){
  // put here wich extension will show the things with variable extension (>v)
  int r = character [GetPlayerCharacter ()].room;
  int o = GetObjectAt (mouse.x, mouse.y);
  int h = GetHotspotAt (mouse.x, mouse.y);

       if ((r == 1) && (h == 1)) OpenCloseExtension (3, location);
  else if ((r == 2) && (h == 1)) OpenCloseExtension (3, location);
  else if ((r == 2) && (h == 2)) OpenCloseExtension (4, location);
  else if ((r == 3) && (h == 1)) OpenCloseExtension (4, location);
  else if ((r == 3) && (h == 2)) OpenCloseExtension (5, location);
  else if ((r == 4) && (h == 1)) OpenCloseExtension (5, location);
  else if ((r == 3) && (h == 3)) OpenCloseExtension (6, location);
  else if ((r == 6) && (h == 6)) OpenCloseExtension (6, location);
  else if ((r == 7) && (h == 1)) OpenCloseExtension (7, location);
  else if ((r == 8) && (h == 1)) OpenCloseExtension (7, location);
}

Going by your any_click parameters, the door leads to room 21 and uses global int 3, so it's probably a door in room 1, right?

You'd have to add this to the function:
Code: ags
  else if ((r == 1) && (h == 1)) OpenCloseExtension (3, location);
  else if ((r == 21) && (h == 1)) OpenCloseExtension (3, location);
(replacing obsolete lines in the process)

There's a pretty lengthy thread in the german Maniac Mansion Mania forum where the custom functions of the starter pack are thoroughly explained.
Unless you have a very good understanding of AGS's scripting in general, you'll have a very hard time of adapting the pack's code to suit your needs.

I'm sorry, but I'm not willing to spend hours on explaining everything. It *is* possible to figure it out just by looking at the global script, and the MMM pack is merely an extension to the existing 9-verb-template by Proskrito which there should be an english doc available for.

I tryed the new stater that i downloaded and there a problem the game wont run it said.


There was an error compiling your script  the problem was in global script

error  (line 273) type mismatch cannot convert string to int




function RemoveExtension (string location){
  //removes the extension of a string
  int length = StrLen (location);     
  if (Extension (location) != 0) StrSetCharAt (location, length - 2, 0);
  return location; // <------
}


whats wrong with it.
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Ashen

I know what you're thinking ... Don't think that.

#5
that was for KhrisMUC i download the starter pack from him



One other thing 

This is just a test thing im doing but i want the player to look in a pot and get a item
but the problem is it keeps on doing it how do i only do it once then say the pot is empty



if (UsedAction (A_LOOK_AT))
  {
    if (MovePlayer (189, 115))
    {
      FaceDirection (GetPlayerCharacter (), DIR_UP);
      DisplaySpeech(GetPlayerCharacter(),"Oh.");
      DisplaySpeech(GetPlayerCharacter(),"I just found a remote");
  player.AddInventory (iRemote);
 
}
else {
 


}



Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Khris

#6
You *CAN'T* be serious.
That is probably the single most asked question of all times.

Please look up "variables", in the forum as well as in the AGS helpfile.

Btw: Instead of DisplaySpeech(GetPlayerCharacter(),"Oh."); you can use player.Say("Oh.");.

Ashen

Quote
that was for KhrisMUC i download the starter pack from him

But did my suggestion work? If not, say why not (e.g. if you still get an error), rather than asking the same question twice, in different threads.
If you only want an answer from a specific person, ask them via PM.

As KhrisMUC (and the Forum Rules) says - Read the Manual, Read the BFAQ, search the Forums. Become more familiar with the AGS language before you set out to adapt someone elses code for your own needs, and you might not have to be asking questions so much. (Or you might find a new set of questions to ask - but at least they won't be ones that have been answered already.)
I know what you're thinking ... Don't think that.

The Enforce-new-style Strings is un-checked still dont work.

Im using AGS version  2.72

From KhrisMUC   There is a starter pack available with implemented character change functionality (written by me).
You can download it here.


Anyway why make a starter pack that dont work
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Ashen

Define "still don't work". Are you still getting the same error message, does it seem to compile but not actually do anything, is there a new error message...?

Can you post the code you're now using?

The starter pack in general is probably having problems because it was written with an older version of AGS that you're using (what version ARE you using, by the way?). It'd be nice if the creator (KhrisMUC?) had the time to release an updated version, but until then you'll just have to cope. Any further discussion of the pack not directly related to the script should be done on the MMM forums or via PM - this isn't the place for it.
I know what you're thinking ... Don't think that.

and i still dont under stand about the pot thing


It wont get the item once  then i want the hot spot to say the pot is empty  look at code on top
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Ashen

Have you read the BFAQ (questions 1 and 9 of the Scripting, Code and Interaction section are particularly helpful here), and searched the forums?
If so, what about it aren't you understanding - do you not get how to create variables, do you not see how to use them in your code, or what? It'll be easier to give you useful advice when we know where the problem actually is.

In your case, you could probably use the Character.InventoryQuantity property, instead of your own variable or a GlobalInt:

Code: ags

  if (UsedAction (A_LOOK_AT)) {
    if (player.InventoryQuantity[iRemote.ID] == 0) { // If the player DOESN'T have the Remote
      // Move them to the pot, and give them it
      MovePlayer (189, 115);
      FaceDirection (GetPlayerCharacter (), DIR_UP);
      DisplaySpeech(GetPlayerCharacter(),"Oh.");
      DisplaySpeech(GetPlayerCharacter(),"I just found a remote");
      player.AddInventory (iRemote);
 
    }
    else { // If the player DOES have the Remote
      // Do nothing.
      // Or, you could have the player say something like "There's nothing else in there."
    } 
  }


Learning how to use variables is still useful, however. Like it says on the first page of the BFAQ:
Quote
NOTE: Please keep the following in mind. Most of our problems can be easily solved using variables. Need to change a hotspot's state in another room? Use variables! Need an object to be used only once? Use variables! You can either use Global Integers and Global Strings (look inside the AGS manual for these) or custom variables.
I know what you're thinking ... Don't think that.

Im really sorry that my scripting stinks im better with graphics but right now im the only one working on this project.


I need some MMM Coding/Scripting Tutorials  i cant find any i ned some basic ones first

Like how to make a locked door and use a key to unlock it.
How to make a light switch for a room
How to make a switch to open a door
And  under standing the basics MMM coding


Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Khris

I'm positive that the starter pack works fine, so if anything is wrong, it's on your end.
I don't carelessly upload untested stuff, you know. (At least not without explicitly telling so.)

There aren't any english coding tutorials for MMM, it is a german project, most of the creators of MM Deluxe/the original starter pack are german, and all authors of the other packs are german, too. As I told you, I won't go through the trouble of explaining everything in detail, especially not to a scripting beginner who wants help but doesn't seem to care to answer questions of those who are willing to help him.

key: check the any_click_on_door_special function in the global script.
light switch: the room's lighting is more complicated to implement, but can be done using SetBackgroundFrame() and Region.LightLevel(). Implementing a switch can be done using a varibale.
switch opens door: Upon activation of the switch, change the door's global int and switch on/off the object with the graphic of the open door.

Please understand that the last two are extremely basic problems. If you can't figure out how to do such things, you should get used to AGS and scripting in general first.
I don't want to be rude, but I am not willing to provide ready-made solutions to such basic stuff. Put MMM aside for now, start with a simple game of your own and learn the basics first.

SMF spam blocked by CleanTalk