Game Builder

Game Builder

Not enough ratings
Flickering street lamp
By Sandles
How to make a flickering street lamp.
   
Award
Favorite
Favorited
Unfavorite
The end-result
The setup
You can look at the workshop link if you'd like, but this build is simple. Simply place a street lamp down, and create a light source right in the bulb. On the bulb, you'll need to change the code.
Code

export const PROPS = [
propDecimal("Speed", 100),

propDecimal("OffsetX", 0),
propDecimal("OffsetY", 0.5),
propDecimal("OffsetZ", 0),
];


function assignLight() {
setLight(
card.range,
new Color(1, 1, 1),
vec3(props.OffsetX, props.OffsetY, props.OffsetZ));
}

export function onTick() {
if (typeof card.tick === "undefined") {
card.tick = 0;
}

if (card.tick > 100 - props.Speed) {
var num = Math.random();
if (num < 0.25) {
card.range = 5;
} else if (num >= 0.25 && num < 0.30) {
card.range = 10;
} else if (num >= 0.30 && num < 0.45) {
card.random = 15;
} else if (num >= 0.45 && num < 0.65) {
card.range = 25;
} else if (num >= 0.65) {
card.range = 0;
}

assignLight();
card.tick = 0;
}

card.tick++;
}

export function onResetGame() {
card.tick = 0;
card.range = 40;
}
Options
You have a few options in this card.

  • Speed - 100 is max; the light will flicker very fast. 0 is the minimum.
  • Offsets - You can move where the source of the light is coming from, these are offsets off the street lamp itself.
Workshop link
Please go here if you'd like to import the card!
2 Comments
[LGD]LunatikO 30 Aug, 2020 @ 3:29pm 
incredibly cool indeed, very detailed, overall a perfect, not so long, well-detailed tutorial.
Bon_Man 1 Nov, 2019 @ 3:47am 
cool:steamhappy: