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!
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 »

Khollik wrote: Sat Jun 15, 2019 12:22 pm I'm trying to create a new item which produces light only in one direction (like a torchlight).
Just off the top of my head, I'd say:
You need to set the light's type
type = "spot",

Also:
viewtopic.php?f=22&t=14711&p=110343#p110343
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

if anyone manages to create a beam of light that spreads out in the distance like a flashlight, that would be ace.

I'm looking for something like this to make a beam for my lighthouse in my docks and then attach a movement script to it.
User avatar
Khollik
Posts: 171
Joined: Tue Aug 29, 2017 6:44 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by Khollik »

Thanks Zo Kath Ra for redirecting me to Minmay's post, that worked EXACTLY as I wanted!!

Code: Select all

{
			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,
		},
I kept the variation of the noise for the cool atmosphere it gives :geek:
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Is it possible to create an object from this? And can anyone post the defineObject code then?
User avatar
Khollik
Posts: 171
Joined: Tue Aug 29, 2017 6:44 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by Khollik »

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,
		},
	  },
}
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 »

From assets/scripts/monsters/wizard.lua in the Asset Pack:
for i=-1,1,2 do
obj.brain:performAction("warp", x, y, i + 2)

What is the 3rd parameter?
My guess would be movement speed, but I'm not sure.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

It's the direction of the edge extrusion visual effect.
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 »

Good day!
Today I ran into such a problem -
"preview: 97556: main function has more than 65536 constants
stack traceback:"
What does it mean? Is it possible to continue working on the mod somehow or is this the limiting limitation of the file?
Help!!!
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

badgert. what were you doing that caused this problem ?
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 »

Badgert wrote: Tue Jul 02, 2019 9:45 pm Good day!
Today I ran into such a problem -
"preview: 97556: main function has more than 65536 constants
stack traceback:"
What does it mean? Is it possible to continue working on the mod somehow or is this the limiting limitation of the file?
Help!!!
1.
Have you googled, duckduckgoed or even binged:
main function has more than 65536 constants

Can't say I understand any of the explanations, though.

2.
Are you using the 4 GB patch?
(just putting this out here so that someone will come and say "this has nothing to do with the 4 GB" and then proceed to explain what it does have to do with)

3.
I wonder if this is caused by tables you've defined yourself, or by the maps in your dungeon, or something else entirely.
Are they all 32x32?
How many maps are there?
Post Reply