Hi! Welcome to the forum for Platinum Arts Sandbox Free 3D Game Maker. I currently have the forums locked as I am attempting to properly update them.

In the meantime please join the new Discord Server!

If you have any questions please e-mail me through the Platinum Arts website.

making a door open IF you have key?

Having issues not related to a specific Sandbox game mode? Get help here!
Please also read the rules for support when posting support requests.
Failure to comply with the forum rules may result in your topic being locked without resolution.
Locked
doublewar
Member
Member
Posts: 11
Joined: January 30th, 2010, 6:46 am
Name: Mario

making a door open IF you have key?

Post by doublewar »

i want to make a door open, but only if you have a key.
my code-

a quest based completely on the apples picking quest-

Code: Select all

//lost key


level_trigger_24 = [
	key1 = (+ $key1 1)
	echo "You picked up the mayors key! he lives in the large house on the small island in the human village."
]

key1 = 0
Mayorskey1 = 0

level_trigger_25 = [showgui Mayor1]
newgui Mayor1 [
	if (= $Mayorskey1 2) [
		guitext "thanks for your help Guardian." chat
		guitext "you can do as you like in my village." chat
	] [
		guitext "a Sacred Guardian? well, this is a rare sight." chat
		guitext "welcome to my village Guardian. i wish we could give" chat
               guitext "you a better welcome and a nice place to stay, but" chat
               guitext "most of our village was claimed by the ogres." chat
               guitext "guardian, can you do me a favor?" chat
	]
	guibar
	if (< $Mayorskey1 2) [
		if (= $Mayorskey1 0) [
			guibutton "sure. what do you need?" "showgui Mayor2; Mayorskey1 = 1" chat
		] [
			if (> $key1 0) [
				guibutton "I've found your key" [Mayorskey1 = 2; showgui Mayor4; key1 = (- $key1 1)] chat
			] [
				guibutton "I've found your key" [showgui Mayor3] chat
			]
		]
	]
	guibutton "bye" [echo "The Mayor: goodbye, Guardian."] chat
] "The Mayor"

Mayor2 [
	guitext "i was having a smith creat a key for me. it was" chat
	guitext "to be a key to get into the castle the ogres took from us." chat
	guitext "i believe the key is on a small rock at the side of the river, just beyond" chat
	guitext "the wall seperating us from the ogres. if you get it for me," chat
	guitext "i will make a copy for you and you can enter the castle whenever you wish." chat
	guibar
	guibutton "sounds good. i'll get the key then" [echo "The Mayor: thanks Guardian. The key is on a rock beside the river, just beyond the dividing wall."] chat
]

Mayor3 [
	guitext "but you do not have the key with you." chat
	guitext "The key is on top of a rock that is beside the river just beyond" chat
	guitext "the wall seperating us from those ogres." chat
	guibar
	guibutton "ok, i'll go get it." chat
] "The Mayor"

Mayor4 [
	guitext "Perfect! this is the key! thanks Guardian. with this we are" chat
	guitext "one step closer to getting our city back from the ogres." chat
	guitext "here, have this rare gem. it is very old, said to be part if the" chat
	guitext "frozen flame of the dragon god long ago. its small, but worth a small fortune" chat
	guibar
	guibutton "no problem mayor." [echo "The Mayor: we are so close to reclaiming my castle, i can almost taste that throne!"
                 treasure = ( + $treasure 5 )
                 key2 = ( + $key2 1 )
                 echo "You got 5 treasure and the key to the ogre castle from the mayor."] chat
] "The Mayor"


key2 is the key to open a door. i wanted to make the door open if you have 1 key2, and if you dont nothing happens when you approach the door.

what i have for the door-

Code: Select all

//the ogre castledoor = trigger26

key2 = 0
opened1 = 0

level_trigger_26 = [showgui ogrecastledoor]
  newgui ogrecastledoor [ if [ = $opened1 1 ]
[ guitext "the doors are open. you can enter and leave as you like." chat ]
 [ if [ key2 = 1 ]
    [ guitext "the castle doors opened" chat ;  [[b][i][u]code to make door open?[/u][/i][/b]] ]
    [ guitext "if you had a key, you could open the door." chat
      guitext "you should ask the human mayor about it." chat ]
   ]
]

if you can tell me how to make the doors triggertype change when you have the key, that would be great :)
doublewar
Member
Member
Posts: 11
Joined: January 30th, 2010, 6:46 am
Name: Mario

Re: making a door open IF you have key?

Post by doublewar »

im guessing there is no way to have the door open if you have the key... is there any way to make the model disappear completely then if you have the key? or have the door open immediately upon finishing the mayors key quest?
arcones
Support Team
Support Team
Posts: 2734
Joined: January 13th, 2010, 12:42 pm
Name: Timothy
IRC Username: I use Steam
Location: Looking over your shoulder...
Contact:

Re: making a door open IF you have key?

Post by arcones »

Hey doublewar!

I have a key and a door that work together as well. But I don't use the code to do that.

Set the door at Trigger Type 12 (that means it's locked until you pick up the key)

Set door Level Trigger at 1 (you can change this to fit your needs)

For the key Trigger Type I use 12 (for the key this makes it disappear)

For the Level Trigger use 1 (same as the door Level Trigger. You MUST keep the key Lvl trigger and the door lvl trigger the SAME)

What happens is this. Your character runs over the key, you pick the key up and go to the previously locked door which is now open! :D

I hope this helps :mrgreen:

Arc
Image
Want a user bar like this one? PM Leo!
User avatar
Venima
Support Team
Support Team
Posts: 259
Joined: February 17th, 2010, 4:56 am
Name: Tombstone
IRC Username: Venima
Location: Somewhere in the eternal planes between the living and the dead

Re: making a door open IF you have key?

Post by Venima »

to help even more, some example code:

Door (trigger type 11, trigger 1)
Key (trigger type 12, trigger 2)

Code: Select all

key1 = 0

level_trigger_1 = [
if (> $key1 0) [trigger 1 1] [echo "This door appears not to be opening"]
]

level_trigger_2 = [
if (= $key1 0) [    //so that you can't pick it up twice
key1 = (+ $key1 1)
echo "Picked up a key"
] [] 
]
Locked