Page 3 of 3
Re: Grim 2 rope item
Posted: Thu Jan 28, 2016 10:07 pm
by RayB
I wonder if you could clear a few more things up for me.
* I thought (from reading the Scripting Reference) that everything in the game was and entity, some being simple like a rock or something and some being more complex like the party. I know that if you try to print an entity it prints 'Table etc. etc.'. You have to use the dot operators i.e. .x, .y, or .level etc. for the print output to be of any use. So from all this I thought it was safe to assume that a level was also an entity. For example: Something like 'lvl = party.map.getAdjacentLevel(0,0,-1)', would set 'lvl' to a level entity. (After all if you try to print it, the output prints 'Table etc. etc.') Now the Scripting Reference gives a list of dot operators which are supposed to work on all entities. Yet a statement like 'print(lvl.level)' only prints nil. Why does the dot operator not work with this entity?
* Looking at the above example, once 'lvl' has been set to the level, how do you go about obtaining the index that that level would have in the dungeon editor's level list? This information would be of great assistance to me for my rope routine.
Re: Grim 2 rope item
Posted: Thu Jan 28, 2016 10:27 pm
by minmay
In Lua, by default, there are eight types: nil, boolean, number, string, function, userdata, thread, and table. In Grimrock, you don't care about thread or userdata. Grimrock 2 adds two additional types available to users: vec (used for 3- and 4- dimensional vectors, like offsets, world position, light colours, etc.) and mat (used by GameObject:getWorldRotation() and GameObject:setWorldRotation()).
Every class listed at the top of the scripting reference is actually a table, that's why you access all their properties and methods with the dot operator.
name, id, x, y, elevation, facing, level, map are properties that are on every GameObject. Not on every table. Map:getAdjacentLevel() returns another Map object. Map is not GameObject. Map is still a table, the dot operator still works, but it doesn't have a 'level' field. Whenever someone says "entity" when talking about Grimrock 2, they actually mean "GameObject".
go is a property on every Component that points to the GameObject it belongs to. All components (PartyComponent, MonsterComponent, StonePhilosopherControllerComponent, etc.) are subclasses of Component, so they have all the fields specified in the Component entry in the scripting reference.
Note that although all the classes and objects listed in the scripting reference are tables, they still cannot be serialized, because they have metatables.
Re: Grim 2 rope item
Posted: Fri Jan 29, 2016 5:44 am
by RayB
Thank you. I guess I was wrong about the Map:getAdjacentLevel() returning an entity (or GameObject as you stated) but I still don't understand how this information will help me obtain an index for the dungeon editor's level list.
For example, if the party is on level 0,0,1 then 'party.map:getAdjacentLevel(0,0,-1)' will return the level above (the map level 0,0,0) that I need to send them to. But, if level 0,0,0 is on the 4th line in the dungeon editors list box, and I use 'party:setPosition(x, y, facing, elevation, level)' to move the party, I need to use '4' for the level value in order to send them to the correct level. There must be a way of obtaining this index. That is what I cannot figure out.
Re: Grim 2 rope item
Posted: Fri Jan 29, 2016 6:35 am
by minmay
Map:getLevel()
Re: Grim 2 rope item
Posted: Fri Feb 05, 2016 8:17 pm
by RayB
Thank you for that. I am now able to send the party to the correct level without the use of level markers.
But, disappointed to say, I have come across another issue. I was reading a post of yours to someone else about a platform to move the party. You mentioned that his code was not good because: what if the party casts a spell or tries to move or something while moving along with the moving platform, then it would crash. I mention this because after reading it I decided to try and move the party while climbing up or down with the rope routine. And sure enough, the party can fall into the pit while climbing and for some reason will end up in no-mans-land and stuck.
So I am working on a correction. I have tried to disable the champions but they can still move and will still fall. I have tried to disable the pit component but the party will still fall through it. (I thought, from reading the reference that disabling a component would be the same as if the component didn't exist.) Why then can't I just disable the pit for the duration of the climb. I have thought about disabling the keyboard and mouse until the climb is finished but I really don't know how.
Got any ideas?