I have tried to accomplish various tasks with Grim 2's script but I find the language extremely difficult and cumbersome and confusing to use. I won't go into the hundreds of difficulties I have had trying to script stuff in Grim 2. There have been way too many. I have been writing code (not professionally) since about 1980 and have never used a language that has caused me so much frustration and disappointment. I have never seen so many errors! Seems like anything you try is difficult to achieve. An example:
I know there are a lot of unnecessary lines in the following code but this is the sort of thing I end up doing to try and see what the heck is going wrong.
local c = party.party:getChampion(1) --c should now be the champion, (but two party's, silly!)
print(c:getName() --prints the champions name, so far so good
local I = spawn("peasant_tunic") -- i should now be the peasant_tunic item
print(i.name) --prints 'peasant_tunic' --still good, both c and I are valid
c:insertItem(4,i) --ERROR: bad argument #2 to 'insertItem' (ItemComponent expected, got ???)
c:insertItem(4,spawn("peasant_tunic")) --THIS GIVES THE SAME ERROR
Come on guys! What the hell is going on?!!
I copied this line directly from the scripting reference: Champion:insertItem(slot, item)
Either the lua structuring for this game sucks or the scripting reference does. Give me a break!
I'll take Grim 1 scripting over Grim 2 any day!
Grim 2 Scripting Language is deplorable
Re: Grim 2 Scripting Language is deplorable
You might like the scripting reference better if you read it more carefully. spawn creates and returns a GameObject, Champion:insertItem(slot, item) takes an ItemComponent as the second argument, like the error message says, and like the prototype implies. There is a publicly available asset pack with definitions for all the standard assets, if you are still confused about the function of objects and components. You can also open Isle of Nex in the dungeon editor to see how everything in the main game was scripted (with the exception of the lindworm fight which is hardcoded).
You needed:
You needed:
Code: Select all
c:insertItem(4,spawn("peasant_tunic").item)
Grimrock 2's scripting interface follows object-oriented discipline noticeably better, and honestly, once you understand the component system almost everything is easier to do than it is in Grimrock 1.RayB wrote:I'll take Grim 1 scripting over Grim 2 any day!
We knew that already.RayB wrote:I have been writing code (not professionally)
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Grim 2 Scripting Language is deplorable
Thank you for your response and your patience.
I tried using the item component reference in the script but I placed 'item.' before rather than '.item' after. After all in the line 'local c = party.party:getChampion(1)' the component reference is placed before. I guess I am still a little confused about the proper syntax of this stuff.
I have downloaded the Grim 2 asset pack 2. Is this the one you refer to or is there another one? Also, where can I get this 'Isle of Nex' that I can open in the dungeon editor? I did not notice this dungeon in the asset pack I have.
And finally, what is this lindworm fight you refer to?
I tried using the item component reference in the script but I placed 'item.' before rather than '.item' after. After all in the line 'local c = party.party:getChampion(1)' the component reference is placed before. I guess I am still a little confused about the proper syntax of this stuff.
I have downloaded the Grim 2 asset pack 2. Is this the one you refer to or is there another one? Also, where can I get this 'Isle of Nex' that I can open in the dungeon editor? I did not notice this dungeon in the asset pack I have.
And finally, what is this lindworm fight you refer to?
Re: Grim 2 Scripting Language is deplorable
No, the component is after the GameObject in that line. The first 'party' is the id of the GameObject, the second 'party' is the name of the PartyComponent belonging to that GameObject.RayB wrote:I tried using the item component reference in the script but I placed 'item.' before rather than '.item' after. After all in the line 'local c = party.party:getChampion(1)' the component reference is placed before. I guess I am still a little confused about the proper syntax of this stuff.
Yes.RayB wrote:I have downloaded the Grim 2 asset pack 2. Is this the one you refer to
...It's the regular game. It's the dungeon you go to when you choose "New Game" in the main menu. Did you not finish it? If you really can't figure out how to open it in the editor, here's a dungeon editor file that will load it.RayB wrote:Also, where can I get this 'Isle of Nex' that I can open in the dungeon editor? I did not notice this dungeon in the asset pack I have.
And finally, what is this lindworm fight you refer to?
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Grim 2 Scripting Language is deplorable
No, I have not finished the game completely. I have finished the 1st ending but have yet to finish the final boss battle with the island master and his clones. Almost! But what has finishing the game got to do with loading the game in the dungeon editor? You implied that I should be able to. I was under the impression that a dungeon editor game had to have the dungeon_editor file extension and that it was not possible to load the exported .dat file into the editor. Am I missing something here?
In the meantime thank you for the link. There is a lot to the Grim 2 dungeon but I am sure that in time it will help me to figure some of this stuff out.
I did notice, however, that your link file has the .dungeon_editor file extension. If I could have somehow loaded the Grim 2 game into the editor without the help of your link I would sure like to know how this would be done.
You have helped me a lot and I hate to keep asking but if you could provide a little guidence as to how to do this I would really appreciate it.
In the meantime thank you for the link. There is a lot to the Grim 2 dungeon but I am sure that in time it will help me to figure some of this stuff out.
I did notice, however, that your link file has the .dungeon_editor file extension. If I could have somehow loaded the Grim 2 game into the editor without the help of your link I would sure like to know how this would be done.
You have helped me a lot and I hate to keep asking but if you could provide a little guidence as to how to do this I would really appreciate it.
Re: Grim 2 Scripting Language is deplorable
By making a dungeon_editor file with a dungeonFolder of "assets/dungeons/grimrock2".RayB wrote:If I could have somehow loaded the Grim 2 game into the editor without the help of your link I would sure like to know how this would be done.
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.