c++ - Game NPC multi-action lua script design -
i need put scriptable npc in currect game project. project developed in c++ language. using luabind bind lua , c++.
i need call npc function when npc clicked or timer activated. stuck between 2 npc script design.
using kind of npcname_action differentiate every npc.
kind of troublesome give name every different npc.
i'm still thinking how implement in project.
example:hotelbellboy12_click() { .. } hotelbellboy12_timeraction() { .. }
using name of function.
every npc have own lua file.
i'm thinking load script memory , when needed loadedluastate
usinglual_loadbuffer
example:onclick() { .. } ontimeraction() { .. }
which 1 better , why?
i've done before , used similar #2 option. when map loads load configuration lua file containing npc data; among name of script file used npc.
when need load npc in game compile lua file. npc's can use 'model' npc type dictate of common behavior (for example merchant type or commoner type) specified in npc configuration. these model types provide basic functionality such providing trade window when clicked. specific npc's use functions onclick() override model , provide custom handlers.
this worked pretty me, although ends being large volume of scripts if game gets large.
Comments
Post a Comment