[ [ Script ] ] Color Conversion + Light Manipulation

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!
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

[ [ Script ] ] Color Conversion + Light Manipulation

Post by NutJob » Tue Oct 28, 2014 7:47 pm

Out of Order
Last edited by NutJob on Wed Oct 29, 2014 11:47 pm, edited 2 times in total.

NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

................

Post by NutJob » Wed Oct 29, 2014 5:28 pm

..................
Last edited by NutJob on Wed Nov 12, 2014 1:33 am, edited 4 times in total.

User avatar
Drakkan
Posts: 1317
Joined: Mon Dec 31, 2012 12:25 am

Re: [ [ Script ] ] Color Conversion + Light Manipulation

Post by Drakkan » Wed Oct 29, 2014 5:39 pm

errr... sory but what is this script for ? I can change light of color ? Do I need define object for it ? any examples ? How to do that ?
Breath from the unpromising waters.
Eye of the Atlantis

NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: [ [ Script ] ] Color Conversion + Light Manipulation

Post by NutJob » Wed Oct 29, 2014 8:07 pm

Drakkan wrote:what is this script for ?
To dynamically change light colors, turn off particles, fade out lights with other scripts (that you make) using calculation instead of hard/hand-coding it into every script you want to manipulate lighting.
Drakkan wrote:I can change light of color ?
Yes, lighting color and pointLight color can be changed. Still trying to figure out particle colors. I think I've been looking in the wrong places to do this.
Drakkan wrote:Do I need define object for it ?
You don't.
Drakkan wrote:any examples ?
Sure

Code: Select all

library.script.GFX.light({"ceiling_light_20", "ceiling_light_21"}, "red") -- turn these two lights red
library.script.GFX.light({"ceiling_light_20", "ceiling_light_21"}, {"red","33ff21"}) -- turn the first light red, the second a light green
library.script.GFX.light("someLight_01", _, 0, 20000) -- fade out someLight_01 over 20 seconds
library.script.GFX.light("someLight_01", "purple", 0, 5000) -- turn  someLight_01 purple then fade it out over 5 seconds
library.script.GFX.light("someLight_01", _, 1, 2000) -- fade in someLight_01 over two second
library.script.GFX.light({"light01","light02","light03","light04","light05","light06","light07"}) -- toggle all 7 lights
library.script.GFX.light("someLight_01", "#3333ff", _, _, _, 0) -- shut off only the particle effects, the light stays AND was turned blue

-- too many permutations for examples but I hope you get the picture

Drakkan wrote:How to do that ?
Make a script_entity, rename the ID 'library'. That's it.
Last edited by NutJob on Fri Oct 31, 2014 1:17 am, edited 1 time in total.

User avatar
Drakkan
Posts: 1317
Joined: Mon Dec 31, 2012 12:25 am

Re: [ [ Script ] ] Color Conversion + Light Manipulation

Post by Drakkan » Wed Oct 29, 2014 9:14 pm

aaaah, I tried some of these examples and it is really wonderfull. I do not think I am able to use whole potencial of this, however still thanks a lot, I can use it for some riddles and will definitey credit you !
Breath from the unpromising waters.
Eye of the Atlantis

NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: [ [ Script ] ] Color Conversion + Light Manipulation

Post by NutJob » Wed Oct 29, 2014 9:18 pm

Drakkan wrote:aaaah, I tried some of these examples and it is really wonderfull. I do not think I am able to use whole potencial of this, however still thanks a lot, I can use it for some riddles and will definitey credit you !
Groovy! And no worries about the credit. A reply of [gratitude|feedback|criticism{constructive|inflammatory}] in the thread you find any of my scripts works well enough. ~cheers~

User avatar
Drakkan
Posts: 1317
Joined: Mon Dec 31, 2012 12:25 am

Re: [ [ Script ] ] Color Conversion + Light Manipulation

Post by Drakkan » Wed Oct 29, 2014 9:28 pm

NutJob wrote:
Drakkan wrote:aaaah, I tried some of these examples and it is really wonderfull. I do not think I am able to use whole potencial of this, however still thanks a lot, I can use it for some riddles and will definitey credit you !
Groovy! And no worries about the credit. A reply of [gratitude|feedback|criticism{constructive|inflammatory}] in the thread you find any of my scripts works well enough. ~cheers~
crediting you is the smallest thanks I can do right now. I will probably need some specific color changes / effect, will send you PM eventaully. Thanks once again.
Breath from the unpromising waters.
Eye of the Atlantis

NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: [ [ Script ] ] Color Conversion + Light Manipulation

Post by NutJob » Wed Oct 29, 2014 9:52 pm

Drakkan wrote:will send you PM eventaully.
Anytime, but it has limitations and bugs currently until I get documentation. I'm sort of winging-it right now and hope to make it a lot more robust, feature rich, and applicable to other objects. Not just light. I was working on a strobe effect that can be applied to any light but removed it before copying it here. It [strobe] "sort of" worked but requires making a timer/script dynamically and was having some problems with it's destruction, too many timers populating, and some logic errors (mostly programmer error heh).

kelly11
Posts: 17
Joined: Mon Oct 08, 2012 12:30 am

Re: [ [ Script ] ] Color Conversion + Light Manipulation

Post by kelly11 » Wed Oct 29, 2014 10:07 pm

what am i doing wrong. i made a script entity library and put your code into it. Then I made a ceiling light and named it someLight_01.. coupled a floor trigger to another lua script entity with the following code:

function somelight()
library.script.GFX.light({"someLight_01"}, "red") -- turn these two lights red

end

When I step on it I get the following message: attempt do index field pointlight a nil value ... behind this part of line in the script below ------------------------------> obj.pointlight:setColor(GFX.vec(xC))

any help would be apriciated: I am very new to this and trying to learn ..what does what .. etc

if forceFade ~= nil then
if forceFade == 1 then
obj.light:fadeIn(fadeOvertime)
obj.pointlight:fadeIn(fadeOvertime)
obj.particle:fadeIn(fadeOvertime)
else
obj.light:fadeOut(fadeOvertime)
obj.pointlight:fadeOut(fadeOvertime)
obj.particle:fadeOut(fadeOvertime)
end
end
if _colors ~= nil then
if _colors ~= nil then xC = _colors else xC = lastColor end
if xC ~= nil then
obj.pointlight:setColor(GFX.vec(xC))
obj.light:setColor(GFX.vec(xC))
lastColor = xC
end
end
end
end



end

NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: [ [ Script ] ] Color Conversion + Light Manipulation

Post by NutJob » Wed Oct 29, 2014 10:23 pm

kelly11 wrote:what am i doing wrong. i made a script entity library and put your code into it. Then I made a ceiling light
Which ceiling light? I suppose I never checked them all and perhaps(?) not all have 'pointlight' ... let me know. I assumed they all had it and it was the "glare" effect for realism. When I get back to my computer at home I'll do more testing. (at office atm)

Post Reply