diff --git a/polymer/eduke32/source/lunatic/con_lang.lua b/polymer/eduke32/source/lunatic/con_lang.lua index 01f84f0a8..c60b4d1b1 100644 --- a/polymer/eduke32/source/lunatic/con_lang.lua +++ b/polymer/eduke32/source/lunatic/con_lang.lua @@ -841,9 +841,10 @@ local UserdefLabels = { idplayers = UDRO".idplayers", level_number = { UD".level_number", UD":set_level_number(%%s)" }, lockout = UDRO".lockout", + m_player_skill = UDRO".m_player_skill", + m_volume_number = UDRO".m_volume_number", pause_on = UDRO".pause_on", player_skill = UD".player_skill", - m_volume_number = UDRO".m_volume_number", mouseflip = UDRO".mouseflip", multimode = { "1" }, noexits = UDRO".noexits", diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index d991df790..79a6b854e 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -308,7 +308,7 @@ local int16_st = ffi.typeof "struct { int16_t s; }" function _shoot(i, tilenum, zvel) check_sprite_idx(i) - check_sector_idx(sprite[i].sectnum) -- accessed in A_ShootWithZvel + check_sector_idx(ffiC.sprite[i].sectnum) -- accessed in A_ShootWithZvel check_tile_idx(tilenum) zvel = zvel and int16_st(zvel).s or 0x80000000 -- SHOOT_HARDCODED_ZVEL @@ -768,6 +768,13 @@ function _qgetsysstr(qdst, what, pli) end end +function _getpname(qnum, pli) + bcheck.quote_idx(qnum, true) + check_player_idx(pli) + local uname = ffiC.g_player[pli].user_name + ffiC.C_DefineQuote(qnum, (uname[0] ~= 0) and uname or tostring(pli)) +end + -- switch statement support function _switch(swtab, testval, aci,pli,dist) @@ -969,7 +976,8 @@ end -- NOTE: function args of the C function have overloaded meaning function _A_Spawn(j, pn) - local bound_check = sector[sprite[j].sectnum] -- two in one whack + check_sprite_idx(j) + check_sector_idx(ffiC.sprite[j].sectnum) check_tile_idx(pn) return CF.A_Spawn(j, pn) end @@ -1143,7 +1151,7 @@ function _A_RadiusDamage(i, r, hp1, hp2, hp3, hp4) end function _testkey(pli, synckey) - local bound_check = player[pli] + check_player_idx(pli) if (synckey >= 32ULL) then error("Invalid argument #2 to _testkey: must be in [0..31]", 2) end diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index 544364365..907f0b26b 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -830,18 +830,18 @@ local function do_include_file(dirname, filename, isroot) local io = require("io") local fd, msg = io.open(dirname..filename) - if (fd == nil and not isroot) then + while (fd == nil and not isroot and filename:find("/")) do -- strip up to and including first slash: filename = filename:gsub("^.-/", "") fd, msg = io.open(dirname..filename) + end - -- As a last resort, try the "default directory" - if (fd==nil and g_defaultDir) then - -- strip up to and including last slash (if any): - filename = filename:gsub("^.*/", "") - dirname = g_defaultDir.."/" - fd, msg = io.open(dirname..filename) - end + -- As a last resort, try the "default directory" + if (fd==nil and g_defaultDir) then + -- strip up to and including last slash (if any): + filename = filename:gsub("^.*/", "") + dirname = g_defaultDir.."/" + fd, msg = io.open(dirname..filename) end if (fd == nil) then @@ -2280,7 +2280,9 @@ local Cinner = { getkeyname = cmd(R,R,R) / "_con._getkeyname(%1,%2,%3)", getpname = cmd(R,R) -- THISACTOR - / handle.NYI, + / function(qnum, pli) + return format("_con._getpname(%s,%s)", qnum, thisactor_to_pli(pli)) + end, -- array stuff -- TODO: handle system gamearrays. Right now, the generated code will be wrong. diff --git a/polymer/eduke32/source/lunatic/test/quote_ops.con b/polymer/eduke32/source/lunatic/test/quote_ops.con index febab25c9..234a0fcdd 100644 --- a/polymer/eduke32/source/lunatic/test/quote_ops.con +++ b/polymer/eduke32/source/lunatic/test/quote_ops.con @@ -88,6 +88,13 @@ onevent EVENT_ENTERLEVEL userquote 400 endevent +// Test of 'getpname' command. +onevent EVENT_JUMP + getpname 400 THISACTOR + userquote 400 +endevent + + // Following code by Hendricks266, from // http://forums.duke4.net/topic/1382-duke-64-mod-thread/page__view__findpost__p__150497 gamevar temp 0 0