Ask a simple question, get a simple answer

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!
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

It still works with current Blender versions, the imported object rotation/scale are just wrong sometimes but this is not too annoying to fix.
To get the correct layout in Blender to export a Grimrock model, import an existing model, look at the object hierarchy, and match it (I often do so by importing a model, deleting the existing mesh, and copying my own mesh object into it). Your object hierarchy should look something like this:
Image
If you have a rig then it's a little more complicated:
SpoilerShow
Image
The Blender plugin uses empty objects for nodes; every empty object except game_matrix will turn into a node, as will every mesh object.
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.
Eburt
Posts: 69
Joined: Thu Feb 05, 2015 5:44 am

Re: Ask a simple question, get a simple answer

Post by Eburt »

Thanks again minmay and Isaac. I think I understand where I was going wrong now.
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Is it possible to add a function to a script entity with a console command?
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

One would think so [ via setSource() ], but in practice it doesn't seem to work.
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

I just tried many things, but it seems completely impossible.

I thought I could somehow patch the mod I shared recently, but any additional code is not allowed after the game has started:
- You can't add a function (except in the GameMode table!)
- If you ignore the compatibility warning and load your old save game file, the definitions of new objects in the new mod version are never defined, the init phase occurring only once.
- You can't spawn a script_entity and set or load its source, it will never execute.
- You have no way to build an object dynamically and define its components' functions.

So, I think there is something done to the lua code on the game start that can't be done later or is forbidden for some reason.
It appears all possible ways are intentionally locked.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

AndakRainor wrote:- You can't spawn a script_entity and set or load its source, it will never execute.
You actually can do this by calling setSource() or loadFile() before the ScriptComponent fully initializes.
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.
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

To do this you would need an object definition with this call, and you can't define a new object when loading a save from a previous version of a mod.

But I suppose I could define a "patch" object which just does this for future updates.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

I'm having issues with id setting.
For some reason, when I place an object on the map that creates other objects and uses self.go.id.."_p" to set their IDs, everything works fine.
But when I spawn that object with a spell, it says "invalid entity id".
Any way to work around this?

Here's the line I'm using to spawn objects through the summoned object:

Code: Select all

spawn("object_proxy", l, x, y, (f+1)%4, e, self.go.id.."_p")
EDIT: I got it. the ID cannot start with a number, so I'll just rewrite it to this:

Code: Select all

spawn("object_proxy", l, x, y, (f+1)%4, e, "p_"..self.go.id)
Last edited by zimberzimber on Fri Oct 14, 2016 1:11 am, edited 1 time in total.
My asset pack [v1.10]
Features a bit of everything! :D
Eburt
Posts: 69
Joined: Thu Feb 05, 2015 5:44 am

Re: Ask a simple question, get a simple answer

Post by Eburt »

How is "self" defined when used in the spell? My guess is self.go.id returns nil in your context.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Eburt wrote:How is "self" defined when used in the spell? My guess is self.go.id returns nil in your context.
No, because like I said, the spell spawns an object that spawns an object.
zimberzimber wrote:when I place an object on the map that creates other objects and uses self.go.id.."_p" to set their IDs, everything works fine.
But when I spawn that object with a spell, it says "invalid entity id".
EDIT: Never mind, figured it out. Read my previous post.
My asset pack [v1.10]
Features a bit of everything! :D
Post Reply