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!
User avatar
TheLastOrder
Posts: 104
Joined: Wed Oct 17, 2012 1:56 am

Re: Ask a simple question, get a simple answer

Post by TheLastOrder »

Sutekh wrote:The summon stone's wake-up animation takes about 5 seconds by my reckoning, so here's one quick and dirty solution:

1: Place an invisible wall object on the same tile as the summon stone to 'shield' it.
2: Place a timer (with timer unchecked and disableSelf checked) set to 5 seconds and connect it to a script that destroys the invisible wall.
3: Use the same trigger that activates the summon stone's controller to also start the timer, which will destroy the invisible wall at about the same time the summon stone is fully awake.
Awesome (and dirty!!!) :mrgreen:
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

What you're supposed to do is place a summon_stone_pile entity on the same square as the dormant summon stone. It works like the invisible wall you described, except it will play the correct animation and is completely automatic.
You also could have learned this by looking at the main campaign or the asset pack.
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
TheLastOrder
Posts: 104
Joined: Wed Oct 17, 2012 1:56 am

Re: Ask a simple question, get a simple answer

Post by TheLastOrder »

minmay wrote:What you're supposed to do is place a summon_stone_pile entity on the same square as the dormant summon stone. It works like the invisible wall you described, except it will play the correct animation and is completely automatic.
You also could have learned this by looking at the main campaign or the asset pack.
Woah... great job!

How could I take a look at the main campaign? I remember to have read something about this, and I searched the forum... but nothing has been released about the original one besides the lua contents :?:

Thanks a lot!
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Ask a simple question, get a simple answer

Post by Grimfan »

Okay. I want to check if all the monsters in a level are dead so I can open a door. Will this work?

Code: Select all

for e in self.go.map:allEntities() do
if e.monster == 0 then
door_1.door:open()
Or is there more to it than that?
Davenfal
Posts: 5
Joined: Mon Dec 22, 2014 4:58 am

Re: Ask a simple question, get a simple answer

Post by Davenfal »

Hey all, I was wondering if there was a method to spawn a beacon holding it's particular element? I know that in LoG1 to make some assets act like an alcove it required a little dirty work, but since the beacons can already hold particular objects, I believe all that would be needed is to spawn it over the beacon and then do xy and z to get it to trigger properly; unfortunately, I'm more of an artistically driven person so figuring this out through lua scripting is akin to me driving into a brick wall. I'll appreciate any and all help that you all can give.
Last edited by Davenfal on Mon Dec 22, 2014 7:28 am, edited 1 time in total.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Grimfan wrote:Okay. I want to check if all the monsters in a level are dead so I can open a door. Will this work?

Code: Select all

for e in self.go.map:allEntities() do
if e.monster == 0 then
door_1.door:open()
This won't work for a couple reasons: first, "e.monster" cannot possibly be 0, it will either be nil or a component. Presumably you wanted nil there instead of 0. Second, your logic is inverted: you have it opening the door if ANY entity on the level does not have a MonsterComponent. Also, it's entirely possible to have a MonsterComponent not named "monster", but this is probably not a concern. Here's the code you probably wanted:

Code: Select all

for e in self.go.map:allEntities() do
  if e.monster then
    return
  end
end
door_1.door:open()
This iterates through all GameObjects on the map, and aborts if it finds one with a component named "monster". If none of the objects on the level have such a component, it will open the door.
Grimfan wrote:Hell all, I was wondering if there was a method to spawn a beacon holding it's particular element? I know that in LoG1 to make some assets act like an alcove it required a little dirty work, but since the beacons can already hold particular objects, I believe all that would be needed is to spawn it over the beacon and then do xy and z to get it to trigger properly; unfortunately, I'm more of an artistically driven person so figuring this out through lua scripting is akin to me driving into a brick wall. I'll appreciate any and all help that you all can give.
http://www.grimrock.net/modding/scripti ... tComponent
Just use:

Code: Select all

beacon_air_1.socket:addItem(spawn("essence_air").item)
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.
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Ask a simple question, get a simple answer

Post by Grimfan »

Boy, I knew it was riddled with errors. :?

By the way, when I wrote e.monster == 0 Is it the fact that I was referring to a component the reason it can't be 0 or something else? If I wrote say turtle_1.monster == 0 would it still not work?

And thanks for the help minmay. I know us lua newbs test your patience at times, but it's a credit to your character that you persist in helping us nonetheless. :)
Davenfal
Posts: 5
Joined: Mon Dec 22, 2014 4:58 am

Re: Ask a simple question, get a simple answer

Post by Davenfal »

minmay wrote:
Davenfal wrote:Hell all, I was wondering if there was a method to spawn a beacon holding it's particular element? I know that in LoG1 to make some assets act like an alcove it required a little dirty work, but since the beacons can already hold particular objects, I believe all that would be needed is to spawn it over the beacon and then do xy and z to get it to trigger properly; unfortunately, I'm more of an artistically driven person so figuring this out through lua scripting is akin to me driving into a brick wall. I'll appreciate any and all help that you all can give.
http://www.grimrock.net/modding/scripti ... tComponent
Just use:

Code: Select all

beacon_air_1.socket:addItem(spawn("essence_air").item)
That worked perfectly, thanks for the help! I do have another question:

Code: Select all

function openNorthGates()
   if NorthGate.onInsertItem(NorthGate, "essence_balance_1") then
         north_gate1.door:open();
		 north_gate2.door:open();
   else
         north_gate1.door:close();
         north_gate2.door:close();
   end
end
For some reason, the field onInsertItem is returning a nil value, am I calling it wrong or is my mistake elsewhere?
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Ask a simple question, get a simple answer

Post by Grimfan »

To show that I have been learning something about lua along the way. If NorthGate is your beacon then:

Code: Select all

function openNorthGate()
       if NorthGate.socket:getItem() then
         northgate1.door:open()
         northgate2.door:open()
         end
      end
Sockets normally only take a single item like a torch (they are not like altars and alcoves). Each of the beacons only accepts a single essence as far as I know.

As always I defer to people like minmay, Thorham, Prozail or Isaac. In other words people who know what they're talking about. ;)
Davenfal
Posts: 5
Joined: Mon Dec 22, 2014 4:58 am

Re: Ask a simple question, get a simple answer

Post by Davenfal »

Grimfan wrote:To show that I have been learning something about lua along the way. If NorthGate is your beacon then:

Code: Select all

function openNorthGate()
       if NorthGate.socket:getItem() then
         northgate1.door:open()
         northgate2.door:open()
         end
      end
Sockets normally only take a single item like a torch (they are not like altars and alcoves). Each of the beacons only accepts a single essence as far as I know.

As always I defer to people like minmay, Thorham, Prozail or Isaac. In other words people who know what they're talking about. ;)
While this does work, it'll also accept any other essence placed onto it, which is unfortunate since I want each essence to only open up certain doors. I feel like onInsertItem should work but it doesn't want to. :|
Post Reply