can somebody please fix what is wrong with my script ? It crash game when I right-click on empty hand of any champion
mod_assets/scripts/drakkantraits.lua:189: attempt to index local 'weapon' (a nil value)
stack traceback:
mod_assets/scripts/drakkantraits.lua:189: in function 'onComputeCooldown'
[string "MeleeAttack.lua"]: in function 'start'
[string "Champion.lua"]: in function 'attack'
[string "AttackPanel.lua"]: in function 'select'
[string "AttackPanel.lua"]: in function 'drawItemSlot'
[string "AttackPanel.lua"]: in function 'updateAttackButtons'
[string "AttackPanel.lua"]: in function 'update'
[string "AttackPanel.lua"]: in function 'update'
[string "Gui.lua"]: in function 'draw'
[string "GameMode.lua"]: in function 'update'
[string "Grimrock.lua"]: in function 'display'
[string "Grimrock.lua"]: in main chunk
defineTrait{
name = "grandmaster_sword",
uiName = "Sword slasher",
icon = 3,
description = "Any sword attack is 20% faster.",
onComputeCooldown = function(champion, weapon, attack, attackType, level)
if weapon:hasTrait("sword") or weapon:hasTrait("sword") then return 0.833 --row 189
end
end,
}
Error in trait, please help
Re: Error in trait, please help
Try with "if weapon and weapon:hasTrait("sword")" etc...
Alois
Alois

Re: Error in trait, please help
Pretty sure it should be...
(not tested) - remember to check level > 0 and then weapon ~= nil (or just 'if weapon then)
If you dont check these the game can crash at the party creation screen while picking traits
SpoilerShow
Code: Select all
defineTrait{
name = "grandmaster_sword",
uiName = "Sword slasher",
icon = 3,
description = "Any sword attack is 20% faster.",
onComputeCooldown = function(champion, weapon, attack, attackType, level)
if level > 0 then
if weapon and weapon:hasTrait("sword") then
return 0.833
end
end
end,
}
If you dont check these the game can crash at the party creation screen while picking traits
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Error in trait, please help
Do cooldown buffs stack?
I mean if you have different traits that grant a bonus to cooldown..do they stack or do they multiply? How does it work?
I mean if you have different traits that grant a bonus to cooldown..do they stack or do they multiply? How does it work?
Re: Error in trait, please help
onComputeCooldown stacks multiplicatively and doesn't work on spell casts. cooldown_rate increases or decreases are added together before applying, instead of applying separately, and do work on spell casts.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.