Wiring puzzle

Started by Reno Caspain, Wed 03/03/2004 06:32:04

Previous topic - Next topic

Reno Caspain

I'm making a puzzle with 10 poles and couple of wires, where the player has to connect right poles together. Here's the code this far:

 // script for hotspot2: Use inventory on hotspot
LoseInventory(16); //wire
Display("Now where should I connect the other end?");
AddInventory(17); Ã, Ã, Ã, //end of wire object
SetActiveInventory(17);Ã, Ã, Ã, //Selects the end of the wire.
DisableRightClick(); Ã, Ã, Ã, //Keeps player from avoiding connecting the other end of the wire.
GUIOff(1);Ã, Ã, Ã, Ã, Ã, Ã, //same as above
connected=2; Ã, Ã, Ã, Ã, Ã, Ã, //Saves the hotspot number the previous end of the wire was connected to.

Now I'd need to check what hotspot the player has clicked, compare it with the int connected, and if right poles are connected, turn on the object with the wire between poles.

Because there are 15 hotspots and 6 objects on the screen, making all possible checks individually is out of the question.

jetxl

I dont completely understand... ?????

if (character[GetPlayerCharacter()].activeinv==17){ //the inventory item you use
 if(connected==2){
   ...
 }
 else {...}
}

Pumaman

You can override the on_mouse_click function within the room script, and then check if the player has clicked on something. Try something like:

function on_mouse_click(int button) {
 if (character[GetPlayerCharacter()].activeinv==17) {
    if (GetObjectAt(mouse.x, mouse.y) == CORRECT_POLE) {
        // connect it up
    }
    else {
        // wrong place
    }
    ClaimEvent();
 }
}

Reno Caspain

#3
Is there a way to limit the on_mouse_click to certain room so it won't be scrolled through in every room? Also, I'm using Proskritos template so I still need to use the global on_mouse_click too.

Another problem is now that when the first end of wire is connected, the cursor mode turns into Walk To-mode, even when player character is hidden in the room.

I've tried SetActiveInv(17) (setting active inventory to end of the wire) and SetCursorMode(4) (set cursor mode to use inventory), but it still stays on walk to mode.

Oh, and the ClaimEvent-function cannot be found, but that might be because I use version 2.56d (if I remember it correctly).

Scorpiorus

Quote from: Reno Caspain on Fri 05/03/2004 11:34:25
Is there a way to limit the on_mouse_click to certain room so it won't be scrolled through in every room? Also, I'm using Proskritos template so I still need to use the global on_mouse_click too.
That is how the code CJ wrote works. Just place the on_mouse_click function into your certain room script. You need the version of AGS that supports ClaimEvent() though.

QuoteAnother problem is now that when the first end of wire is connected, the cursor mode turns into Walk To-mode, even when player character is hidden in the room.

I've tried SetActiveInv(17) (setting active inventory to end of the wire) and SetCursorMode(4) (set cursor mode to use inventory), but it still stays on walk to mode.
Could it be because the template itself overrides the cursor appearence or something?

SMF spam blocked by CleanTalk