Йоу, в чём тут проблема?
Код:
function Unit.GetUnitNameByID( id )
if id == 11 then return "creature_enchantress_treantprotector"
elseif id == 12 then return "creature_enchantress_treants"
end
print ('ID find')
end
function UnitSpawn( event )
local caster = event.caster
local owner = caster:GetOwner()
local pos = event.caster:GetCursorPosition() + event.caster:GetForwardVector()
local unit_name = Unit.GetUnitNameByID(id)
local Unit = CreateUnitByName(unit_name, pos, true, caster, caster, caster:GetTeamNumber())
Unit:SetControllableByPlayer(caster:GetPlayerOwnerID(), false)
Unit:SetOwner(owner)
print ('Unit spawn')
end
Код:
"enchantress_treantprotector"
{
"BaseClass" "ability_datadriven"
"AbilityTextureName" "treant_natures_guise"
"MaxLevel" "1"
"AbilityBehavior" "DOTA_ABILITY_BEHAVIOR_POINT"
"AbilityUnitTargetType" "DOTA_UNIT_TARGET_BASIC"
"AbilityType" "DOTA_ABILITY_TYPE_BASIC"
"AbilityManaCost" "8"
"AbilityCooldown" "10.0"
"AbilityCastRange" "7000"
"PlayerCanControl" "0"
"AbilitySpecial"
{
"01"
{
"var_type" "FIELD_INTEGER"
"atk_damage_tooltip" "250"
}
"02"
{
"var_type" "FIELD_FLOAT"
"atk_speed_tooltip" "2.5"
}
"03"
{
"var_type" "FIELD_INTEGER"
"atk_range_tooltip" "150"
}
"04"
{
"var_type" "FIELD_INTEGER"
"health_tooltip" "2550"
}
"05"
{
"var_type" "FIELD_INTEGER"
"armor_tooltip" "4"
}
"06"
{
"var_type" "FIELD_INTEGER"
"unitID" "11"
}
}
"precache"
{
"particle" "particles/units/heroes/hero_treant/treant_naturesguise_cast.vpcf"
"soundfile" "soundevents/game_sounds_heroes/game_sounds_treant.vsndevts"
"model" "models/heroes/treant_protector/treant_protector.vmdl"
"model" "models/heroes/treant_protector/treant_crow.vmdl"
"model" "models/heroes/treant_protector/head.vmdl"
"model" "models/heroes/treant_protector/hands.vmdl"
"model" "models/heroes/treant_protector/foliage.vmdl"
}
"OnSpellStart"
{
"RunScript"
{
"ScriptFile" "unit.lua"
"Function" "UnitSpawn"
}
}
}
Код:
[ W VScript ]: Script Runtime Error: ...a\game\dota_addons\heroesclash\scripts\vscripts\unit.lua:16: attempt to index local 'Unit' (a nil value)
[ W VScript ]: stack traceback:
[ W VScript ]: ...a\game\dota_addons\heroesclash\scripts\vscripts\unit.lua:16: in function <...a\game\dota_addons\heroesclash\scripts\vscripts\unit.lua:11>
Последнее редактирование модератором: