
Looking for help simulating lightning with UDL or any other method. Not the most knowledgeable so if someone could break it down for me that would be great.
Looking for help simulating lightning with UDL or any other method. Not the most knowledgeable so if someone could break it down for me that would be great.
I wrote a lightning script a while ago that flashed at random intervals, though it was written for LDL. It could be modified for UDL by changing the name of the token properties in the flashOn function (those properties can be found here - emits_bright_light, bright_light_distance, emits_low_light, low_light_distance).
Note that there was a bug in UDL that prevented immediate application of light changes that I think was resolved, though I can't remember at the moment, so YMMV.
EDIT - I can't compile & test right now, but if you have any issues I can try to get to it later.
sorry to ask , when you say changing the name of the token properties in the flashOn function which do you mean , sorry to ask but if you could explain i would appreciate it very much
Looks like my edit and your response cross-posted! There are actually two functions to edit.
Here's the LDL versions (found in the code posted in the link above):
const flashOff = function(src) { src.set('light_radius', 0); } const flashOn = function(src, dim, timeout) { let rand = Math.random() * timeout; if (dim) { src.set('light_dimradius', -15); src.set('light_radius', 200); } else { src.set('light_radius', 200); } setTimeout(flashOff, rand, src); }
Try replacing them with this (untested)
const flashOff = function(src) { src.set('emits_bright_light', false); src.set('emits_low_light', false); } const flashOn = function(src, dim, timeout) { let rand = Math.random() * timeout; if (dim) { src.set('emits_low_light', true); src.set('low_light_distance', 400); } else { src.set('emits_bright_light', true); src.set('bright_light_distance', 200); } setTimeout(flashOff, rand, src); }
If this doesn't work, let me know and I can check it out after work tonight.
No luck , at least not on my part but I am still new to all this stuff . I set up the scene like the example you gave used !Lightning on but no effect.
Here's a little API called Flash that simulates a lightning strike by turning on daylight mode for 300ms
Trigger it with:
!flash
Code (Fixed):
on('ready',()=>{
const FLASH_TIME = 300; // milliseconds
const getPageForPlayer = (playerid) => {
let player = getObj('player',playerid);
if(playerIsGM(playerid)){
return player.get('lastpage');
}
let psp = Campaign().get('playerspecificpages');
if(psp[playerid]){
return psp[playerid];
}
return Campaign().get('playerpageid');
};
const flash = (page) => {
if(page.get('dynamic_lighting_enabled') && !page.get('daylight_mode_enabled')){
page.set({daylight_mode_enabled: true});
setTimeout(()=>page.set({daylight_mode_enabled: false}), FLASH_TIME);
}
}
on('chat:message',(msg)=>{
if('api' === msg.type && /^!flash(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){
let page = getObj('page', getPageForPlayer(msg.playerid));
if(page){
flash(page);
let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname');
sendChat('',`/w "${who}" ⚡ FLASH ⚡`);
}
}
});
});
thank you for your help both of you, I just cant get them to work , i think im going to have to do some more reading up on this stuff im just not understanding what im doing wrong
Just in case it is a basic installation problem, here is a very quick and useful introduction to APIs:
thank you, yes unfortunately I have installed the scripts they just don't seem to activate or turn on when I'm in game. Unfortunately it seems i will have to do without for next session and keep reading up on how API's work
kyle said:
thank you, yes unfortunately I have installed the scripts they just don't seem to activate or turn on when I'm in game. Unfortunately it seems i will have to do without for next session and keep reading up on how API's work
Just to be sure... While you are logged into the game, have you opened the api settings page up in another browser tab and hit the button to restart the api sandbox? Then you can see if there are any errors when it restarts.
No errors :( sorry guys i know it will be something ridiculous and small that I'm doing or not doing but unfortunately I just don't know enough to realise what it is yet.
How are you testing the actual viewing of the lightning? I strongly recommend using a Dummy Player Account, as what you see as GM will be impacted by your GM-level viewing settings (such as the opacity of the GM layer) as well bugs that still exist with UDL. It's possible that the lightning is showing correctly for your players, but you're not seeing it as GM.
@Aaron I try your script but it did not work. I check the sandbox no error, I select the map with the ribbon. I activate by with !flash on chat but nothing happen. UDL was on, and the token had vision.
Ok, I got on and tested this. Turns out I'd completely borked that script at some point, here's a new version that I just tested which works for me:
!flashScript:
on('ready',()=>{ const FLASH_TIME = 300; // milliseconds const getPageForPlayer = (playerid) => { let player = getObj('player',playerid); if(playerIsGM(playerid)){ return player.get('lastpage'); } let psp = Campaign().get('playerspecificpages'); if(psp[playerid]){ return psp[playerid]; } return Campaign().get('playerpageid'); }; const flash = (page) => { if(page.get('dynamic_lighting_enabled') && !page.get('daylight_mode_enabled')){ page.set({daylight_mode_enabled: true}); setTimeout(()=>page.set({daylight_mode_enabled: false}), FLASH_TIME); } } on('chat:message',(msg)=>{ if('api' === msg.type && /^!flash(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){ let page = getObj('page', getPageForPlayer(msg.playerid)); if(page){ flash(page); let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); sendChat('',`/w "${who}" ⚡ FLASH ⚡`); } } }); });
I wrote another version that uses the UDL daylightModeOpacity to fade back to darkness (or the current opacity setting) that looks awesome, but unfortunately seems to be broken in the API for client updates. =( Hopefully that will get fixed and I can release it.
hopefully, from what ive found it seems there are a few ways to do what im after in the older version i hope they update the UDL soon.
It works on a page set up for UDL lighting. You need to not have Global Illumination on for it to activate.
Well I am doing something wrong lol.
The Aaron said:
It works on a page set up for UDL lighting. You need to not have Global Illumination on for it to activate.