PrinceRevivalDK wrote: ↑Tue Oct 24, 2023 1:28 pm
EvenLess wrote: ↑Tue Oct 24, 2023 9:28 am
...
So you would do something like this? Since I have added some more stuff to this code right now it looks like this:
Code: Select all
{$lua}
if syntaxcheck then return end
local movementMeters = 1000 -- The amount of movement.
local rollBonus = 50 -- Bonus added to all dice rolls.
local resistanceLevel = "Immune" -- Resistant or Immune.
local damageType = {
"Bludgeoning",
"Piercing",
"Slashing",
"Acid",
"Cold",
"Fire",
"Force",
"Lightning",
"Necrotic",
"Poison",
"Psychic",
"Radiant",
"Thunder",
}
boost = ''
boost = boost .. "UnlockSpellVariant("
boost = boost .. "IsSpell() or not IsSpell(),"
boost = boost .. "ModifySpellRoll('not SavingThrow','SpellAutoResolveOnAlly'),"
boost = boost .. "ModifyTargetRadius(AdditiveBase,10),"
--boost = boost .. "ModifyNumberOfTargets(AdditiveBase,2),"
boost = boost .. "ModifyMaximumTargets(AdditiveBase,10),"
--boost = boost .. "ModifySpellFlags(Verbal,0),"
boost = boost .. "ModifySpellFlags(Stealth,1),"
boost = boost .. "ModifySpellFlags(Melee,0),"
boost = boost .. "ModifySavingThrowDisadvantage(),"
boost = boost .. "ModifyUseCosts(Override,ActionPoint,0,0),"
boost = boost .. "ModifyUseCosts(Override,BonusActionPoint,0,0),"
boost = boost .. "ModifyUseCosts(Override,ReactionActionPoint,0,0),"
boost = boost .. "ModifyTooltipDescription()"
boost = boost .. "ActionResourcePreventReduction(Movement);"
boost = boost .. ");"
boost = boost .. string.format("ActionResourceOverride(Movement,%s,0);", movementMeters)
boost = boost .. string.format("RollBonus(SkillCheck,%s);", rollBonus)
boost = boost .. string.format("RollBonus(RawAbility,%s);", rollBonus)
boost = boost .. string.format("RollBonus(SavingThrow,%s);", rollBonus)
for i = 1, #damageType do
--boost = boost .. string.format("Resistance(%s, %s);", damageType[i], resistanceLevel)
end
[ENABLE]
AddBoostsToPlayer(boost)
[DISABLE]
RemoveBoostsFromPlayer(boost)
Or would you move the ");" below the string.format ?
I see you found one of my earlier scripts
Without having tested your code, I would imagine that it is failing/not working. Right now you're adding a separate
ActionResourcePreventReduction()
boost into your
UnlockSpellVariant()
boost, then terminating all lines up to that point (the semicolon), then adding a lonely end parenthesis that is then also terminated, followed by 4 more
ActionResourceOverride()
and
RollBonus()
boosts.
You need to keep track of when a opening and closing brackets, as the number must match. So
UnlockSpellVariant()
is a single function/command, which can contain several arguments inside its brackets/parenthesis. This is actually the main reason it is VERY good practice to always indent your code for better readability. Then you can follow your cursor down from the starting bracket (or command that precedes the starting bracket) down to the closing bracket. This section between is often called a "code block".
I've rewritten your code to how I would do it today, keeping it mind that I want it somewhat modular, so I can easily add or remove commands/boosts.
Code: Select all
{$lua}
if syntaxcheck then return end
local rollBonus = 50 -- Bonus added to all dice rolls.
-- Add all the wanted "ModifySpell" options to a table.
local spellMod = {
"ModifySpellRoll('not SavingThrow','SpellAutoResolveOnAlly')",
"ModifyTargetRadius(AdditiveBase,10)",
--"ModifyNumberOfTargets(AdditiveBase,2)",
"ModifyMaximumTargets(AdditiveBase,10)",
--"ModifySpellFlags(Verbal,0)",
"ModifySpellFlags(Stealth,1)",
"ModifySpellFlags(Melee,0)",
"ModifySavingThrowDisadvantage()",
"ModifyUseCosts(Override,ActionPoint,0,0)", -- Set Action Point cost to 0.
"ModifyUseCosts(Override,BonusActionPoint,0,0)", -- Set Bonus Action Point cost to 0.
"ModifyUseCosts(Override,ReactionActionPoint,0,0)", -- Set Reaction Action Point cost to 0.
"ModifyTooltipDescription()",
}
-- Concatenate all the spellMods, separated by a comma, into a single UnlockSpellVariant() boost string.
local spellVariant = string.format("UnlockSpellVariant(IsSpell() or not IsSpell(),%s)",table.concat(spellMod, ','))
-- Add all the wanted boosts to a table.
local boost = {
spellVariant,
"ActionResourcePreventReduction(Movement)",
"Resistance(All, Immune)",
string.format("RollBonus(SkillCheck,%s)", rollBonus), -- Add bonus to skill checks.
string.format("RollBonus(RawAbility,%s)", rollBonus), -- Add bonus to ability checks.
string.format("RollBonus(SavingThrow,%s)", rollBonus), -- Add bonus to saving throws.
}
local boosts = table.concat(boost, ';')
print(boosts)
[ENABLE]
AddBoostsToPlayer(boosts)
[DISABLE]
RemoveBoostsFromPlayer(boosts)
So first I removed the code that you weren't actually using (i.e. the damageType table
ActionResourceOverride()
for movement, since you already have another boost that fully eliminates movement cost). I could have left the
resistanceLevel
variable in there, this again is a thing of preference. I tend to use variables if the same string/result is used multiple places in the following code, that way I only have to change it one place. Or I might use a variable at the top, just so I don't have to hunt through the code to find the one thing I might want to change ad-hoc.
Then I first created a table containg every
ModifySpell*()
" function that should be added to the
UnlockSpellVariant()
boost. I've ensured the commas were removed, as they will be added using the with comma as a delimiter
table.concat()
. This will be stored in the
spellVariant
variable.
Then I create a table with every single boost. Again, I don't add the semicolons, as I'll be adding those with the delimiter argument in the
table.concat()
function.
If in doubt what a function does, just Google the command along with "Lua", then you'll get results that will explain what the command/function does, and its syntax (i.e. how many and in which order any arguments are) and what the command/function returns as in this case you want it to return a string, and not a boolean (true/false) or nil (i.e. nothing) or a table etc. I usually use
print()
to verify the result is as I expect, and if
print()
doesn't output anything, enclose the variable you're trying to print in a
tostring()
, that way whatever type in the result will be converted to a string, so
print()
will at least give you a nice hint of what happened. So f.ex.
print(tostring(boosts))
will always print something, even if it's just "nil" (meaning the variable contains no data whatsoever), or it might return something like "table" and you know you just tried sending a table where you wanted a string.
I can really recommend going through some of the "courses" on
[Link]. They don't have Lua, but JavaScript is somewhat similar in the syntax, so you would easily could take the understanding gained from that course and apply it to many other coding/programming languages. While I don't really know Python, I would really recommend that one as well, as a first language, since you can find and create almost anything in Python. The syntax is a bit different though, but it's good at forcing people into the habit of indenting/formatting their code properly as Python requires proper indentation to work