Game Builder
Evaluări insuficiente
Flickering street lamp
De către Sandles
How to make a flickering street lamp.
   
Premiază
Adaugă la preferate
Preferat
Elimină din preferate
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 comentarii
[LGD]LunatikO 30 aug. 2020 la 15:29 
incredibly cool indeed, very detailed, overall a perfect, not so long, well-detailed tutorial.
Bon_Man 1 nov. 2019 la 3:47 
cool:steamhappy: