This repository has been archived by the owner on Dec 15, 2020. It is now read-only.
forked from kane-t/dfhack_scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
-- Set the sexual orientation of a unit with the given ID | ||
local utils = require 'utils' | ||
|
||
validArgs = validArgs or utils.invert({ 'unit', 'men', 'women'}) | ||
local args = utils.processArgs({...}, validArgs) | ||
|
||
local men = -1 | ||
local women = -1 | ||
local unit = nil | ||
|
||
if args.unit and tonumber(args.unit) then -- Check for unit declaration !REQUIRED | ||
unit = df.unit.find(tonumber(args.unit)) | ||
else | ||
print('No unit selected') | ||
return | ||
end | ||
|
||
if unit == nil then | ||
print('Bad unit ID') | ||
return | ||
end | ||
|
||
if args.men and tonumber(args.men) then | ||
men = tonumber(args.men) | ||
if men < 0 or men > 2 then | ||
print('Bad orientation value for men (valid values: 0, 1, 2)') | ||
return | ||
end | ||
end | ||
|
||
if args.women and tonumber(args.women) then | ||
women = tonumber(args.women) | ||
if women < 0 or women > 2 then | ||
print('Bad orientation value for women (valid values: 0, 1, 2)') | ||
return | ||
end | ||
end | ||
|
||
if men == -1 and women == -1 then | ||
print('Have to specify a value for either men or women (valid values: 0, 1, 2)') | ||
return | ||
end | ||
|
||
if men == 0 then | ||
unit.status.current_soul.orientation_flags.romance_male = 0 | ||
unit.status.current_soul.orientation_flags.marry_male = 0 | ||
end | ||
if men == 1 then | ||
unit.status.current_soul.orientation_flags.romance_male = 1 | ||
unit.status.current_soul.orientation_flags.marry_male = 0 | ||
end | ||
if men == 2 then | ||
unit.status.current_soul.orientation_flags.romance_male = 0 | ||
unit.status.current_soul.orientation_flags.marry_male = 1 | ||
end | ||
|
||
if women == 0 then | ||
unit.status.current_soul.orientation_flags.romance_female = 0 | ||
unit.status.current_soul.orientation_flags.marry_female = 0 | ||
end | ||
if women == 1 then | ||
unit.status.current_soul.orientation_flags.romance_female = 1 | ||
unit.status.current_soul.orientation_flags.marry_female = 0 | ||
end | ||
if women == 2 then | ||
unit.status.current_soul.orientation_flags.romance_female = 0 | ||
unit.status.current_soul.orientation_flags.marry_female = 1 | ||
end |