Skip to content

Commit

Permalink
moddable-gods.lua script
Browse files Browse the repository at this point in the history
  • Loading branch information
expwnent committed Jul 3, 2014
1 parent 83b0886 commit 72a0a9a
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ DFHack future
triggers commands when interactions happen
invader-item-destroyer.lua
destroys invaders' items when they die
moddable-gods.lua
standardized version of Putnam's moddable gods script
moddableGods.lua
makes raw moddable gods possible
projectileExpansion.lua
Expand Down
95 changes: 95 additions & 0 deletions scripts/modtools/moddable-gods.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
--scripts/modtools/moddable-gods.lua
--based on moddableGods by Putnam
--edited by expwnent

local utils = require 'utils'

validArgs = validArgs or utils.invert({
'help',
'name',
'spheres',
'gender',
'depictedAs',
'domain',
'description',
-- 'entities',
})
local args = utils.processArgs({...})

if args.help then
print([[scripts/modtools/moddable-gods.lua
arguments:
-help
print this help message
-name godName
sets the name of the god to godName
if there's already a god of that name, the script halts
-spheres [ sphereList ]
define a space-separated list of spheres of influence of the god
-depictedAs str
often depicted as a str
-domain str
set the domain of the god
-description str
set the description of the god
]])
return
end

if not args.name or not args.depictedAs or not args.domain or not args.description or not args.spheres or not args.gender then
error('All arguments must be specified.')
end

local templateGod
for _,fig in ipairs(df.global.world.history.figures) do
if fig.flags.deity then
templateGod = fig
break
end
end
if not templateGod then
error 'Could not find template god.'
end

if args.gender == 'male' then
args.gender = 1
elseif args.gender == 'female' then
args.gender = 0
else
error 'invalid gender'
end

for _,fig in ipairs(df.global.world.history.figures) do
if fig.name.first_name == args.name then
print('god ' .. args.name .. ' already exists. Skipping')
return
end
end

local godFig = df.historical_figure:new()
godFig.appeared_year = -1
godFig.born_year = -1
godFig.born_seconds = -1
godFig.curse_year = -1
godFig.curse_seconds = -1
godFig.old_year = -1
godFig.old_seconds = -1
godFig.died_year = -1
godFig.died_seconds = -1
godFig.name.has_name = true
godFig.breed_id = -1
godFig.flags:assign(templateGod.flags)
godFig.id = df.global.hist_figure_next_id
df.global.hist_figure_next_id = 1+df.global.hist_figure_next_id
godFig.info = df.historical_figure_info:new()
godFig.info.spheres = {new=true}
godFig.info.secret = df.historical_figure_info.T_secret:new()

godFig.sex = args.gender
godFig.name.first_name = args.name
for _,sphere in ipairs(args.spheres) do
godFig.info.spheres:insert('#',df.sphere_type[sphere])
end
df.global.world.history.figures:insert('#',godFig)


1 change: 1 addition & 0 deletions scripts/modtools/moddableGods.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,4 @@ dfhack.onStateChange.letThereBeModdableGods = function(state)
moddableGods()
end
end

0 comments on commit 72a0a9a

Please sign in to comment.