as far as resources go, you could take a look at the official documentation:
http://www.grimrock.net/modding/
particularly the parts on scripting, hooks and asset definition.
to answer your question, a function is a way to isolate a piece of script and make it only run when you want it... usually a function will look something like
Code: Select all
function functionName(variable1,variable2)
-- do some stuff here
end
so when we want to run that block of code, we call the function by name and pass any info we want to it via the variables.
e.g.
With scripting hooks the format is a bit different, and the variables we use are determined by the type of hook. For example onDie will provide an entity for the actual monster that is dying.
hence
or you could write
whatever word you put in the bracket you will be able to use to represent the monster that just died....
so a very simple example would be:
Code: Select all
onDie = function(monster)
hudPrint(monster.name .. " just died")
end
which will print e.g. "spider just died" on the screen.
alternatively
Code: Select all
onDie = function(monster)
hudPrint(monster.id .. " just died")
end
will print e.g. "spider_1 just died".