2019-07-11 02:03:37

Hey everyone. Would anyone be willing to please help me in creating a door I can open and close with the GDE? I can't seem to get it to work. I want it to be non-passable if it is closed, and able to be walked through if it is opened. I also want to be able to of course play a door opening sound when pressing which ever action button I use to open it. And play a door shutting sound when pressing that same action button to close it. If anyone could do this for me and just post the GDE script, I should then be able to create the actions to make it work on my end. Thanks so much for your help in advance.

2019-07-15 18:38:19 (edited by Charles 2019-07-15 18:39:33)

Is GDE that thing called game develop engine or am I wrong?
Edit
Sorry. I think it's called the g develop engine not the game develop engine

2019-07-15 21:10:00

Its the game development enviroment for the Sonus, Charles.

On the door object, something like this in the button held events will stop the player object from going through them

if "L" "State" "==" "C" "Closed"
if "Col" "Player" "==" "L" ""
subz "1"
endif
endif

Line 1 checks the door has a local varaible set to Closed.
Line 2 checks it is colliding with the player object
if both of these conditions are met, line 3 knocks the player back by 1, this example is if the up button is being pressed so it knocks the Z co-ordiante down by one.


Next on the doorknob object that changes the state of the door. The following code applies

setlv "StateHasChanged" "false"
if "Col" "Player" "==" "L" ""
if "L" "State" "==" "C" "Closed" "Door"
setlv "State" "Open" "Door"
setlv "StateHasChanged" "true"
endif
if "L" "State" "==" "C" "Open" "Door"
if "L" "StateHasChanged" "!=" "C" "true"
setlv "State" "Closed" "Door"
endif
endif
endif

Line 1 sets the "State Has Changed" variable to false, so false is the defult state everytime the event is run.
Line 2 checks the door knob is colliding with the player
Line 3 CHecks the local variable "State" on the door is set to Closed
If both of these are true. Line 4 then sets the door "State" variable to Open and then Line 5 sets the "State Has Changed" varaible to true. I use this variable to stop the next part of the code firing, as the next section checks that it is false.
Line 6 closes the condition section checking if the if the door is closed.
Line 7 then checks if the local variable called "State" is set to Open on the door
Line 8 then checks if the "State Has Changed" variable is not set to True (essentially checking if we have just changed the State to Open, if this wasnt here the door would set itself to open and then straight back to closed again.)7
Line 9 then sets the Door State to Closed
Line 10, 11 and 12 then close the remaing open conditions including the Player collision condtion than all actions except line 1 are in.

I havent tested the code but its pretty simple so hopefully it should work. Sorry I havent had as much spare time at the moment to help you out.

2019-07-15 21:21:10

Also at various places in your project you havent got the same amount of condition end actions as you have condition begins. This can cause all sorted of problems. Make sure you close you conditions. or it messes the skip counter up that tells it how many actions to ignore.

2019-07-16 00:36:54 (edited by Sean-Terry01 2019-07-16 03:01:30)

Ok, I did everything you wrote in your last post Aron. But, if I hit the door. Then, I can move to the left, right, and down but, when I try moving back up towards the door, the player footsteps play, but, the player object doesn't move. For example. If I hit the door, I get knocked back one. I can them move to the left, right and down. so, say I am at coordinates 263, 199. I can then move back down to 184. when I try moving back up to the door, the player stays at 184, but can still freely move as much to the left or right as I want to. I'm not sure what I did here. I copied exactly what you said. I added the same actions to the down pressed event on the door as are on the up pressed event. but, of course changed the SubZ by 1 to AddZ by 1. But, once I've collided with the doorknob, then I can't move forward. Even if I've backed away from the doorknob so I'm not touching it anymore.
Edit.
So, I don't think my movement issue has anything to do with the door/doorknob objects. I think the latest update to the GDE when player collides with other walking surfaces than the default one set is causing the issue. In version 2.14, I never had this happen to me. I went north and to the right to go into the house from the part I haven't added a wall to. Then I was at coordinates 215, 305. I move back south a few steps to 301, everything is fine here, but, I move one more step south to 300, which is where the house's wood floor starts, and the wood walk sound plays, but, the player doesn't move. The reverse from above happens then. I can move forward, left and right all I want, but, even if I'm not near the house on the x access, I can't move down. Even if I'm at coordinates X25,Z500, or X500,Z500. I can't move backwards. If I hit the house from anywhere with it to my north, I then, can no longer move forward. so, I can then be at coordinates X360,Z100, and I can't go forward on the Z access. If I hit the house from the left or right, I can no longer move left or right respectively on the X access. Man, I really hope all of this makes sense. I'm trying to be as detailed as possible to show you the issue I'm having. This issue happen with the gravel boarder I've got set up around the edges of the map.

2019-07-16 07:03:05

Could you post a button hold event on your player object for me please Sean?

2019-07-16 07:23:59 (edited by Sean-Terry01 2019-07-16 09:42:11)

Ok, here is the script of u"Up Held".

if "Col" "Area" "==" "L" ""
addz "1"
setgv "PlayerZ" "Z"
ltts "PlayerZ" "0"
endif
if "Col" "Area" "!=" "L" ""
subz "1"
setgv "PlayerZ" "Z"
stopa "Walk Sound"
endif
if "Col" "Main House" "==" "L" ""
setgv "Material" "Wood"
endif
if "Col" "Bottom Boarder" "==" "L" ""
setgv "Material" "Gravel"
endif
if "Col" "Left Boarder" "==" "L" ""
setgv "Material" "Gravel"
endif
if "Col" "Top Boarder" "==" "L" ""
setgv "Material" "Gravel"
endif
if "Col" "Right Boarder" "==" "L" ""
setgv "Material" "Gravel"
endif
if "Col" "Main House" "!=" "L" ""
if "Col" "Bottom Boarder" "!=" "L" ""
if "Col" "Left Boarder" "!=" "L" ""
if "Col" "Top Boarder" "!=" "L" ""
if "Col" "Right Boarder" "!=" "L" ""
setgv "Material" "Grass"
endif
endif
Edit
Ok, I added 3 more end if statements to all directional key held event on the player object, and all works as far as being able to walk on different surfaces now. But, now, my button 3 event on the doorknob doesn't want to work. Here is the script for the button 3 pressed event on the doorknob object.

setlv "Changed State" "False"
if "Col" "Player" "==" "L" ""
if "L" "State" "==" "C" "Closed" "Main House Front Door"
setlv "State" "Open" "Main House Front Door"
setlv "Changed State" "True"
endif
endif
if "L" "State" "==" "C" "Open" "Main House Front Door"
if "L" "Changed State" "==" "C" "True"
setlv "State" "Closed" "Main House Front Door"
endif
endif
endif

I'm glad I figured out the walking issue. But, also, even though the generator no longer plays any sounds if the player isn't touching the starter level, it still does want to activate and it will still start playing the muffled generator sound when I enter the house and still play the normal generator sound when I leave the house even though I have the gen power local variable set right. At least, I thought I did. Lol.

2019-07-16 09:26:20

At the bottom you have five condition begins (if's) and only 2 condition ends (endif's).

This can cause problems. Add 3 more endif commands and see if that makes things any better

2019-07-16 09:43:44

Lol, Just edited the post to reflect this. I just figured that out on my own. Lol. Now I just need to figure out what's wrong with the rest of the edit I wrote. Lol.

2019-07-16 09:48:21

Ok you must be sending the generator object a play command. Maybe on the collision  with the house? Or on a directional button hold event for the house?

If you could send me any code you can find like that, paste it for me.

2019-07-16 10:28:56

Ok, here is the current code for the button 2 pressed event on the generator starter lever.

setlv "Changed State" "False"
if "Col" "Player" "==" "L" ""
if "L" "Gen Power" "==" "C" "Off"
playa "Generator Start" "1" "Generator Start"
wait "3.4"
playposa "Generator" "1" "Generator"
endif
endif
if "L" "Gen Power" "==" "C" "On"
stopa "Generator"
playa "Generator Shutdown" "1" "Generator Shutdown"
endif
if "L" "Gen Power" "==" "C" "Off"
setlv "Changed State" "True"
setlv "Gen Power" "On"
endif
if "L" "Gen Power" "==" "C" "On"
if "L" "Changed State" "==" "C" "False"
setlv "Gen Power" "Off"
endif
endif

Here is the code for the periodical event on the house.

if "Col" "Player" "==" "L" ""
if "L" "Gen Power" "==" "C" "Off" "Generator Crank"
stopa "Generator"
endif
if "L" "Gen Noise" "==" "C" "Normal"
setlv "Gen Noise" "Muffled"
playposa "Generator Muffled" "1" "Generator"
endif
endif
if "Col" "Player" "!=" "L" ""
if "L" "Gen Power" "==" "C" "Off" "Generator Crank"
stopa "Generator"
endif
if "L" "Gen Noise" "==" "C" "Muffled"
setlv "Gen Noise" "Normal"
playposa "Generator" "1" "Generator"
endif
endif

I'm also gonna paste the scripts for, first the door, then the doorknob.

Door.
Up Pressed.
if "L" "State" "==" "C" "Closed"
if "Col" "Player" "==" "L" ""
subz "1"
endif
endif

Door.
Down Pressed.
if "L" "State" "==" "C" "Closed"
if "Col" "Player" "==" "L" ""
addz "1"
endif
endif

Doorknob
Button 3 Pressed.
setlv "Changed State" "False"
if "Col" "Player" "==" "L" ""
if "L" "State" "==" "C" "Closed" "Main House Front Door"
setlv "State" "Open" "Main House Front Door"
setlv "Changed State" "True"
endif
endif
if "L" "State" "==" "C" "Open" "Main House Front Door"
if "L" "Changed State" "==" "C" "True"
setlv "State" "Closed" "Main House Front Door"
endif
endif
endif

Thanks a lot for looking at all this and helping. I really appreciate it a lot. Once I understand your results, I know I'l be able to understand it and make it work on more similar objects.

2019-07-16 12:22:29

Ok I'm just going to focus on the generator noise at the moment.

The periodical event when playing the muffled or normal generator audio isn't checking it the generator is on. It's just checking if it is colliding or not colliding with the player. Add another condition before playing the muffled or normal audio to check if the generator is on. Right now as long as it is colliding with the player it will play.

For example. Turn

if "L" "Gen Noise" "==" "C" "Normal"
setlv "Gen Noise" "Muffled"
playposa "Generator Muffled" "1" "Generator"
endif

Into

if "L" "Gen Power" "==" "C" "On" "Generator Crank"
if "L" "Gen Noise" "==" "C" "Normal"
setlv "Gen Noise" "Muffled"
playposa "Generator Muffled" "1" "Generator"
endif
endif

2019-07-16 19:37:59 (edited by Sean-Terry01 2019-07-16 19:44:08)

Ok, so, the generator no longer plays any noise in the house. But, I can still press button 2 and it still wants to play the generator shutdown sound the second time I press button 2. so, button 2 pressed once doesn't do anything. But, clearly, it does set the generator to on. So, I can press button 2 again and the generator shut down sound plays to make it show that it is at the off state. I wonder then where I got lost with that. Lol.
Here is the code for the button 2 pressed event on the generator crank.

setlv "Changed State" "False"
if "Col" "Player" "==" "L" ""
if "L" "Gen Power" "==" "C" "Off"
playa "Generator Start" "1" "Generator Start"
wait "3.4"
playposa "Generator" "1" "Generator"
endif
endif
if "L" "Gen Power" "==" "C" "On"
stopa "Generator"
playa "Generator Shutdown" "1" "Generator Shutdown"
endif
if "L" "Gen Power" "==" "C" "Off"
setlv "Changed State" "True"
setlv "Gen Power" "On"
endif
if "L" "Gen Power" "==" "C" "On"
if "L" "Changed State" "==" "C" "False"
setlv "Gen Power" "Off"
endif
endif

Thanks again for everything.

2019-07-16 20:32:29

Move line 9 down to the bottom. That's where the colliding with player conditions ends. You want the whole event to be encapsulated in that condition.

At the moment everything below line 9 doesnt care if the player is colliding with it or not. It isn't checking

2019-07-16 20:40:24

Is this the line you want me to move to the bottom?
if "L" "Gen Power" "==" "C" "On"
If so. where should I put it? Is it that line, or is it the end if line right above that?

2019-07-16 20:41:43

The end if line is the one that needs moving

2019-07-16 21:16:41 (edited by Sean-Terry01 2019-07-16 22:12:03)

Yay, I've got it done correctly now. Not a thing happens if I press button 2 when not colliding with the generator starter lever. Wow. I am glad that is done. I assume that I could now effectively use button 2 to open and close doors since I got that button to stop doing things with the generator. Lol.  Now, I can make it get deeper in my brain cause I'm gonna put a window air conditioning unit in the house that you can turn on and off just like the generator. But, could you help me with the original reason this topic was created? Lol. The Door. Man, you are an awesome star. I love working with you. I know I'll get this stuff grasped and be able to actually truly create an audio game. Again, like we've said before. Yes, this is a big thing I'm taking on. But, I really really love the challenge. It really tests my mind and patients. I need that kind of thing right now as I really don't have anything else to do. and It helps keep my mind off current stressful situations. So, thanks again for creating this awesome program and helping me work these things out so I can actually recreate the stuff using another set of objects and test if I've got it right or not. If not, I can just go back to the original code used on the first of those objects and adjust as needed.

2019-07-16 22:08:51

Giving people projects was the idea. I'm really glad it's been something that can benefit you and have a positive impact. Criticism can improve things but knowing your helping someone definitely keeps the motivation up.

As for the door. I'll need code to look at. Anything that affects the players movement in the player object and the door object.

2019-07-16 22:20:25

Here is the code for the door itself.

Door.
Up Held.
if "L" "State" "==" "C" "Closed"
if "Col" "Player" "==" "L" ""
subz "1"
endif
endif

Door.
Down Held.
if "L" "State" "==" "C" "Closed"
if "Col" "Player" "==" "L" ""
addz "1"
endif
endif

Local Variable On Door.
State. Value by default is Closed.

Doorknob.
Button 3.
setlv "Changed State" "False"
if "Col" "Player" "==" "L" ""
if "L" "State" "==" "C" "Closed" "Main House Front Door"
setlv "State" "Open" "Main House Front Door"
setlv "Changed State" "True"
endif
endif
if "L" "State" "==" "C" "Open" "Main House Front Door"
if "L" "Changed State" "==" "C" "True"
setlv "State" "Closed" "Main House Front Door"
endif
endif
endif

Variable on Doorknob.
Changed State
Value is False by default.

Thank you again for the help and positive comments.

2019-07-16 22:47:39 (edited by Charles 2019-07-16 22:49:05)

GDE is a cool project to be honest. But the limited buttons make it hard to add more features. For example, if I'd make a game that has a lot of stats such as health stamina or whatever, I wouldn't have enough keys to check all of these things instead I'll have to make a menu for stats yet if all of the numbers from 1 to 5 are already used, you'll not be able to do anything about it, because usually the w, s, a and d keys will be used to move. But still, I could make a menu that has other menus, so let's say, I'll press 1 to open a menu, then I have, stats, weapons, save game, load game and whatever, but this would just make it harder for the players because they'll have to open the menu, open the other menu they want and then their gonna find the thing they wanted in the first place. It's maybe not designed for this type of games but just wanted to say my opinion. Regards.

2019-07-16 22:54:15

Sorry for double posting. But I noticed after creating the farm game as explaned in the website that if I press w 2times or any button to walk more than once at a time it interrupts the walking sound and plays an other. Does that mean that it cannot play 2 sounds or more together? I don't think it should interrupt it. If there's a way to make sounds not interrupt each other, please let me know. Regards.

2019-07-16 22:56:42

Hey Charles. Yeah I get the desire for more buttons. But the PCP is the PC version of the game console. And mimics the amount of buttons available, which is limited like any other console. How many people overcome this is by combining buttons. Such as holding bottom 5 enter let's say a stat mode. Then button 1 while holding 5 would say you health. And button 2 while also holding 5 could say your stamina etc.

I hope this limitation isn't a huge problem. I'm sure mechanics can be implemented to still achieve the games you want to make. And i would be happy to help you achieve them.

2019-07-16 22:58:37

Yes I understand. But can we make button combinations in GDE? Or it cant do that yet?

2019-07-16 22:59:18

Not trying to say anything wrong here, but, I think the last 2 posts should have been put in the other GDE topic in the dev room. That way we don't get too off topic about creating objects and making them work.

2019-07-16 23:00:15

Sorry