Page 1 of 1

Script: Fix Dungeon Wall Lanterns Not Against Wall

Posted: Sun Nov 02, 2014 7:54 pm
by Lark
[edit] This code was example code to be put in your own function. Unfortunately, it referenced entities in non-local variables which would cause the game to crash. While untested as I don't have access to LoG2 here, I put this in a function and added the local statement which should fix the issue. I'll update this edit once I've had time to test it. Too bad the person who complained didn't offer constructive criticism and post a correction here. Sorry for the oversight! -Lark

There's been lots of activity on the Forum and I'm behind, so I don't know if anyone else has noticed this or not, but when I place the dungeon_wall_lantern on a dungeon_wall, it sure looks to me like it is floating just in front of the wall and not on it. So, here is a little code to move them back against the wall, just in case it bothers you.

Code: Select all

function adjustIt()
  local num, bad, obj, val, ix, dx, dy
  num = 0
  bad = 2
  while bad > 0 do
    num = num + 1
    obj = findEntity("dungeon_wall_lantern_" .. num)
    if obj ~= nil then
      val = obj:getWorldPosition()
      val[2] = val[2] + .7
      ix = (3 - (obj.facing % 2) * 2)
      dx, dy = getForward(obj.facing)
      val[ix] = val[ix] + .21 * (dx - dy)
      obj:setWorldPosition(val)
    else
      bad = bad - 1
      end
    end
  end
The code looks for all dungeon_wall_lanterns on a level and moves them back (and up val[2] = val[2] + .7 just because I wanted them higher) and, with bad = 2, requires two consecutive lanterns to not exist before it quits looking for them. That way, if you have a gap somewhere in the naming, it will still catch the later ones. Cheers, -Lark

Re: [FIXED] Dungeon Wall Lanterns Not Against Wall

Posted: Sun Nov 02, 2014 8:00 pm
by NutJob
Thank you! I was was messing with world position on them too then I got distracted and never went back. =)