~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(Easy Scripting Updated!

Post by SnowyOwl47 »

mpuppetier wrote:I guys, how can i kill a monster??
i had tried

Code: Select all

function killWizard()
   wizard_1.monster:destroy();
end
also tried the methods
kill() and dieBastard() :D
and setHeath(0) ...
but the wizard still looking at me :D
I think dieBastard should work :lol:

Lol ok to destroy an object you say:

As an example I created three tree cluster items in my dungeon through script when a boss starts then when the boss died I destroyed them:

Code: Select all

Entity:destory
Make sure to replace entity with the name of whatever you want to kill/destroy.

Edit: you can also say

Code: Select all

entity.monster:setHealth(0)
Edit: Another thing you can do to damage it a little is:

Code: Select all

function hurt()
    health = entity.monster:getHealth() - 1
    entity.monster:setHealth(health)
end
That should work and is a cool thing.
mpuppetier
Posts: 16
Joined: Tue Sep 02, 2014 11:20 am

Re: ~Basic Scripting and Editor Help(Easy Scripting Updated!

Post by mpuppetier »

SnowyOwl47:
setHealth works but doesn't kill the monster .
destroy
doesn't trigger onDie

This works :

Code: Select all

die = false;
function killWizard()
	if die == false then
		wizard.monster:die();
		die = true;
	end
end
User avatar
zeltak
Posts: 119
Joined: Fri May 04, 2012 2:33 am

Re: ~Basic Scripting and Editor Help(Easy Scripting Updated!

Post by zeltak »

Is there a way to reset the preview mode? Or to change the time of day in the preview mode?
[SMUG]Ipecac
Posts: 28
Joined: Tue Oct 21, 2014 5:51 am

Re: ~Basic Scripting and Editor Help(Easy Scripting Updated!

Post by [SMUG]Ipecac »

Hey can someone tell my how to require a specific object in an alcove or altar for the triggering effect? So far it only work with "add object" which can just be a rock.

I found some old script from loGR but it doesn't work.

function itemPuzzle()
-- iterate through all contained items on alcove, checking for a matching name
for i in itemPuzzleAlcove:containedItems() do
if i.name == "pitroot_bread" then
playSound("level_up")
break
end
end
end

containedItems() is a null value at the very least
Anyone?
User avatar
zeltak
Posts: 119
Joined: Fri May 04, 2012 2:33 am

Re: ~Basic Scripting and Editor Help(Easy Scripting Updated!

Post by zeltak »

I'll post my question here, so not to flood forum with every single simple question in its own thread.

How do I activate and deactivate teleporters from the script?
I tried:

Code: Select all

teleporter_name.teleporter:activate()
teleporter_name.teleporter:deactivate()
but it returns with "attempt to call method 'activate' (a nil value) x"
User avatar
Lark
Posts: 178
Joined: Wed Sep 19, 2012 4:23 pm
Location: Springfield, MO USA

Re: ~Basic Scripting and Editor Help(Easy Scripting Updated!

Post by Lark »

Use "enable" and "disable""

Code: Select all

function flyAway()
  teleporter_1.teleporter:enable()
  end
User avatar
zeltak
Posts: 119
Joined: Fri May 04, 2012 2:33 am

Re: ~Basic Scripting and Editor Help(Easy Scripting Updated!

Post by zeltak »

Lark wrote:Use "enable" and "disable""

Code: Select all

function flyAway()
  teleporter_1.teleporter:enable()
  end
Thank you.
User avatar
zeltak
Posts: 119
Joined: Fri May 04, 2012 2:33 am

Re: ~Basic Scripting and Editor Help(Easy Scripting Updated!

Post by zeltak »

Hmm..
teleporter_1.teleporter:enable() ..:disable(), enables and disables only the teleporter part of the whole thing. Particles, lights, sounds etc. are unaffected. How do I shut down and start up the whole thing? I tried leaving the .teleporter -part away from the script, but then it again doesn't understand enable() & disable().
User avatar
Lark
Posts: 178
Joined: Wed Sep 19, 2012 4:23 pm
Location: Springfield, MO USA

Re: ~Basic Scripting and Editor Help(Easy Scripting Updated!

Post by Lark »

Well, in that case, I think I would try spawning the teleporter only when it was desired, and destroy it when I no longer wanted it. I'll check for other options later tonight...
User avatar
sps999
Posts: 44
Joined: Sun Oct 26, 2014 11:16 pm

Re: ~Basic Scripting and Editor Help(Easy Scripting Updated!

Post by sps999 »

[SMUG]Ipecac wrote:Hey can someone tell my how to require a specific object in an alcove or altar for the triggering effect? So far it only work with "add object" which can just be a rock.

I found some old script from loGR but it doesn't work.

function itemPuzzle()
-- iterate through all contained items on alcove, checking for a matching name
for i in itemPuzzleAlcove:containedItems() do
if i.name == "pitroot_bread" then
playSound("level_up")
break
end
end
end

containedItems() is a null value at the very least
Anyone?
This thread was able to help me with the same problem, you should read through it:

viewtopic.php?f=22&t=7698&hilit=rock
Post Reply