`homeCity`, the home city for the unit(s). `veteran`, sets the veteran flag on the created unit(s) `inCapital`, create unit(s) in the tribe's capital city `randomize`, randomize the list of locations `count`, the number of units to create `options` is a table with any of the following keys: `locations` is a list of tile coordinates, like. This is the Lua implementation of the CreateUnit action. If you want this kind of functionality, civlua.createUnit does it more easily and reliably than civ.createUnit.Ĭreate (a) unit(s) of type `unittype`, owned by tribe `tribe`. Ground units won't be created at sea, you can provide a list of tiles and the unit will be placed on the first valid one, etc. civlua.createUnit and gen.createUnit both allow you to provide some extra information in the arguments, and then handle details behind the wrote civlua.createUnit to recreate the functionality and options of the Create Unit macro event. That means thinking about details and debugging those details. Using civ.createUnit is likely to require you to ask and answer a lot of questions in your code. Want the unit to randomly choose one of 4 tiles? Your code will have to select the tile first. Don't want the unit to appear on another tribe's tile? You must write code to check if the tile is clear, and only create the unit if it is. Want to make multiple units? You must write a loop. If you want to set the home city or veteran status, you must write lines for that. It doesn't care if you're trying to create a land unit on the ocean, or if the destination tile is occupied by another tribe. This information is provided by the Lua Function Reference:Ĭiv.createUnit(unittype, tribe, tile) -> unitĬreates a unit of type `unittype`, owned by `tribe`, at the location given by `tile`.Ĭiv.createUnit will create the unit no questions asked, unless it isn't provided a valid unittype, tribe, or tile. The civ.createUnit function is the function that actually tells the game to do something. How can I copy my scenario to a larger map? How can I have 2 (or more) sets of conditions for building an item, where only one set of conditions has to be true? Is there a way to set (or increase/decrease) the number of unhappy citizens via some sort of function? Suggestion 1. What happens if I use Lua to give a unit a non-integer movement allowance? If the River/Road/Railroad/Alpine movement multipliers are different, which one is chosen? How do I add/remove pollution from a tile? How do I make an event fire if a unit is destroyed on a specific tile? ( Question, Answer) How do you add/remove an improvement (or wonder) from a city be it either when a specific turn is reached or when a city is taken? What is the difference between civ.createUnit, civlua.createUnit, and gen.createUnit, and how do I know which one to use? How do I stop certain ground units from being airlifted? (Delayed Action Module) How can a delayed action use information that is only available when the action is first delayed? ( Question, Answer) How do I convert my existing scenario to Lua, and take advantage of build option restrictions? As a rule of thumb, I'd say after ~6 posts, strongly consider if the discussion should be moved elsewhere. Also, if a question asked here turns out to require substantial coding and/or discussion, please move it to its own thread, or the Lua Scripting Possibilities thread, and provide a link. If you know of questions and answers elsewhere on the forums, it would be helpful to post a link in this thread, and I'll add it to the Q&A List. This way, there is a convenient place to see if a topic has been addressed.ĭon't worry about if a question has been addressed elsewhere, feel free to ask it here anyway. I'll edit this post periodically to add links to the questions and answers. The second is to provide a link index for questions and their answers, as well as other resources. The first is to provide a general Q&A thread for Lua and related topics. This thread is meant to serve two related purposes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |