temporarilty immobilize the party

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
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

temporarilty immobilize the party

Post by FeMaiden »

is there a way to do this? like if I want the party to enter an area and then they step on a floor trigger and it immobilizes them until a vilain makes an appearance, then i can make dialogue appear where the vaillain speaks to the party, then the villain disappears and the party can move freely again.

I know i can just use a force field for this but I don't want to have any visual effect.
the force field is invisible if I turn off all the boxes in it's componnets. if the force field is active in it's initial state, it's invisible but if I make it deactive and then have the party trigger it to activate on top of them, the visual effect reappears.

I can't use invisible walls because they can't be deactivated.

is there some command I can use like party.party:disableMovement() or something to that effect?
User avatar
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

Re: temporarilty immobilize the party

Post by FeMaiden »

I did have one idea...a rather odd solution is to have a staging area on a dummy map, that looks just like the regular map, and then in the spot where i trigger this event, i activate an invisible teleporter that then brings the party to the "fake" map and the player does not realize they were teleported but then finds them self surrounded by invisible walls.
then use delayed calls for all the dialogue and then at the end of the "cut-scene" i activate a second teleporter to bring the party back to their original position then deactivate the first telporter, so the party can continue with the quest.

I dunno, this seems like a sloppy way to do it.
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: temporarilty immobilize the party

Post by Drakkan »

several possibilities on my mind. Probably more, but ...
The most easy is to set party move component to false (check party components) OR you finally start use John Log framework where is freeze world functionality together with tons of other stuff OR you can just spawn some invisible blockers around the party / remove them when required OR you can use some kind of invisible teleporters to keep party locked OR you can use the trick of yours (which I do not like).
Breath from the unpromising waters.
Eye of the Atlantis
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: temporarilty immobilize the party

Post by minmay »

Return false from the PartyComponent.onMove() hook.
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
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

Re: temporarilty immobilize the party

Post by FeMaiden »

so i would have a floor trigger, trigger the script and the first thing in my script would be to set the party move component to false and then i do all the other things i want to do and then at the end set the party move component to true again?
the thing with invisible blockers, they only block monsters, not the party.

@minmay, I still don't quite get what you mean when you keep saying "hook".
you keep saying "Change this hook" or "change that hook"
what is a "hook"?
is a hook the same as a component? is it a connector?
what's the command? like

Code: Select all

party.party:onMove(false)

I'm sorry I'm asking you to just tell me what i need to type.
because I can't find this in the scripting refenence.
the only thing in there related to moveComponents are all monster moveComponents
Last edited by FeMaiden on Mon Nov 02, 2015 6:05 am, edited 1 time in total.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: temporarilty immobilize the party

Post by minmay »

a hook is a function that's called upon some action being performed
the party component's onMove() hook is called whenever the party attempts to move
if it returns false, the party won't move
otherwise, the party will move

It is in the scripting reference, under PartyComponent like I told you. And you can read about the syntax of Lua here: http://www.lua.org/manual/5.1/manual.html

You could also call GameMode.setGameFlags("DisableMovement",true) to disable all movement, and GameMode.setGameFlags("DisableMovement",false) to allow it again, depending on your needs.
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
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

Re: temporarilty immobilize the party

Post by FeMaiden »

minmay wrote:a hook is a function that's called upon some action being performed
the party component's onMove() hook is called whenever the party attempts to move
if it returns false, the party won't move
otherwise, the party will move

It is in the scripting reference, under PartyComponent like I told you. And you can read about the syntax of Lua here: http://www.lua.org/manual/5.1/manual.html
okay, I guess the syntax is probably why i'm having such trouble with this. I never learned the syntax and i'm just guessing at it from the context of the scripts you guys post
User avatar
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

Re: temporarilty immobilize the party

Post by FeMaiden »

minmay wrote:a hook is a function that's called upon some action being performed
the party component's onMove() hook is called whenever the party attempts to move
if it returns false, the party won't move
otherwise, the party will move

It is in the scripting reference, under PartyComponent like I told you. And you can read about the syntax of Lua here: http://www.lua.org/manual/5.1/manual.html

You could also call GameMode.setGameFlags("DisableMovement",true) to disable all movement, and GameMode.setGameFlags("DisableMovement",false) to allow it again, depending on your needs.

I tried

Code: Select all

function immobilize()
	GameMode.setGameFlags("DisableMovement",true)
end
and i get "attempt to call field 'setGameFlags' (a nil value) x"


I also tried

Code: Select all

function immobilize()
	party.partyComponent:onMove(false)
end

and that returned "attempt to call field 'onMove' (a nil value) x"


I know you say "it's in the manual" but that manual is large, how would I know what section to look for any given answer?
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: temporarilty immobilize the party

Post by minmay »

FeMaiden wrote:I tried

Code: Select all

function immobilize()
	GameMode.setGameFlags("DisableMovement",true)
end
and i get "attempt to call field 'setGameFlags' (a nil value) x"
Oops, there's a typo on the wiki. The function is just named "setGameFlag" with no s.
FeMaiden wrote:I also tried

Code: Select all

function immobilize()
	party.partyComponent:onMove(false)
end

and that returned "attempt to call field 'onMove' (a nil value) x"
You are on the Web. If you don't understand my last post you can search the Web for what "function", "return", etc. mean in the context of programming languages. There is a publicly available scripting reference and asset pack, which together give you all the information you need about component hooks. There is no reason to try to guess these things at random, like you're doing here. All that does is waste your time.
Component hook functions go in the component definition, like this:

Code: Select all

{
  class = "Party",
  onMove = function(self, direction)
    return false
  end,
}
FeMaiden wrote:I know you say "it's in the manual" but that manual is large, how would I know what section to look for any given answer?
Most Web browsers have a built-in search function. You can press ctrl+F and type in whatever you want to find. In this case, you could search for "syntax". The section you're most interested is probably section 2, "The Language".
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
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

Re: temporarilty immobilize the party

Post by FeMaiden »

but if I change the onmove to false in the party definitions, then isnt that going to permanently disable their movements?


what i wanted to do was have the party move into a room and then they suddenly cant move and then the villain comes in and says something, then disappears, then the party can move again.


I know what a function is.

that lua page explaining the syntax, it's using symbols i've never seen in any of these scripts like

Code: Select all

 
var ::= Name

and

Square brackets are used to index a table:

Code: Select all

	var ::= prefixexp `[´ exp `]´




what are those 2 colons followed by an equal sign? I never saw any of you guys use that in the scripts.


and when I googled "what is a lua hook"

all I get are things saying that it's a debug command and its saying stuff like

"The hook mechanism of the debug library allows us to register a function that will be called at specific events as your program runs. There are four kinds of events that can trigger a hook: call events happen every time Lua calls a function; return events happen every time a function returns; line events happen when Lua starts executing a new line of code; and count events happen after a given number of instructions. Lua calls hooks with a single argument, a string describing the event that generated the call: "call", "return", "line", or "count". Moreover, for line events, it also passes a second argument, the new line number. We can always use debug.getinfo to get more information inside a hook."



I didn't know I was gonna need a degree in computer sciences to do this stuff
Post Reply