mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-16 10:19:47 +02:00
ecaa9f5d0b
* Made most Handlers derived from CHandlerBase and moved service API there. * Declared existing Entity APIs. * Added basic script context caching * Started Lua script module * Started Lua spell effect API * Started script state persistence * Started battle info callback binding * CommitPackage removed * Extracted spells::Caster to own header; Expanded Spell API. * implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C * !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented * Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key) * Re-enabled VERM macros. * !?GM0 added * !?TM implemented * Added !!MF:N * Started !?OB, !!BM, !!HE, !!OW, !!UN * Added basic support of w-variables * Added support for ERM indirect variables * Made !?FU regular trigger * !!re (ERA loop receiver) implemented * Fixed ERM receivers with zero args.
59 lines
1.4 KiB
Lua
59 lines
1.4 KiB
Lua
local ReceiverBase = require("core:erm.ReceiverBase")
|
|
local Metatype = require ("core:Metatype")
|
|
local EntitiesChanged = require("netpacks.EntitiesChanged")
|
|
|
|
local SERVICES = SERVICES
|
|
local creatures = SERVICES:creatures()
|
|
local SERVER = SERVER
|
|
|
|
|
|
local function sendChanges(metatype, index, data)
|
|
local pack = EntitiesChanged.new()
|
|
pack:update(metatype, index, data)
|
|
SERVER:commitPackage(pack)
|
|
end
|
|
|
|
local UN = ReceiverBase:new()
|
|
|
|
function UN:new(ERM)
|
|
return ReceiverBase.new(self,{ERM=ERM})
|
|
end
|
|
|
|
UN:p1Dispatcher("G")
|
|
|
|
function UN:G0(x, ...)
|
|
error ("UN:G0 is not implemented")
|
|
end
|
|
|
|
function UN:G1(x, creatureIndex, N, v)
|
|
return nil, nil, (self["G1"..tostring(N)](self, x, creatureIndex, v))
|
|
end
|
|
|
|
function UN:G10(x, creatureIndex, v)
|
|
if v == nil then
|
|
return creatures:getByIndex(creatureIndex):getSingularName()
|
|
else
|
|
v = self.ERM:getZVar(v)
|
|
local packData = {config = {name={singular=v}}}
|
|
sendChanges(Metatype.CREATURE, creatureIndex, packData)
|
|
end
|
|
end
|
|
function UN:G11(x, creatureIndex, v)
|
|
if v == nil then
|
|
return creatures:getByIndex(creatureIndex):getPluralName()
|
|
else
|
|
v = self.ERM:getZVar(v)
|
|
local packData = {config = {name={plural=v}}}
|
|
sendChanges(Metatype.CREATURE, creatureIndex, packData)
|
|
end
|
|
end
|
|
function UN:G12(x, creatureIndex, v)
|
|
error ("UN:G1/*/2/* is not implemented")
|
|
end
|
|
|
|
function UN:G2(x, ...)
|
|
error ("UN:G2 is not implemented")
|
|
end
|
|
|
|
return UN
|