Не работает функция

TRex

Пользователь
8 Авг 2018
38
0
У меня не работает объявление победы сил тьмы.
function GameMode:OnEntityKilled( events ) --550
--551
local killedUnit = EntIndexToHScript( event.entindex_killed ) --552
if killedUnit == "GiantBoy" then --553
GameRules:SetGameWinner( DOTA_TEAM_BADGUYS ) --554
end --555
--556
end --557
Хз вообще что делать. Иногда пишет что ошибка в 552 строке но я её не вижу
scripts\vscripts\barebones.lua:552: attempt to index global 'event' (a nil value)
stack traceback:
scripts\vscripts\barebones.lua:552: in function <scripts\vscripts\barebones.lua:550>
Script Runtime Error: scripts\vscripts\barebones.lua:552: attempt to index global 'event' (a nil value)
stack traceback:
scripts\vscripts\barebones.lua:552: in function <scripts\vscripts\barebones.lua:550>
 

Дикий Пёс

Друзья CG
28 Июн 2017
411
96
Проект
Petri Reborn
Вот эта функция в barebones:
Lua:
function GameMode:OnEntityKilled( keys )
  DebugPrint( '[BAREBONES] OnEntityKilled Called' )
  DebugPrintTable( keys )


  -- The Unit that was Killed
  local killedUnit = EntIndexToHScript( keys.entindex_killed )
  -- The Killing entity
  local killerEntity = nil

  if keys.entindex_attacker ~= nil then
    killerEntity = EntIndexToHScript( keys.entindex_attacker )
  end

  -- The ability/item used to kill, or nil if not killed by an item/ability
  local killerAbility = nil

  if keys.entindex_inflictor ~= nil then
    killerAbility = EntIndexToHScript( keys.entindex_inflictor )
  end

  local damagebits = keys.damagebits -- This might always be 0 and therefore useless

  -- Put code here to handle when an entity gets killed
end

Теория: заменить event на events
 

TRex

Пользователь
8 Авг 2018
38
0
Вот эта функция в barebones:
Lua:
function GameMode:OnEntityKilled( keys )
  DebugPrint( '[BAREBONES] OnEntityKilled Called' )
  DebugPrintTable( keys )


  -- The Unit that was Killed
  local killedUnit = EntIndexToHScript( keys.entindex_killed )
  -- The Killing entity
  local killerEntity = nil

  if keys.entindex_attacker ~= nil then
    killerEntity = EntIndexToHScript( keys.entindex_attacker )
  end

  -- The ability/item used to kill, or nil if not killed by an item/ability
  local killerAbility = nil

  if keys.entindex_inflictor ~= nil then
    killerAbility = EntIndexToHScript( keys.entindex_inflictor )
  end

  local damagebits = keys.damagebits -- This might always be 0 and therefore useless

  -- Put code here to handle when an entity gets killed
end

Теория: заменить event на events
все равно не получается, но я сделал через гейм евент что при смерти юнит сообщает гейм евенту чтобы тот объявил победу и сработало
 

I_GRIN_I

Друзья CG
15 Мар 2016
1,335
105
Ты передаваемую в функцию таблицу объявляешь как events, а в коде вызываешь event(без s)
 

TRex

Пользователь
8 Авг 2018
38
0
я дописал 'S' но не помогло имел ввиду
 

I_GRIN_I

Друзья CG
15 Мар 2016
1,335
105
Ты сравниваешь строку с таблицей. HScript - это таблица. killedUnit:GetUnitName() =='idi_uchi_api_leat'
 
  • Нравится
Реакции: vulkantsk
Реклама: