LoG2 console changes (components)

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!
Post Reply
User avatar
Frenchie
Posts: 219
Joined: Wed Oct 16, 2013 2:50 am

LoG2 console changes (components)

Post 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
Last edited by Frenchie on Thu Jan 15, 2015 1:16 pm, edited 5 times in total.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: LoG2 console changes

Post 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
User avatar
Frenchie
Posts: 219
Joined: Wed Oct 16, 2013 2:50 am

Re: LoG2 console changes (components)

Post 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?
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: LoG2 console changes (components)

Post 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)
User avatar
Frenchie
Posts: 219
Joined: Wed Oct 16, 2013 2:50 am

Re: LoG2 console changes (components)

Post 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?
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: LoG2 console changes (components)

Post 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.
Post Reply