mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-26 00:40:56 +00:00
Lunatic: more complex gamevar-decl code.
git-svn-id: https://svn.eduke32.com/eduke32@2534 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
b897a59d82
commit
ef7ad7b554
1 changed files with 23 additions and 3 deletions
|
@ -24,7 +24,8 @@ typedef struct
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int32_t x, y;
|
int32_t x, y;
|
||||||
const int16_t point2, nextwall, nextsector; int16_t cstat;
|
const int16_t point2, nextwall, nextsector;
|
||||||
|
int16_t cstat;
|
||||||
int16_t picnum, overpicnum;
|
int16_t picnum, overpicnum;
|
||||||
int8_t shade;
|
int8_t shade;
|
||||||
uint8_t pal, xrepeat, yrepeat, xpanning, ypanning;
|
uint8_t pal, xrepeat, yrepeat, xpanning, ypanning;
|
||||||
|
@ -566,9 +567,28 @@ function getbunch(sectnum, cf)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- 'simple' code for prohibiting initial assignments to create new variables,
|
-- code for prohibiting initial assignments to create new variables,
|
||||||
-- from 14.2 of PiL
|
-- based on 14.2 of PiL
|
||||||
function gamevar(name, initval) -- aka 'declare'
|
function gamevar(name, initval) -- aka 'declare'
|
||||||
|
local declaredNames = {}
|
||||||
|
|
||||||
|
if (type(name) ~= "string") then
|
||||||
|
error("First argument to 'gamevar' must be a string", 2);
|
||||||
|
end
|
||||||
|
|
||||||
|
if (~string.match(name, "^[%a_][%w_]*$")) then
|
||||||
|
error("First argument to 'gamevar' must be a valid identifier", 2);
|
||||||
|
end
|
||||||
|
|
||||||
|
if (declaredNames[name]) then
|
||||||
|
error(string.format("Duplicate declaration of identifier '%s'", name), 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
if (rawget(G_, name) ~= nil) then
|
||||||
|
error(string.format("Identifier name '%s' is already used in the global environment", name), 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
declaredNames[name] = true
|
||||||
rawset(G_, name, initval or false)
|
rawset(G_, name, initval or false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue