Component Creation

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!
Post Reply
RayB
Posts: 140
Joined: Fri Mar 06, 2015 3:45 am

Component Creation

Post by RayB »

I have been trying to use the 'dungeon_wall_open" entity in my mod allowing the player to look into another lower area.
This entity does not have an obstacle component so I tried to script one for it using the following...

dungeon_wall_open_1:createComponent("Obstacle")
dungeon_wall_open_1.obstacle:setBlockParty(true)
dungeon_wall_open_1.obstacle:enable()

Of course it does not work. Can anyone tell me why?
User avatar
Zo Kath Ra
Posts: 944
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Component Creation

Post by Zo Kath Ra »

RayB wrote: Sat Mar 21, 2020 4:13 pm I have been trying to use the 'dungeon_wall_open" entity in my mod allowing the player to look into another lower area.
This entity does not have an obstacle component so I tried to script one for it using the following...

dungeon_wall_open_1:createComponent("Obstacle")
dungeon_wall_open_1.obstacle:setBlockParty(true)
dungeon_wall_open_1.obstacle:enable()

Of course it does not work. Can anyone tell me why?
viewtopic.php?f=22&t=7897&start=10#p102392

Doesn't explain why adding an obstacle component dynamically doesn't work, though.
I suppose if you wanted the obstacle component to work, you'd have to add it in the object definition.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Component Creation

Post by minmay »

ObstacleComponent doesn't work when created dynamically, you'll have to put it in the object definition instead.

A couple other things to consider here:
1. dungeon_wall_open has minimalSaveState, so your created Component will not be preserved across save/load, breaking your dungeon.
2. dungeon_wall_open has "wall" placement, but ObstacleComponent blocks an entire square. This may or may not be a problem depending on where you're using it; if it is a problem, use DoorComponent instead.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: Component Creation

Post by Isaac »

RayB wrote: Sat Mar 21, 2020 4:13 pm ...allowing the player to look into another lower area.
Is this intended to allow the player to view a lower area from above, with a wall or Bannister?


Similar to this?
Image
RayB
Posts: 140
Joined: Fri Mar 06, 2015 3:45 am

Re: Component Creation

Post by RayB »

Yes

I will give the door component a try.
Post Reply