Game Builder

Game Builder

評價次數不足
Flickering street lamp
由 Sandles 發表
How to make a flickering street lamp.
   
獎勵
加入最愛
已加入最愛
移除最愛
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 則留言
[LGD]LunatikO 2020 年 8 月 30 日 下午 3:29 
incredibly cool indeed, very detailed, overall a perfect, not so long, well-detailed tutorial.
Bon_Man 2019 年 11 月 1 日 上午 3:47 
cool:steamhappy: