stop object from being used more

Started by , Wed 14/04/2004 19:48:58

Previous topic - Next topic

John

Want to stop the object from being used more then one time so how do i do that ?
// script for object0: Any click on object
SetObjectView(0,28);
AnimateObject(0,0,0,0);
Now click on it and it moves the switch down but if you click on it again it will recycle the animation..
Just want it to work one time but not remove the object .

Scorpiorus

At the top of room script:

int clicked = 0;


// script for object0: Any click on object

if (clicked == 0) {  // if player hasn't clicked on it
   SetObjectView(0,28);
   AnimateObject(0,0,0,0);
   clicked = 1; //now he has clicked :)
}

~Cheers

Johm

Thank you Scorpiorus  that work .

John

Can you have a switch turn on a hot spot on in a diff room ?
What I was wanting to do was have the switch turn on a hot spot in the next room so  a door would be open and if they didn't  flip the switch the door would be closed .  I have a room  showing the door open and one closed .
Or is there a better way to do that .

Scorpiorus

#4
You could set a global int to indicate whether player flipped the switch:

f (clicked == 0) { // if player hasn't clicked on it
Ã, Ã, Ã, SetObjectView(0,28);
Ã, Ã, Ã, AnimateObject(0,0,0,0);
Ã, Ã, Ã, clicked = 1; //now he has clicked
Ã, Ã, Ã, SetGlobalInt(1, 1); //i.e. GlobalInt#1 = 1; // turned on
}



Then on player enters room (before fade-in) with a hotspot:

if (GetGlobalInt(1)==1) EnableHostpot(...); // if globalint#1 = 1 then enable hotspot
else DisableHotspot(...); //if not disable it


QuoteI have a room showing the door open and one closed .
hmm, you don't need two rooms. Just make the door an object and draw a hotspot, so after turning switch on player could click on it to enter.

[edit]With the SetObjectGraphic (int object, int slot) you can change door's sprite:

if (GetGlobalInt(1)==1) {
   EnableHostpot(...);
   SetObjectGraphic(obj, SLOT_WITH_IMAGE_OF_OPENED_DOOR);
}
else DisableHotspot(...);


TerranRich

Your questions -- al of them -- can be solved using variables. Check out Global Integers and Global Strings in the manual, or customized variables in the Beginners' FAQ. Both are suitable for what you want to do.

For the switch idea, since it's not possible to manipulate regions/hotspots in other rooms, simply set a global integer -- or a variable -- such as "hotspot_is_on" to a certain value, then change it whenever you need to. Simple as that. :) Most of our problems can be solved using variables.
Status: Trying to come up with some ideas...

SMF spam blocked by CleanTalk