General scripting issues and questions

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: General scripting issues and questions

Post by Montis »

Thanks.


Another question:

I tried to set a global variable and then using it in a scripting hook.
Basically what I did was

Code: Select all

onMove = function(self, dir)
       print(myvariable)
   end
but it always prints out "nil". What am I doing wrong?
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: General scripting issues and questions

Post by petri »

There are no global variables. We are considering adding variable setters/getters to the public interface of script entities.
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: General scripting issues and questions

Post by cromcrom »

Oh yes please.
A trip of a thousand leagues starts with a step.
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: General scripting issues and questions

Post by Montis »

Thanks for the answer.

Another question:
I want to emulate the random rumbles and screen shakes from the main game but at a specific point (after a trigger). I tried the following but the earthquake sound doesn't stop and loops forevermore.

Code: Select all

function rumblealot()
	party:shakeCamera(1, 10)
	playSound("earthquake")
	end
I tried cloning the sound object(?) and setting the loop to false but that didn't work. I also tried only having the sound play at a specific location (playSoundAt()) but then it gave an error about "trying to play non-mono sound at location".
Any ideas besides importing a custom sound?


And still another question:
Is it possible to manipulate the map (and with that I mean the automap) per script? E.g make areas unexplored again or some such?
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: General scripting issues and questions

Post by Montis »

Montis wrote:I want to emulate the random rumbles and screen shakes from the main game but at a specific point (after a trigger). I tried the following but the earthquake sound doesn't stop and loops forevermore.

[omitted code]

I tried cloning the sound object(?) and setting the loop to false but that didn't work. I also tried only having the sound play at a specific location (playSoundAt()) but then it gave an error about "trying to play non-mono sound at location".
Any ideas besides importing a custom sound?
ok I could make it work with

Code: Select all

defineSound{
	name = "rumble",
	filename = "assets/samples/env/earthquake_01.wav",
	volume = 0.5,
	minDistance = 2,
	maxDistance = 5,
	loop = false,
}
but the sound cuts off apruptly at the end. :( sucks a bit.
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

Re: General scripting issues and questions

Post by Lmaoboat »

I have a puzzle where you have to zap a trap mechanism to cause the traps in a nearby room to turn on the enemy. Since there's nothing to check for the state of a receptor, I have it teleport something into a pressure plate named "security" in a sealed room and check for the state of that plate. I don't get any errors from the script, and the pressure plate is being triggered, but when it's pressed, I don't even get the "successes" message in the console.

Code: Select all

if security:isDown() then
	trap1:setTriggeredByParty(disable)
	trap1:setTriggeredByMonster(enable)
	print("success")
end
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: General scripting issues and questions

Post by Komag »

I think you could forgo the rock on pressure plate trick and just have the receptor connect directly to the script with a "zaptrigger" function:

maybe this script will work:

Code: Select all

function zaptrigger()
    trap1:setTriggeredByParty(disable)
    trap1:setTriggeredByMonster(enable)
    print("success")
end
Finished Dungeons - complete mods to play
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

Re: General scripting issues and questions

Post by Lmaoboat »

How do I go about connecting the receptor to the script?
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: General scripting issues and questions

Post by Komag »

After you make the script, you just select the receptor and do a normal "Add Connector" and select the script item. The "Action" should automatically say "zaptrigger" (or whatever you want to name it in the script)
Finished Dungeons - complete mods to play
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

Re: General scripting issues and questions

Post by Lmaoboat »

Oh wow, didn't know it worked like that. This is going to make things much easier.
Post Reply