Lua command for sleep & build limit for unique units

greenlamb

Chieftain
Joined
Jun 24, 2014
Messages
26
2 Questions:

1. What's the Lua command to make an unit sleep? I get that unit:DoCommand can be used, but in CommandTypes there's only a command for wake, not for sleeping! I thought maybe it's interchangeable, but I tried it out; it didn't make the unit sleep.

Code:
unit:DoCommand(CommandType.COMMAND_WAKE);


2. Is there a way to make the player only able to build 1 unit of a particular unique unit? Much like missionaries in civ 4, where you can only build 3.
 
There's this for the unit class, but I don't see anything in <units> for the individual units (unique or otherwise) within a class type.
Code:
	<Table name="UnitClasses">
		<Column name="ID" type="integer" primarykey="true" autoincrement="true"/>
		<Column name="Type" type="text" notnull="true" unique="true"/>
		<Column name="Description" type="text"/>
		<Column name="MaxGlobalInstances" type="integer" default="-1"/>
		<Column name="MaxTeamInstances" type="integer" default="-1"/>
		[COLOR="Blue"]<Column name="MaxPlayerInstances" type="integer" default="-1"/>[/COLOR]
		<Column name="InstanceCostModifier" type="integer" default="0"/>
		<Column name="DefaultUnit" type="text"/>
	</Table>
 
Perfect, it works! Thanks so much LeeS!

Now anyone else knows anything about using Lua to make units sleep?
 
Now anyone else knows anything about using Lua to make units sleep?
It's not a Command, it's a Mission (MISSION_SLEEP).

I guess you use unit:popMission() and unit:pushMission() to edit the mission stack.
 
Ahh I see. Great, thanks a lot Nutty, I'll give it a go later when I get back home. Thanks again!

Edit:
Adding in the code that worked for me to make the unit named "unit" sleep, for the benefit of anyone else who searches this thread.

Code:
unit:PopMission();
unit:PushMission(MissionTypes.MISSION_SLEEP, 0, 0, 0, 0, 1, MissionTypes.MISSION_SLEEP, unit:GetPlot(), unit);
 
Top Bottom