Ask a simple question, get a simple answer

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!
Badgert
Posts: 258
Joined: Sun Jan 29, 2017 6:14 pm

Re: Ask a simple question, get a simple answer

Post by Badgert »

Many thanks! This is exactly what I need!
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

I have a newbisch question about posting images on this forum. Somehow I cannot get it to work. I can get a link working to a picture (see my dirt cave post) but not the picture directly on the forum.
I want to post some more pictures. How to do this?

I am using imgur.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Image

If you can see this image, then depending on your browser, you can copy the image link by right-clicking the image (and choosing the correct option), or taking it from the URL address bar. On the imgur website, clicking the image (to zoom) takes you to a direct file URL. You can copy that from the address bar, and paste it into an img tag, on the forum.
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: Ask a simple question, get a simple answer

Post by Mysterious »

Hi all again.

Ok im trying the Script from Skuggs for night and day time actions. What I would like to do is if its 6Pm then the doors shut and if its 7am the doors open.

The Door Code Object:

Code: Select all

defineObject{
	name = "sx_swingdoor_clickable",
	components = {
		{
			class = "Model",
			model = "mod_assets/models/doors/swingdoor.fbx",
			offset = vec(0,1.375,0),
		},
		{
			class = "Model",
			name = "door_logic",
			model = "assets/models/env/dungeon_secret_door.fbx",
			enabled = false
		},
		{
			class = "Animation",
			animations = {
				activate = "mod_assets/animations/swingdoor_open.fbx",
				deactivate = "mod_assets/animations/swingdoor_close.fbx",
			},
		},
		{
			class = "Door",
			sparse = true,
			killPillars = false,
			openVelocity = 10,
			closeVelocity = 0,
			closeAcceleration = -10,
			openSound = "silent",
			closeSound = "silent",
			lockSound = "silent"
		},
		{
			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)
				if self.go.door:isClosed() then
					self.go.controller:open()
				else
					self.go.controller:close()
				end
			end
		},
		{
			class = "Controller",
			onOpen = function(self)
				self.go.door:open()
				playSound("lever") --Change to what you want
				self.go.animation:play("activate")
			end,
			onClose = function(self)
				self.go.door:close()
				playSound("lever") --Change to what you want
				self.go.animation:play("deactivate")
			end,
			onToggle = function(self)
				if self.go.door:isClosed() then
					self.go.controller:open()
				else
					self.go.controller:close()
				end
			end,
		},
	},
	placement = "wall",
	editorIcon = 124,
	tags = { "doors" },
}

Night and Day Code (in editor):

Code: Select all

function nightdoors2() 
    if GameMode.getTimeOfDay() > 1.04 and GameMode.getTimeOfDay() < 1.97 then
   		sx_swingdoor_clickable_3.clickable:disable()
  		sx_swingdoor_clickable_3.controller:disable()
else
  		sx_swingdoor_clickable_3.clickable:enable()
  		sx_swingdoor_clickable_3.controller:activate()
   end
end
What happens is the door is unuseable at night but when the day cycle come back I cannot open the door. I have set a timer on to check 0.1 seconds. I don't know what I have done wrong here?
User avatar
Zo Kath Ra
Posts: 937
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

Mysterious wrote:Night and Day Code (in editor):

Code: Select all

function nightdoors2() 
    if GameMode.getTimeOfDay() > 1.04 and GameMode.getTimeOfDay() < 1.97 then
   		sx_swingdoor_clickable_3.clickable:disable()
  		sx_swingdoor_clickable_3.controller:disable()
else
  		sx_swingdoor_clickable_3.clickable:enable()
  		sx_swingdoor_clickable_3.controller:activate()
   end
end
What happens is the door is unuseable at night but when the day cycle come back I cannot open the door. I have set a timer on to check 0.1 seconds. I don't know what I have done wrong here?
Replace
sx_swingdoor_clickable_3.controller:activate()
with
sx_swingdoor_clickable_3.controller:enable()

Or you can just leave out the calls to the sx_swingdoor_clickable_3.controller methods.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

I think that rather than have it set to 0.1, that you could probably just as well set your timer to 180, or 360.
It could save an awful lot of —guaranteed failure— time checks.

Or you could perhaps check or set the time when the game loads, and set the timer to the exact delay that you need.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Isaac wrote:I think that rather than have it set to 0.1, that you could probably just as well set your timer to 180, or 360.
It could save an awful lot of —guaranteed failure— time checks.
The performance impact of this is utterly irrelevant.
Isaac wrote:Or you could perhaps check or set the time when the game loads, and set the timer to the exact delay that you need.
Except time of day doesn't work that way. It increments when the party moves or turns, not with real-time.
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: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

minmay wrote:
Isaac wrote:I think that rather than have it set to 0.1, that you could probably just as well set your timer to 180, or 360.
It could save an awful lot of —guaranteed failure— time checks.
The performance impact of this is utterly irrelevant.
Is it? I will take your word for it; it still seems a waste to make that check ten times a second for half of the day.
Isaac wrote:Or you could perhaps check or set the time when the game loads, and set the timer to the exact delay that you need.
Except time of day doesn't work that way. It increments when the party moves or turns, not with real-time.
I never liked that part about it. It seems to me that the time should pass even when squandered by loitering. I suppose it is to obfuscate the —much faster than realistic— passage of time during the game.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by bongobeat »

minmay wrote:
bongobeat wrote:Well I didn't know that you can have (and should) only one. But what is the matter when using 5 water_surface_component on the same map? Except for the issue of reflection.
The game only has one reflection buffer. The only things you accomplish by having multiple WaterSurfaceComponents on the same level are:
1. You make it difficult to know which WaterSurfaceComponent will be used to calculate the reflection buffer. This is bad.
2. You make performance slightly worse. This is also bad.

Note that WaterSurfaceComponent isn't really affected by disabling it. You should remove the components entirely, not just disable them.
ok, understood!
well this is corriged then. Thank you!
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: Ask a simple question, get a simple answer

Post by Mysterious »

Hi al.

Thank you for the (door) help :) Someone said to me there was a way you could load a save game into your new mod eg: Legends 1 - and when you finish this game you can continue to Legends 2 - with the same equipment, skils etc....

My question is. Is it possible and where might I find the code for this function?
Than you :)
Post Reply