Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local unit05_messages = {
- "Hello, tiny friend!",
- "Greetings.",
- "I wonder what happened to unit 6 & 7..",
- "Oh. Uhh. Hi!",
- "Are you taking good care of the friends I gave you?",
- "Beep boop. I am bored.",
- "Sorry, were you saying something?",
- }
- script.on_nth_tick(3600, function()
- for _, player in pairs(game.connected_players) do
- local entity = player.surface.find_entities_filtered{name="unit-05"}
- for _, entity in pairs(entity) do
- if player.position and entity.valid then
- local dx = player.position.x - entity.position.x
- local dy = player.position.y - entity.position.y
- local dist = math.sqrt(dx*dx + dy*dy)
- if dist < 10 then
- trigger_message(player, entity)
- end
- end
- end
- end
- end)
- function trigger_message(player, entity)
- -- FIX: storage.rng.talk(N) instead of math.random(N).
- -- The talk generator is created in init_debris() alongside the others.
- local msg = unit05_messages[storage.rng.talk(#unit05_messages)]
- rendering.draw_text{
- text = msg,
- surface = entity.surface,
- target = entity,
- target_offset = {0, -2},
- color = {r=1, g=1, b=0.8},
- scale = 1.5,
- time_to_live = 300,
- players = {player}
- }
- end
Advertisement
Add Comment
Please, Sign In to add comment