One thing that I'd like to show and ask for comments is how events are defined. The idea here is to have the ability to make it easy to write, using just the grimrock editor, without the need to modify any scripts. The current event (see gw_event_1 at 16,16) looks as follows:
Code: Select all
-- is this event enabled?
enabled = true
-- name of the imeage to show
image = "mod_assets/images/example-image.dds"
-- todo: the following x,y coords are temporary.
-- They should be calculated automatically.
-- image position
image_x = 40
image_y = 60
-- text description position
text_x = 220
text_y = 60
-- buttons position
buttons_x = 220
buttons_y = 160
buttons_width = 200
-- initial state
state = 1
-- functions called after specific buttons being pressed
function onHeal()
hudPrint("Healing!")
state = 2
end
function onTalk()
hudPrint("Dwarf is in too much pain to talk.")
end
function onLeave()
enabled = false
end
function onHealed()
hudPrint("He is healed already!")
end
-- defines states. Each entry must have exactly two columns:
-- first is state number, the second is description shown.
states = {
{ 1, "An injured dwarf lies on the ground before you,\n" ..
"nearly unconscious from his wounds." },
{ 2, "The healed dwarf is happy." }
}
-- defines possible actions in each state. Each entry has
-- 3 values. First is state number. Second is action name
-- (will be printed on a button). The third is a function
-- that will be called when action is taken (i.e. button
-- is pressed).
actions = {
{ 1, "tend his wounds", onHeal },
{ 1, "talk", onTalk },
{ 1, "leave", onLeave},
{ 2, "healed", onHealed}
}
