Skip to content

Commit

Permalink
Migrate startdwarf from Ruby to Lua
Browse files Browse the repository at this point in the history
  • Loading branch information
lethosor committed May 27, 2022
1 parent b1bfe27 commit b43e461
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
32 changes: 32 additions & 0 deletions startdwarf.lua
@@ -0,0 +1,32 @@
-- change number of dwarves on initial embark

--[====[
startdwarf
==========
Use at the embark screen to embark with the specified number of dwarves.
- ``startdwarf 10`` would just allow a few more warm bodies to dig in
- ``startdwarf 500`` would lead to a severe food shortage and FPS issues
The number must be 7 or greater.
]====]

local addr = dfhack.internal.getAddress('start_dwarf_count')
if not addr then
qerror('start_dwarf_count address not available - cannot patch')
end

local num = tonumber(({...})[1])
if not num then
qerror('argument must be a number')
elseif num < 7 then
qerror('argument must be at least 7')
end

dfhack.with_temp_object(df.new('uint32_t'), function(temp)
temp.value = num
local temp_size, temp_addr = temp:sizeof()
dfhack.internal.patchMemory(addr, temp_addr, temp_size)
end)
19 changes: 0 additions & 19 deletions startdwarf.rb

This file was deleted.

0 comments on commit b43e461

Please sign in to comment.