~Basic Scripting and Editor Help(Easy Scripting Updated!)

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!
User avatar
SnowyOwl47
Posts: 148
Joined: Fri Sep 12, 2014 10:41 pm

Re: Basic Scripting and Editor Help(Short Script Reference)

Post by SnowyOwl47 »

JohnWordsworth wrote:Food for thought for someone with more time than me at the moment (I'm using all my spare time at the moment on the new model editor)...

If you want to see a list of most of the components in the game, you can probably use this screenshot from an old blog post... http://www.grimrock.net/wp-content/uplo ... ofiler.jpg

Sure, we don't know what all of the definitions and methods are for these components, but it gives you a place to start experimenting. Using the above chart, we could likely try to make a breakable door that can also be opened by putting something in a socket on it with something like...

Code: Select all

defineObject{
  name = "my_door",
  components = {
    {
      class = "Model",
      model = "...",
    },
    {
      class = "Door",
      ???
    },
    {
      class = "Socket",
      ???
    },
    {
      class = "Health",
      health = 15,
      immunities = { "poison" },
    },
  },
  placement = ??,
  editorIcon = ??
}
There will likely be a lot of trial and error involved but some of the properties on the components will be the same (or similar to) LOG1 I guess. However, I expect there will also be lots of new ones too!

Equally, using the attached list of components, it means you can start trying to play around with entities from the console in the main game (to see what functions exist) doing things like...

Code: Select all

entity = spawn(...); entity.animation:stop(); 
The above might not be a function, but it might work. Anyway, I think I'll just wait for the official asset pack and modding guide to come out, but if you're really eager - this could be a good place to start!
There is a very good chance you can make a breakable door, because really all a door is, is an model. But if you want it to also be able to open and close... that probably will be a little harder but then again you can do a lot more with defining objects now with the new code.

Another thing I'm pretty sure you can do is with objects in the editor you know how at the bottom right when you've clicked on an object there is all those things like monster/controller/connectors/etc I'm fairly sure you can add your own things to be able to change in objects. Now cloning objects would be useful for me right now because I'm trying to make a herder_big a nice guy that won't hurt you and stuff but I don't want to define a new object since I have no clue what the animation file would be called. But i've been doing lots of work on decoding the code in the editor...

Need some help with things go to your dungeons open a dungeon and go to mod_assets_/scripts/dungeon.lua And if you open it you can see lots of the coding, to help you figure out how the script_entity coding :D
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Basic Scripting and Editor Help(Short Script Reference)

Post by JohnWordsworth »

Cloning an object is easy (I think). You just do...

Code: Select all

defineObject {
  name = "jw_herder_big",
  baseObject = "herder_big"
}
And hey presto - you can drop a "jw_herder_big" into your dungeon which acts just like the original.

I don't know if components defined in cloned objects completely override the base object, or just the updated fields override the base fields.
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
Jgwman
Posts: 144
Joined: Thu Jun 28, 2012 10:14 pm

Re: Basic Scripting and Editor Help(Short Script Reference)

Post by Jgwman »

JohnWordsworth wrote: I don't know if components defined in cloned objects completely override the base object, or just the updated fields override the base fields.
It seems to be overriding my entire object; when I use

Code: Select all

baseObject = "tome_wisdom"
the entire object is a Tome of Knowledge (except for my "name" field for the editor) I have a uiName, description, and more defined. Perhaps most of the properties from Grimrock 1 simply no longer apply? Any idea what the equivalent to uiName is?
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Basic Scripting and Editor Help(Short Script Reference)

Post by JohnWordsworth »

It appears that defining a new component on a cloned object will result in that entire component being cleared out, so I don't think it will be easy for us to just rename an item without at least knowing some other information about that item (like the icon image path etc). However, it's easy to add new components (ie. a light) to a book at the moment.

We are, of course, just being impatient. When the asset pack or modding guide is released - all of this will be much more obvious :p.
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
SnowyOwl47
Posts: 148
Joined: Fri Sep 12, 2014 10:41 pm

Re: Basic Scripting and Editor Help(Short Script Reference)

Post by SnowyOwl47 »

JohnWordsworth wrote:Cloning an object is easy (I think). You just do...

Code: Select all

defineObject {
  name = "jw_herder_big",
  baseObject = "herder_big"
}
And hey presto - you can drop a "jw_herder_big" into your dungeon which acts just like the original.

I don't know if components defined in cloned objects completely override the base object, or just the updated fields override the base fields.
Im rarely sure its not that simple I already tried that...
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Basic Scripting and Editor Help(Short Script Reference)

Post by JohnWordsworth »

Having said that, the following will clone the "Tome of Wisdom" with a new title and description!

Code: Select all

defineObject{
	name = "jw_tome_of_wisdom",
	baseObject = "tome_wisdom",
	components = {
		{
			class = "Item",
			uiName = "Boo Yah!",
			gfxIndex = 30,
			description = "A mysterious tome that will give you a skill point!",
		}
	},
}
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
Jgwman
Posts: 144
Joined: Thu Jun 28, 2012 10:14 pm

Re: Basic Scripting and Editor Help(Short Script Reference)

Post by Jgwman »

Nice! I pretty much did that, but I'll move my script directly into your code and try again. I hope onUseItem is still the correct property.
User avatar
Jgwman
Posts: 144
Joined: Thu Jun 28, 2012 10:14 pm

Re: Basic Scripting and Editor Help(Short Script Reference)

Post by Jgwman »

Yours works fine, but it's pretty much exactly the same. What is the gfxIndex referring to?
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Basic Scripting and Editor Help(Short Script Reference)

Post by JohnWordsworth »

SnowyOwl47 wrote:I'm rarely sure its not that simple I already tried that...
Then some sort of magic must be happening, because I've added a red light to the big herder and renamed the Tome of Wisdom on my machine! :p
SpoilerShow
Image
Last edited by JohnWordsworth on Sat Oct 18, 2014 8:16 pm, edited 1 time in total.
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Basic Scripting and Editor Help(Short Script Reference)

Post by JohnWordsworth »

The gfxIndex is the "index" of the icon from an image file that's built into the DAT file. Basically , there's a big graphics atlas (a single image with loads of icons on it spread out in a grid) somewhere with probably a couple of hundred icons in it - this book is the 30th icon in that file.

You can find out this index in game by doing this...

print(spawn("tome_wisdom").item:getGfxIndex());

It's super cool that so many properties can be queried and set now from scripts. This is going to be so much more flexible than LOG1 and we're gonna see some amazing mods :)
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
Post Reply