Me again. Relatively simple question;
I am trying to create an enhancement for a shield generator:
Basically just adding a weapon who's muzzle is located on the shield?
From script.lua:
- Code: Select all
CreateEnhancement = function(self, enh)
TShieldStructureUnit.CreateEnhancement(self,enh)
local bp = self:GetBlueprint().Enhancements[enh]
if not bp then return end
# Restraining order
if enh == 'RestrainingOrder' then
local blueprint = self:GetBlueprint()
CreateSlider(self,'muzzle', blueprint.Defense.Shield.ShieldSize, 0, 0, 1000, true)
self:SetWeaponEnabledByLabel('PhasonBeam',true)
elseif enh == 'RestrainingOrderRemove' then
local blueprint = self:GetBlueprint()
CreateSlider(self,'muzzle', -blueprint.Defense.Shield.ShieldSize, 0, 0, 1000, true)
self:SetWeaponEnabledByLabel('PhasonBeam',false)
end
end,
From unit.bp:
- Code: Select all
Enhancements = {
RestrainingOrder = {
BuildCostEnergy = 10000,
BuildCostMass = 1000,
BuildTime = 1000,
Icon = 'cd',
Name = 'Restraining Order',
Slot = 'Back',
},
RestrainingOrderRemove = {
BuildCostEnergy = 1,
BuildCostMass = 1,
BuildTime = 0.1,
Icon = 'cd',
Name = 'Remove Restraining Order',
Prerequisite = 'RestrainingOrder',
RemoveEnhancements = {
'RestrainingOrder',
'RestrainingOrderRemove',
},
Slot = 'Back',
},
},
The enhancement option doesn't appear for the unit, and I get weird glitchiness with the ACU (not sure if related), any ideas?
- Code: Select all
WARNING: Error running '/lua/ui/game/gamemain.lua:OnSelectionChanged': ...nce\gamedata\lua.scd\lua\ui\controls\specialgrid.lua(143): attempt to call method `Hide' (a nil value)
stack traceback:
...nce\gamedata\lua.scd\lua\ui\controls\specialgrid.lua(143): in function `CalcVisible'
...nce\gamedata\lua.scd\lua\ui\controls\specialgrid.lua(167): in function `Refresh'
...orever\gamedata\lua.nx2\lua\ui\game\construction.lua(367): in function `OnCheck'
...alliance\gamedata\mohodata.scd\lua\maui\checkbox.lua(45): in function `SetCheck'
...orever\gamedata\lua.nx2\lua\ui\game\construction.lua(475): in function `CreateTabs'
...orever\gamedata\lua.nx2\lua\ui\game\construction.lua(357): in function `OnCheck'
...alliance\gamedata\mohodata.scd\lua\maui\checkbox.lua(45): in function `SetCheck'
...orever\gamedata\lua.nx2\lua\ui\game\construction.lua(2210): in function `OnSelection'
...\faforever\gamedata\lua.nx2\lua\ui\game\gamemain.lua(491): in function <...\faforever\gamedata\lua.nx2\lua\ui\game\gamemain.lua:465>
Thanks