Really glad to be rid of the combat spam.
In case you really are unclear about what those lines do in the code, and not just joking:
local utils = require 'utils'
Imports the lua file called utils, that is the "require 'utils'" part. This allows you to use the functions defined in the file utils. The 'local utils' defines how you can access those functions, it is an alias for the file utils.lua, you are also calling it utils. You would then access any function in utils.lua with utils.functionname(), the same way you use dfhack.isMapLoaded().
-- yep, whatever.
local args = {...}
This captures the input arguments sent to the script, the stuff typed after the script name. i.e. In 'clean all', all is the arg.
-- Yeah, useful code:
if not args then qerror("Needs an argument, for example: announcement golem") end
Check to see if any arguments were passed, if not prints an error message. Most other scripts print a help menu here.
-- yep, whatever.
local EventType = args[1]
Above you defined args as the arguments passed the script. More specifically you defined args as an array. In programming that is essentually a column of data value like a column in excel. To access each cell of the column you type the array name follow by the index of the value you want inclosded in square brackets [1] in this instance. LUA starts counting at 1, many other programming languages starts at 0. Thus here args[1] is the first value in the array args, in C++ it would be args[0].
In total:
local EventType = args[1]
Creates a new variable and gives it the value of the first argument. You don't have to do this, you could just use args[1] directly, but it doesn't really hurt anything.
-- list of all possible arguments.
-snip-
{
"golem",
"loot",
"lich",
"greatweapon",
this list is probably what you should print out instead of the error message.
--again, no idea, but if I delete it, it wont work anymore. I could probably delete half of it though. It has something to do with the args, but I know I dont need entities. Doesnt matter.
local function findCiv(arg)
local entities = df.global.world.entities.all
if tonumber(arg) then return arg end
if arg and not tonumber(arg) then
for eid,entity in ipairs(entities) do
if entity.entity_raw.code == arg then return entity end
end
end
end
It does not look like you actually use this. I can not see why it would not work if it was not there.
In the screenshot it looks yellow, color says brown?
Add a 'you have discovered magma' for the blood of armok, and make it only run once. You shouldn't have too much difficulty figuring out that (there are some examples in the dfhack folder)