Hi,
I have read the messages on how to add LUA to the smaugfuss (it works) but some things are not clear to me probably due to my little knowledge of LUA.
When the mud starts, the "startup_mud.lua" file is loaded (which loads tprint.lua, utilities.lua, reset.lua).
When any PC comes into play, the "startup.lua" file will be loaded for it (which loads tprint, utilities, tasks, tasklist, taskevents, taskhints, whereis, whereis_destination).
What I don't understand now is how future additions should be structured. I'll explain.
In task.lua, for example, Nick has inserted a "looking" function that is activated when the PC is looking and certain conditions are validated.
This function trig as the following appears in act_info.c:
If I add a "test.lua" file with a second function that must be activated by "look":
... how should I go about getting both of them working?
I would like to understand how the handler array works and how it is used:
In "task.lua" I notice that Nick has entered:
I think he add "handlers.looking" table the element "looking".
Just to try I tried to put in "test.lua":
and then use:
But of course it didn't work.
They will be banalities but I didn't understand how to work on the LUA side.
Thanks!
Bye
I have read the messages on how to add LUA to the smaugfuss (it works) but some things are not clear to me probably due to my little knowledge of LUA.
When the mud starts, the "startup_mud.lua" file is loaded (which loads tprint.lua, utilities.lua, reset.lua).
When any PC comes into play, the "startup.lua" file will be loaded for it (which loads tprint, utilities, tasks, tasklist, taskevents, taskhints, whereis, whereis_destination).
What I don't understand now is how future additions should be structured. I'll explain.
In task.lua, for example, Nick has inserted a "looking" function that is activated when the PC is looking and certain conditions are validated.
function looking (vnum)
- need to know about this player
char_info = mud.character_info ()
- we need to know if quest-giver or quest-receiver is here
find_mobs_in_room ()
<cut>
endThis function trig as the following appears in act_info.c:
call_lua (ch, "looking", NULL);If I add a "test.lua" file with a second function that must be activated by "look":
function looking (arg)
send ("looking funcion 2")
end... how should I go about getting both of them working?
I would like to understand how the handler array works and how it is used:
- install handlers into handlers table AFTER this code
- (this code below creates the handlers table)
for _, name in ipairs
{
"new_player", "entered_game",
"speech",
<cut>In "task.lua" I notice that Nick has entered:
table.insert (handlers.looking, looking) - check for tasks in this roomI think he add "handlers.looking" table the element "looking".
Just to try I tried to put in "test.lua":
table.insert (handlers.looking, looking_2)and then use:
function looking_2 (arg)
send ("looking funcion 2")
endBut of course it didn't work.
They will be banalities but I didn't understand how to work on the LUA side.
Thanks!
Bye