Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(2 edits)

I found an almost ideal code for global variables:

function RUN(_x)
 local _test = load("return " .. _x)
 return _test()
end

HeroHP=75

function SetG(_name,_act,_value)
if (_act=="+") then
 _G[_name] = _G[_name] + _value
elseif (_act=="-") then
 _G[_name] = _G[_name] - _value
elseif (_act=="*") then
 _G[_name] = _G[_name] * _value
elseif (_act=="/") then
 _G[_name] = _G[_name] / _value
else -- default
_G[_name] = _value
end
return _G[_name]
end

RUN("SetG('HeroHP','-',20)")
RUN("print('HeroHP: '..HeroHP)")

PS But maybe there's a more easy and/or advanced way.