Page 315 of 396

Re: Ask a simple question, get a simple answer

Posted: Wed Jul 03, 2019 6:10 pm
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?

Re: Ask a simple question, get a simple answer

Posted: Wed Jul 03, 2019 7:43 pm
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 ...

Re: Ask a simple question, get a simple answer

Posted: Wed Jul 03, 2019 10:27 pm
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.

Re: Ask a simple question, get a simple answer

Posted: Thu Jul 04, 2019 11:55 am
by Badgert
Thank! All clear.
We'll have to split the mod into two different files ...

Re: Ask a simple question, get a simple answer

Posted: Thu Jul 04, 2019 12:15 pm
by kelly1111
Minmay: is there a way to see beforehand how many constants you have?

Re: Ask a simple question, get a simple answer

Posted: Thu Jul 04, 2019 7:09 pm
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.

Re: Ask a simple question, get a simple answer

Posted: Thu Jul 04, 2019 9:55 pm
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.. ?

Re: Ask a simple question, get a simple answer

Posted: Sat Jul 06, 2019 5:26 pm
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.

Re: Ask a simple question, get a simple answer

Posted: Sat Jul 06, 2019 7:01 pm
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()

Re: Ask a simple question, get a simple answer

Posted: Sat Jul 06, 2019 9:53 pm
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