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!
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

Khollik wrote: Mon Jun 17, 2019 4:43 pm Hello actually adding the "light" component to the "party" object wasn't the most difficult part:

Code: Select all

defineObject{
	name = "party",
	baseObject = "party",
	components = {
		{
		class = "Party",
		
		onDrawGui = function(party, g)
					
		end,  			

		{
			class = "Light",
			type = "spot",
			range = 12,
			color = vec(1.3, 0.68, 0.35),
			brightness = 8,
			spotAngle = 60,
			spotSharpness = 0.4,
			castShadow = true,
			staticShadows = true,
			destroyObject = true,
			shadowMapSize = 256,
			offset = vec(0, 1.5, -0.4),
			onUpdate = function(self)
				local noise = math.noise(Time.currentTime()*3 + 123) * 0.5 + 0.9
				self:setBrightness(noise * 6)
			end,
		},
	  },
}
Is there a way to have different light classes on the party component and then to enable or disable them? ... for instance.. this spotlight only enabled when party has a certain object on them... or would it be better to add the definition to the object?
Badgert
Posts: 258
Joined: Sun Jan 29, 2017 6:14 pm

Re: Ask a simple question, get a simple answer

Post by Badgert »

1
When I'm try to press the preview button, an error message appears
=== Software Failure ===

preview:97547: main function has more than 65536 constants
stack traceback:
[C]: in function 'error'
[string "Dungeon.lua"]: in function 'loadDungeonFile'
[string "DungeonEditor.lua"]: in function 'playPreview'
[string "DungeonEditor.lua"]: in function 'previewButtons'
[string "DungeonEditor.lua"]: in function 'update'
[string "Grimrock.lua"]: in main chunk

2
4GB patch installed

3
I'm trying to make the mod "Xeen's cronicles" part 1 and 2 in a single file.
Total maps are approximately 110-120. All size 32x32

The story and the plot are the same for both parts. I would not like to split the mod into two files ...
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Functions in Lua are limited to 65536 constants at compile time. Because dungeon.lua uses a string constant for every GameObject id and GameObject ids are unique, every GameObject placed in your dungeon corresponds to at least one constant (more if one of its name, or one of its x,y,facing,elevation,level values has not appeared previously).

The easiest workaround for this would be to move some of your spawn() calls from your dungeon.lua to an external script file.
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.
Badgert
Posts: 258
Joined: Sun Jan 29, 2017 6:14 pm

Re: Ask a simple question, get a simple answer

Post by Badgert »

Thank! All clear.
We'll have to split the mod into two different files ...
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

Minmay: is there a way to see beforehand how many constants you have?
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

I suppose you could compile it with luajit yourself and find the constant count in the resulting bytecode. Not sure why you'd need that information though.
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.
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

minmay wrote: Thu Jul 04, 2019 7:09 pm I suppose you could compile it with luajit yourself and find the constant count in the resulting bytecode. Not sure why you'd need that information though.
I was wondering what badgert did to get such a large count. The large amount of levels he merged.. ?
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

Code: Select all

defineObject{
	name = "party",
	baseObject = "party",
	components = {
		{
		class = "Party",
		
		onDrawGui = function(party, g)
					
		end,  			
			},
		{
			class = "Light",
			type = "spot",
			range = 4,
			color = vec(1.3, 0.68, 0.35),
			brightness = 4,
			spotAngle = 60,
			spotSharpness = 0.4,
			castShadow = true,
			staticShadows = true,
			destroyObject = true,
			shadowMapSize = 256,
			offset = vec(0, 1.5, -0.4),
			onUpdate = function(self)
				local noise = math.noise(Time.currentTime()*3 + 123) * 0.5 + 0.9
				self:setBrightness(noise * 6)
			end,
		},
	  },
}
... is it possible to turn the class light on and of on the party ? for instance when stepping on a floor trigger?
Asking this because I want to create a sort of flashlight for the party ... , but I dont want it on all the time
any ideas ?

edit by Zo Kath Ra:
I've put the definition inside <code> tags, to make it more readable.
It's the </> symbol in the formatting bar.
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 »

party.light:disable()

party.light:enable()


The party already has a component called 'torch'; that handles the ambient and flaming torch lighting.

party.torch:disable()
party.torch:enable()
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

Thanks Isaac. That should have been obvious for me, but wasnt :shock:
Another question. I can now switch between the party.light and party.torch ... is it possible to make more lightsources attached to the party. Say for instance party.light1 / party.light2 ...

what I am trying to create is a dungeon that has different party light settings when you go deeper in.

Nevermind: I figured it out. Gave them names
Post Reply