Inserting a video in a factorio instance

Anything that prevents you from playing the game properly. Do you have issues playing for the game, downloading it or successfully running it on your computer? Let us know here.
Post Reply
ever_Lord
Inserter
Inserter
Posts: 20
Joined: Thu Apr 02, 2020 7:20 pm
Contact:

Inserting a video in a factorio instance

Post by ever_Lord »

I dont know anything about tech / coding in factorio.
I could use a video inside the game, with transparency (green background)

the idea is to add a countdown for starting scenario and a "Knock Out thing" when game ends.

Ideally, that has to be possible in scenario, without using mod.

Is this do-able, how would you do it ?

thanks !

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Inserting a video in a factorio instance

Post by DaveMcW »

There is no support for video in mods, or even in the base game. All animations are just single images played one after the other.

You can load a transparent image directly from an unmodded scenario folder:

Code: Select all

/c 
for _, player in pairs(game.players) do
  player.gui.screen.add{name = "my-image", type = "sprite", sprite = "file/my-image.png"}
end
script.on_nth_tick(300, function()
  for _, player in pairs(game.players) do 
    if player.gui.screen["my-image"] then player.gui.screen["my-image"].destroy() end
  end
end)

ever_Lord
Inserter
Inserter
Posts: 20
Joined: Thu Apr 02, 2020 7:20 pm
Contact:

Re: Inserting a video in a factorio instance

Post by ever_Lord »

That must be helpful, thanks !

So say i want to show 4 images after some button has been clicked :

image img1 appears in the middle of the screen, then 1 second later img2 replaces img1 and so on.


Would you help me do that please ? or do i have enough infos to do it myself (i've not tested anything yet) ?

ever_Lord
Inserter
Inserter
Posts: 20
Joined: Thu Apr 02, 2020 7:20 pm
Contact:

Re: Inserting a video in a factorio instance

Post by ever_Lord »

So if anyone comes here, here the trick
in player.gui.screen.add{name = "my-image", type = "sprite", sprite = "file/my-image.png"}
"file/" refers to the root of the scenario, the folder just beyond "/scenarios"

you can then add subfolders, which i did so i have "[...]\Factorio\scenarios\my_scenario\png\example.png"
so the command is in chat
/c game.player.gui.screen.center.add{name = "my-image", type = "sprite", sprite = "file/png/example.png"}

btw, i'm looking to resize my image in factorio, did anyone manage to do so ?

thanks !

Post Reply

Return to “Technical Help”