Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

RPG in a Box

Bring your stories and ideas to life! · By Justin Arnold

How to get Doors working?

A topic by Daza created Apr 24, 2017 Views: 147 Replies: 3
Viewing posts 1 to 4

I looked at the example map and also checked out the script for it called open_door. I noticed tile02 was the tile behind the door and tile03 behind the door to the left, tile01 mentioned in the script i couldnt find on the example map.

So i am assuming the tile ID used in the scripts are to do with perhaps the game engine switching the door to tile03 when opened and back to tile02 when closed to give the appearance of opening and closing on its hinges?

On my map i created IDs for the tiles in the same locations relative (that is behind the door and to the left of door) to the door as in example one and named them tile2a and tile3a, tile04 for the mystery tile01 and duplicated the open_door script and renamed it Opendoor2 and placed that as the script for my door. But this didnt work, nothing happens :( infact if i clicked the door too many times it crashed the game.

Looking at the Source code i notice differences in the duplicate version (duplicate has a green Valid Script btw) this is the only differences i see in the source code...

Original: snippet

modify_navigation("tile01", "tile02", 2);

modify_navigation("tile02", "tile03", 1)

Duplicate:

modify_navigation("tile04", "tile2a", INTERACT_ONLY);

modify_navigation("tile2a", "tile3a", WALK_ONLY)

I think there may be a bug in the example map where it's not showing the ID for that tile, the mystery "tile01" should be the tile in front of the door (the path end tile right outside the house), or "tile04" in the case of your duplicated script. The door itself doesn't change to a different tile, it just has an "opening" animation, and then using the Modify Navigation scripts along with the IDs takes care of changing the navigation paths so you can walk through the doorway once it is open (and prevents the character from clipping through the open door by preventing movement from "tile02" to "tile03").

In regards to the differences between the original and duplicated script, I recently added named constants for the navigation mode values so it defaults to using them now instead of the corresponding integer values. For example, WALK_AND_INTERACT = 0, WALK_ONLY = 1, INTERACT_ONLY = 2, etc. Either can be used, but I added the named constants so you don't have to remember the integer values when typing quick scripts. Here is the changelog that mentions the change: https://itch.io/t/73895/release-notes-for-v0410-alpha

Thanks for your help :) Got the door working. Revisited this issue today and I had two things to tweak, i had to make the path orange on the tile the door sits and i had two tile ID in the wrong place on the tiles themselves.

So we have to copy and alter each script for each door we put into the game. Would be viable to have perhaps object collision for the doors, that the game wont let you pass and when the door is open that object collision wont be in effect because the way is made open, unless you try to walk into the open door. This might remove the need to have a script for every door. Or alternatively when you copy a script it will increment the number for preset variables reserved for door scripts it. ie. tile01, tile02, tile03 are reserved, and when you copy the open door script the game engine increments each one so we get tile04, tile05, tile06 all we have to do is name the tiles around the door with these. Unless its possible to have the game engine automatically name those tiles? or even have function that automatically creates the script and does those things when you place a door, and attaches script to door.

Doors i imagine would be something a game maker will be adding a lot of so might be worth having something like that, even if we have to name the tiles ourselves but the duplicated script will increment the tile id correctly, this would still be a time saver.

Yep, that definitely makes sense. I would like to eventually create some sort of "template" functionality for scripts that would make commonly used functionality like doors easier and less tedious to set up, and should help save time for situations like you described.