Page 4 of 5

Re: Who wants Clickable/Unlockable doors ?

Posted: Fri Nov 14, 2014 4:14 pm
by Doridion
Aisuu wrote:But the door will open as soon as you walk on the tile in front of the door. I dont want that. I want, when party move against the door and then door open. Sorry for my bad explanation, Iam not native english speaker :D
Don't mind about your english, i'm not english native too ;)

For your door system, you can do the door + 2 pressplates trick, and, if I understand what you want, you can link them with onActivate mode to script like that :

Code: Select all

function OpenIfFacing()
   if (my_door.facing == party.facing or my_door.facing == (party.facing+2)%4) and my_door.door:isClosed() then
      my_door.door:open()
   else
      my_door.door:close()
   end
end
Tested and working ;)

Re: Who wants Clickable/Unlockable doors ?

Posted: Fri Nov 14, 2014 4:20 pm
by Aisuu
That basically open the door when party face against the door?
But what if party want to just listen what kind of monsters are behind the door and dont whant to open the door just yet. You know what I mean.. :)

Re: Who wants Clickable/Unlockable doors ?

Posted: Fri Nov 14, 2014 4:23 pm
by Doridion
Aisuu wrote:That basically open the door when party face against the door?
But what if party want to just listen what kind of monsters are behind the door and dont whant to open the door just yet. You know what I mean.. :)
In this way, you can use my clickable doors, and replace my_door.door:open() by my_door.clickable:enable() or my_door.clickable:disable()

There, you'll be able to activate/deactive clickable function of the doors, and so, choose if you want or not open it ;)

Re: Who wants Clickable/Unlockable doors ?

Posted: Fri Nov 14, 2014 4:31 pm
by Aisuu
Thx for ideas. I gonna play with it when I get home :)

Re: Who wants Clickable/Unlockable doors ?

Posted: Fri Nov 28, 2014 5:12 am
by MadCatter
Has anyone figured out how to make the door clickable from both sides? It's a big problem if you close the door from the inside and get locked in.

Also, I don't know if this was deliberate, but maxDistance = 1 means the player can activate the door from 1 block away, maxDistance = 0 means they have to be next to it.

Re: Who wants Clickable/Unlockable doors ?

Posted: Fri Nov 28, 2014 6:18 am
by GoldenShadowGS
MadCatter wrote:Has anyone figured out how to make the door clickable from both sides? It's a big problem if you close the door from the inside and get locked in. Also, I don't know if this was deliberate, but maxDistance = 1 means the player can activate the door from 1 block away, maxDistance = 0 means they have to be next to it.
You can always do a work around.
Only one facing can be true for any given door(0,1,2,3). So the only two valid tiles that can toggle the door is when the party is standing on the tile the door is placed, or the adjacent one the door is facing.

Code: Select all

defineObject{
   name = "my_clickable_door",
        baseObject = "dungeon_door_portcullis",
   components = {
      {
         class = "Door",
         sparse = true,
         killPillars = true,
      },
      {
         class = "Clickable",
         maxDistance = 1,
         -- offset vector is the point where begin the clickable box
         offset = vec(0,1.3,0),
         -- size is the size of our clickable box
         size = vec(2.5,2.5,0.3),
         onClick = function(self)
			local x1 = self.go.x
			local y1 = self.go.y
			local x2 = party.x
			local y2 = party.y
			local facing = self.go.facing
			if x1 == x2 and y1 == y2 then
				self.go.door:toggle()
			elseif facing == 0 and x1 == x2 and y1-1 == y2 then
				self.go.door:toggle()
			elseif facing == 1 and x1+1 == x2 and y1 == y2 then
				self.go.door:toggle()
			elseif facing == 2 and x1 == x2 and y1+1 == y2 then
				self.go.door:toggle()
			elseif facing == 3 and x1-1 == x2 and y1 == y2 then
				self.go.door:toggle()
			end
         end
      },
      {
         class = "Controller",
         onOpen = function(self, name)
            self.go.door:open()
         end,
         onClose = function(self)
            self.go.door:close()
         end,
         onToggle = function(self)
            self.go.door:toggle()
         end,
      },
   },
   placement = "wall",
   editorIcon = 124,
}

Re: Who wants Clickable/Unlockable doors ?

Posted: Fri Nov 28, 2014 7:30 am
by GoldenShadowGS
Aisuu wrote:I need something similar to clickable doors.
I want to open the door (not locked), when party move into the tile with closed door.
It should by onMove hook, facing script. But I have no idea how to put it together or if its even possible.
Try this:
It makes it so when the party moves and bumps into the door, it opens on contact. I think this is what you wanted.
This door can only be opened from one side with this script. Place the door on the tile you want to open from.

Code: Select all

--change script_entity_4 to match the script's name.
party.party:addConnector("onMove", "script_entity_4", "doorcheck")

function doorcheck(self,dir)
--change "dungeon_door_portcullis_1" to the door's name in your dungeon
	local door = dungeon_door_portcullis_1
	if party.x == door.x and party.y == door.y and door.facing == dir then
		door.door:open()
	end
end

Re: Who wants Clickable/Unlockable doors ?

Posted: Fri Nov 28, 2014 11:06 am
by Aisuu
Thats exactly what I wanted, but from both sides. Nevermind, I already gave up on this Idea and implement something else.
Thank you for trying all of you, I really appreciated ;) Maybe someone else need it and use it :)

Re: Who wants Clickable/Unlockable doors ?

Posted: Fri Nov 28, 2014 3:34 pm
by GoldenShadowGS
It can be modified to be opened from both sides if you want me to fix the script.

Re: Who wants Clickable/Unlockable doors ?

Posted: Fri Nov 28, 2014 4:54 pm
by Aisuu
Oh, yes please. I thought its not possible :mrgreen: