Ryoga
King
- Joined
- Oct 12, 2010
- Messages
- 993
Hello, I've been creating mods for Civ V for a while but I always limited myself to xml and graphics edits. In other words I know practically nothing about lua code.
I'm kinda at loss as how to learn the language, but in my case it's probably better if I learn from experience.
Since I need to create a specific function I thought maybe someone here can help.
What I want the mod to perform is basically the same database updates I'm used to make except instead of adding or replacing lines with preset ones, I want it to randomly select it from a list at the start of the game.
For example if I wanted to change the yield food of Banana resources I'd do it like this:
<Resource_YieldChanges>
<Row>
<ResourceType>RESOURCE_BANANA</ResourceType>
<YieldType>YIELD_FOOD</YieldType>
<Yield>1</Yield>
</Row>
</Resource_YieldChanges>
But what if I wanted it to randomly select whether to set the Yield to "1", "2" or "3"?
This might be a silly example but that's basically the kind of operation that I want the mod to perform and that might have many different applications.
So in other words what I need to understand is how to make lua code randomly choose an item from a list, how to use it to update the database, and how to make it perform it at the start of the game.
Also, what would you do if you wanted it to randomize a list? For example if I gave it a list of numbers from 1 to 10, "1,2,3,4,5,6,7,9,10" how would I make it regenerate the list in a random order quickly and simply?
Thanx in advance.
I'm kinda at loss as how to learn the language, but in my case it's probably better if I learn from experience.
Since I need to create a specific function I thought maybe someone here can help.
What I want the mod to perform is basically the same database updates I'm used to make except instead of adding or replacing lines with preset ones, I want it to randomly select it from a list at the start of the game.
For example if I wanted to change the yield food of Banana resources I'd do it like this:
<Resource_YieldChanges>
<Row>
<ResourceType>RESOURCE_BANANA</ResourceType>
<YieldType>YIELD_FOOD</YieldType>
<Yield>1</Yield>
</Row>
</Resource_YieldChanges>
But what if I wanted it to randomly select whether to set the Yield to "1", "2" or "3"?
This might be a silly example but that's basically the kind of operation that I want the mod to perform and that might have many different applications.
So in other words what I need to understand is how to make lua code randomly choose an item from a list, how to use it to update the database, and how to make it perform it at the start of the game.
Also, what would you do if you wanted it to randomize a list? For example if I gave it a list of numbers from 1 to 10, "1,2,3,4,5,6,7,9,10" how would I make it regenerate the list in a random order quickly and simply?
Thanx in advance.