Page 1 of 1

LoG2 console changes (components)

Posted: Thu Jan 15, 2015 6:19 am
by Frenchie
When I was stuck I sometimers uses these functions in LoG1, but with LoG2 they didn't work anymore.

Corrected forward teleport function (st is the number of steps forward):

Code: Select all

function Ghost(st) 
fa = party.facing; 
le = party.level; 
xx = party.x; 
yy = party.y; 
zz = party.elevation;
dx, dy = getForward(fa); 
party:setPosition(xx + dx * st, yy + dy * st, fa, zz, le) 
end
The open door function (checking front and back side of a door) not working yet:

Code: Select all

function Sesame() 
fa = party.facing; 
le = party.level; 
xx = party.x; 
yy = party.y; 
dx, dy = getForward(fa) 
     for e in entitiesAt(le, xx, yy) do 
          if e.setDoorState and e.facing == fa then e:open() 
          end 
     end 
     for e in entitiesAt(le, xx + dx, yy + dy) do 
          if e.setDoorState and e.facing == (fa + 2) % 4 then e:open() 
          end 
     end 
end

Re: LoG2 console changes

Posted: Thu Jan 15, 2015 6:39 am
by Isaac
In LoG2, the objects now have components... the door object for instance, has a door component, so the command to set the door [component] state would be: e.door:setDoorState() .... However... it seems to me that setDoorState() is broken in LoG2 :shock:

Open() & close() work fine, but when I tried setDoorState("open") the door sunk into the floor. :o

There is definitely a bug with setDoorState().

_______________________

Code: Select all

function ghost(st)
fa = party.facing;
le = party.level;
xx = party.x;
yy = party.y;
dx, dy = getForward(fa);
party:setPosition( xx + dx * st, yy + dy * st, fa, party.elevation, le)
end

Re: LoG2 console changes (components)

Posted: Thu Jan 15, 2015 1:01 pm
by Frenchie
Thx Isaac, for clearing that up. I'm not fully understanding it all

As I look at the scripting reference it looks like entitiesAt only needs 2 variables -> Map:entitiesAt(number, number). So it doesn't need party level anymore?

Re: LoG2 console changes (components)

Posted: Fri Jan 16, 2015 1:32 am
by Isaac
Frenchie wrote:Thx Isaac, for clearing that up. I'm not fully understanding it all

As I look at the scripting reference it looks like entitiesAt only needs 2 variables -> Map:entitiesAt(number, number). So it doesn't need party level anymore?
Well it would get that from the object.
eg.
  • party.map:entitiesAt(number, number)
  • cheese_1.map:entitiesAt(number, number)

Re: LoG2 console changes (components)

Posted: Sat Jan 17, 2015 12:28 pm
by Frenchie
So, in the Sesame function I need to change the entitiesAt to map:entitiesAt, but do we also need to do something with getOpeningDirection() since your door opened the wrong way?

Re: LoG2 console changes (components)

Posted: Sat Jan 17, 2015 6:20 pm
by Isaac
Frenchie wrote:So, in the Sesame function I need to change the entitiesAt to map:entitiesAt, but do we also need to do something with getOpeningDirection() since your door opened the wrong way?
The door is not supposed to open the wrong way when called... That's an engine bug that Petri needs to look at.