Sx_Town_Set - Swinging Door

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Sx_Town_Set - Swinging Door

Post by Eleven Warrior »

Hi... THANK YOU SO MUCH FOR THIS AWESOME :) I love this door man and ill try out what you said Skuggs. Thxs a million 10 Kudos for you :)
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Sx_Town_Set - Swinging Door

Post by Eleven Warrior »

Hi Skuggs Thxs for this information. YES a new Door would be welcomed by me for sure, can you do it? Errrrr what the hell am I saying...of course you can lol. First though I must check out the converter and your new code thxs a million mate :)

EDIT: Ok skuggs I just realized it's a Blender add on and I have no idea what to do sorry. I am not sure now how to convert the 2 animation files :oops:
User avatar
Skuggasveinn
Posts: 562
Joined: Wed Sep 26, 2012 5:28 pm

Re: Sx_Town_Set - Swinging Door

Post by Skuggasveinn »

Eleven Warrior wrote:EDIT: Ok skuggs I just realized it's a Blender add on and I have no idea what to do sorry. I am not sure now how to convert the 2 animation files :oops:
prozails tool is not a Blender script , its a program that converts the animation files to version 2.
Please have a look at the following thread.
viewtopic.php?f=22&t=7913&p=84745#p84745
Link to all my LoG 2 assets on Nexus.
Link to all my LoG 1 assets on Nexus.
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Sx_Town_Set - Swinging Door

Post by Eleven Warrior »

Yesss dammmm it yesss I got it to work guys awesome. Errr so thxs to Prozils convertor and your script Skuggs. Sorry for being pain in the butt, but this door is so worth it :D :D :D Now I can continue on with the set. Thxs again guys wonderful - I have to say this - 10 Kudos to each of you :D

EDIT: The door can only be opened from one side though, but love it anyway. Now all I have to do is figure away to stop the party walking through the door lol.
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Sx_Town_Set - Swinging Door

Post by Eleven Warrior »

Eleven Warrior wrote:Yesss dammmm it yesss I got it to work guys awesome. Errr so thxs to Prozils convertor and your script Skuggs. Sorry for being pain in the butt, but this door is so worth it :D :D :D Now I can continue on with the set. Thxs again guys wonderful - I have to say this - 10 Kudos to each of you :D

EDIT: The door can only be opened from one side though, but love it anyway. Now all I have to do is figure away to stop the party walking through the door lol.
Ok guys I have done it. It's crude but it works nicely thxs from Skuggs and Prozil. If anyone wants this door just leave a post and ill put the model and scripts in my Drop Box :D

1 - Door Object Code:

Code: Select all

--- Swing Door ---
defineObject{
name = "sx_swingdoor",
baseObject = "lever",
components = {
{
class = "Model",
model = "mod_assets/models/swingdoor_ani.fbx",
offset = vec(0,1.375,0),
},
{
class = "Animation",
animations = {
activate = "mod_assets/animations/swingdoor_open.fbx",
deactivate = "mod_assets/animations/swingdoor_close.fbx",
}
},
},
}
2 - Invisable Blocker: Which is behind the door object.
2a - Add 2 connecters from the Swing Door Lever to the blocker:
onActivate: blocker_1_1: deactivate
onDeactivate: blocker_1_1: activate

Code for Blocker_1:

Code: Select all

defineObject{
	name = "blocker_1",
	baseObject = "blocker",
	components = {
	{
	class = "Obstacle",
	blockParty = true,
	blockItems = true,
	},
	{
	class = "Controller",
	onActivate = function(self)
	self.go.obstacle:enable()
		end,
	onDeactivate = function(self)
	self.go.obstacle:disable()
	end,
	onToggle = function(self)
	if self.go.obstacle:isEnabled() then
	self.go.obstacle:disable()
	else
	self.go.obstacle:enable()
	end
		end,
	},
	},
	placement = "floor",
	editorIcon = 96,
}
User avatar
Skuggasveinn
Posts: 562
Joined: Wed Sep 26, 2012 5:28 pm

Re: Sx_Town_Set - Swinging Door

Post by Skuggasveinn »

Eleven Warrior wrote:EDIT: The door can only be opened from one side though, but love it anyway. Now all I have to do is figure away to stop the party walking through the door lol.
You can place an invisible lever on the other side that toggles the door so you can open it from both sides. (not tested but you can should be able to remove the model component of the dungeon lever)
Link to all my LoG 2 assets on Nexus.
Link to all my LoG 1 assets on Nexus.
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Sx_Town_Set - Swinging Door

Post by Eleven Warrior »

Hi Skuggs. Ok I tried this and I have a invisible lever that works the only problem is it prints this error to the screen:
animation target model not found: fake_lever_1.model
This is because I have not defined the animation events. If I use baseObject = "lever", The lever is the normal lever in the game picture and all not invisible. So the question is do I have to create a new lever animation for close and open or is the code wrong?
Any how thxs for your time and how is the House's going? I cant wait to use or see them ahy :)

Code: Select all

--- Levers fake ---

defineObject{
	name = "fake_lever",
	--baseObject = "lever",
	components = {
	--{
	--class = "Model",
	--model = "assets/models/env/wall_lever.fbx",
	--offset = vec(0, 1.375, 0),
	--},
	{
	class = "Animation",
	animations = {
	activate = "assets/animations/env/lever_down.fbx",
	deactivate = "assets/animations/env/lever_up.fbx",
	}
	},
	{
	class = "Clickable",
	offset = vec(0,1.375,0),
	size = vec(0.4, 0.6, 0.4),
	--debugDraw = true,
	},
	{
	class = "Lever",
	--sound = "lever",
	},
	},
	placement = "wall",
	editorIcon = 12,
}
sajon
Posts: 38
Joined: Fri Nov 08, 2013 7:17 am

Re: Sx_Town_Set - Swinging Door

Post by sajon »

I have been working on improving the mechanics of the swinging door. I found when that once the door was opened you could not close it from inside. this was due to the blocker that was being used. I found a work around....
Here is how:

1.open swingdoor_ani.animation model with GrimRock Model toolkit
a) Create a node. Name it gate ( if you do not do this the editor will complain about missing gate node)
c) Save As mod_assets/sx_towntileset/models/swingdoor_ani.animation
2. Open \modassets\sx_town_objects.lua
a) Paste the following in the door section:

Code: Select all

defineObject{
   name = "sx_swingdoor_clickable",
   baseObject = "lever",
   components = {
   {
	class = "Model",
	model = "mod_assets/sx_towntileset/models/swingdoor_ani.fbx",
	offset = vec(0,1.375,0),
	},
	{
	class = "Animation",
	animations = {
	activate = "mod_assets/animations/swingdoor_open.fbx",
	deactivate = "mod_assets/animations/swingdoor_close.fbx",
   },
   },
   {
	class = "Door",
	sparse = true,
	killPillars = true,
	openVelocity = 10.0,
	closeVelocity = 0,
	closeAcceleration = -10,
    },
      {
         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)
            self.go.door:toggle()
         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,
}

b) save the file
4. Save (ctrl-s) and reload (ctrl-r) the project.
5. place sx_swingdoor_clickable where you want it
4. Now press F5 and test

This method works for me now the lever works as a door.

Notes & Tips
If you have a issue with the door lifting up uncheck the door box in properties this will prevent it from lifting.
To get pillars to show up you need to change killPillars = true, to killPillars = false,

Now for why this works
The lever does not have the ability to use the sparse = true, parameter.
sparse: a boolean which controls whether items can be picked through the door.
The original door is (baseObject = "lever",) this is set on the outside of the door so you can click on it only from outside the door without sparse you cannot reach through the door to open it.
Last edited by sajon on Wed Dec 31, 2014 4:50 pm, edited 1 time in total.
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Sx_Town_Set - Swinging Door

Post by Eleven Warrior »

Hi sajon. Thank you for this information I will start it right away awesome man thxs :)
sajon
Posts: 38
Joined: Fri Nov 08, 2013 7:17 am

Re: Sx_Town_Set - Swinging Door

Post by sajon »

Sorry I made a small revision to my previous post. (Wrote the post after a 10 hr work day at midnight)
Step 1 is not needed.
I originally was using a blocker to stop the party from walking through the door when it was a level,
but since it has been converted to a door that is not needed.

just add the gate node and save then define the object with the provided code and it should work....
Post Reply