Page 1 of 1

[Solved] How do I get the name of the current scenario?

Posted: Wed May 26, 2021 6:13 pm
by QGamer
Hello,
I want to access the name of the current scenario from within control.lua. How does one go about doing that? I can't seem to find anything in LuaGameScript that allows me to access this property.

If it helps, I'm trying to print a message to the console, but only in a very specific scenario that is included in one of my other mods:

Code: Select all

if get_scenario_name() == "my-scenario-from-another-mod" then
	player.print( "special message" )
end

Re: How do I get the name of the current scenario?

Posted: Wed May 26, 2021 6:29 pm
by DaveMcW
You can define a unique remote interface.

in scenario:

Code: Select all

remote.add_interface("my_scenario", {})
in mod:

Code: Select all

if remote.interfaces["my_scenario"] then
  game.print("special message")
end

Re: How do I get the name of the current scenario?

Posted: Wed May 26, 2021 6:31 pm
by Bilka

Re: How do I get the name of the current scenario?

Posted: Wed May 26, 2021 8:11 pm
by QGamer
Bilka wrote:
Wed May 26, 2021 6:31 pm
https://lua-api.factorio.com/latest/Lua ... trap.level should help.
This was exactly what I was looking for.
Thank you so much!