Entities redesign and a few ERM features
* 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.
2018-03-17 16:58:30 +02:00
|
|
|
local ReceiverBase = require("core:erm.ReceiverBase")
|
|
|
|
|
|
|
|
local VR = ReceiverBase:new()
|
|
|
|
|
|
|
|
function VR:new(ERM, v)
|
|
|
|
assert(v ~= nil, "!!VR requires variable identifier")
|
|
|
|
return ReceiverBase.new(self, {v=v, ERM=ERM})
|
|
|
|
end
|
|
|
|
|
|
|
|
local match = string.match
|
|
|
|
|
|
|
|
local function trim(s)
|
|
|
|
return match(s,'^()%s*$') and '' or match(s,'^%s*(.*%S)')
|
|
|
|
end
|
|
|
|
|
|
|
|
function VR:H(flagIndex)
|
|
|
|
local v = trim(self.v)
|
|
|
|
self.ERM.F[flagIndex] = v ~= ''
|
|
|
|
end
|
|
|
|
|
2021-04-19 17:28:55 +02:00
|
|
|
function VR:U(subString)
|
|
|
|
self.ERM.F['1'] = string.find(self.v, subString) > 0
|
|
|
|
end
|
|
|
|
|
|
|
|
function VR:M1(startIndex, length)
|
|
|
|
return string.sub(self.v, startIndex - 1, startIndex - 1 + length)
|
|
|
|
end
|
|
|
|
|
|
|
|
function VR:M2(wordIndex)
|
|
|
|
local words = string.gmatch(self.v, "[^%s]+")
|
|
|
|
local i = 0
|
|
|
|
|
|
|
|
for w in words do
|
|
|
|
if i == wordIndex then
|
|
|
|
return w
|
|
|
|
end
|
|
|
|
i = i + 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function VR:M3(val, radix)
|
|
|
|
radix = radix or 10
|
|
|
|
|
|
|
|
if(type(val) ~= "number") then
|
|
|
|
error("The first parameter should be of numeric type")
|
|
|
|
end
|
|
|
|
|
|
|
|
if(type(radix) ~= "number") then
|
|
|
|
error("The second parameter should be of numeric type. Default value is 10.")
|
|
|
|
end
|
|
|
|
|
|
|
|
if radix == 10 then
|
|
|
|
return tostring(val)
|
|
|
|
elseif radix == 16 then
|
|
|
|
return string.format("%x", val)
|
|
|
|
else
|
|
|
|
error("The second parameter value is invalid. Only 10 and 16 radix are supported for now.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function VR:M4()
|
|
|
|
return string.len(self.v)
|
|
|
|
end
|
|
|
|
|
|
|
|
function VR:M5()
|
|
|
|
local firstPos = string.find(str, "[^%s]+")
|
|
|
|
|
|
|
|
return firstPos
|
|
|
|
end
|
|
|
|
|
|
|
|
function VR:M6()
|
|
|
|
local lastPos = 1 + string.len(self.v) - string.find(string.reverse(self.v), "[^%s]+")
|
|
|
|
|
|
|
|
return lastPos
|
|
|
|
end
|
|
|
|
|
Entities redesign and a few ERM features
* 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.
2018-03-17 16:58:30 +02:00
|
|
|
|
|
|
|
return VR
|