GMSV腳本的Lua接口 NpcEventCall
NpcEventCall可以讓用戶在GMSV自身的腳本(data/npc/*.txt)中傳遞和獲取值給lua引擎中處理
定義方式
在npc腳本中,使用關鍵字luac來傳遞參數給lua引擎
在lua腳本的init.lua或其他腳本中加入一個名爲ScriptCall的lua函數,函數的參數下面會介紹
當ScriptCall返回值的時候,會設置該值爲localcount31
ScriptCall參數定義 ScriptCall(npc, player, s)
npc:[數值型] NPC的對象實例的索引player:[數值型] 玩家的對象實例的索引s:[字符串] luac中傳遞的參數
其他說明
傳遞的字符串中,由於gmsv自身的處理,所有字符會變爲小寫,且刪除了所有的空格和大部分符號。
例子
npc腳本
block
luac myplayer set 1
if localcount 31 == 1
luac countsetdone!
function ScriptCall(npc, player, s)
if(string.find(s,"myplayerset")then
NLG.SystemMessage(player, s)
return 1
end
if(string.find(s,"countsetdone")then
NLG.SystemMessage(player, "countsetdone,Lua<->npc腳本 互通正常")
return 1
end
return 1
end
HourGlass