setResistances to remove resistances

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

Re: setResistances to remove resistances

Post by Emera Nova »

When I just type in

Code: Select all

function changeResistances(monster,newResistances)
  local damageTypes = {"fire","cold","shock","poison","physical","dispel"}
  local resists = {}
  for _,type in ipairs(damageTypes) do
    resists[type] = newResistances[type] or monster:getResistance(type)
  end
  monster:setResistances(resists)
end
it brings up an error code that says attempt to index local 'newResistances' (a nil value)

so I tried to fill in some of the stuff where it says type :S
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: setResistances to remove resistances

Post by minmay »

The error is occurring because you are not passing anything as the second argument in the function call. I even gave an example. I responded to your post believing that you had a Grimrock 2 modding question, not that you were asking someone to teach you Lua in disguise. There are many tutorials and manuals online that you can consult for that.
This will be my last post in this topic. I am not interested in wasting my time with someone who is not acting in good faith.
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.
Post Reply