I am wanting to use a luna script to change the prerequisites trait of a ship yard.
A example of this would be to change prerequisites trait based on difficulty level.
A example in rules is:
SYRD:
Buildable:
Prerequisites: anypower
So if difficulty level is hard, the lua script would do the equivalent of.
SYRD:
Buildable:
Prerequisites: ~disabled
So how would I do this in lua script?
Use lua script to change prerequisites trait?
Is it possible to use luna script to change prerequisites trait?
Re: Use lua script to change prerequisites trait?
You can use Lua to grant a preqrequisite, so you could change it to something like
and grant the "easy" prerequisite from Lua.
Code: Select all
SYRD:
Buildable:
Prerequisites: ~easy, anypower
Re: Use lua script to change prerequisites trait?
Would you give me a example on how to do this?
Re: Use lua script to change prerequisites trait?
In your rules.yaml:
In Lua:
That should hopefully do it. (Note that I wrote it off the top of my head, so it might need slight adjustments, but I hope you get the gist.)
Code: Select all
SYRD:
Buildable:
Prerequisites: ~easy, anypower
EASY:
AlwaysVisible:
Interactable:
ProvidesPrerequisite:
Code: Select all
-- assuming you have a variable "difficulty"
if difficulty == "easy" then
-- creates the actor for player with variable name "player1", which grants the prerequisite
Actor.Create("easy", false, { Owner = player1 })
end