Events
Events
Are there any global events that can trigger scripts? The one I'm looking for is something to run a script when the players loads a game. Such as onLoad, OnEnter, onPlayerStart or anything that represents the game is fully loaded that can trigger a script to initialize other scripts, spawn items, set effects, etc.
OR
Must I set all my scripts to an object? Which is fine, can simply set an invisible object (floor_trigger) but I would have to set them down everywhere over every square inch because people will not one-shoot dungeons without any saving or loading.
Am I missing something obviously critical/simplistic? I'm very used to having events run the program or loops or polling but can not figure it out in this editor.
OR
Must I set all my scripts to an object? Which is fine, can simply set an invisible object (floor_trigger) but I would have to set them down everywhere over every square inch because people will not one-shoot dungeons without any saving or loading.
Am I missing something obviously critical/simplistic? I'm very used to having events run the program or loops or polling but can not figure it out in this editor.
- Skuggasveinn
- Posts: 562
- Joined: Wed Sep 26, 2012 5:28 pm
Re: Events
you can have a script entity that doesn't use a function that needs to be called
like placing a command inside a script but outside a function will run it when the dungeon starts
So you should be able to just spawn items and effects directly that way without the need to trigger them
but placing it within a function means that you need to call it with a trigger
Hope that helps.
Skuggasveinn.
like placing a command inside a script but outside a function will run it when the dungeon starts
Code: Select all
Spawn("rock",1,16,20,0,2)but placing it within a function means that you need to call it with a trigger
Code: Select all
function spawnrock()
Spawn("rock",1,16,20,0,2)
endSkuggasveinn.
- Chimera005ao
- Posts: 187
- Joined: Sun Jun 29, 2014 8:34 am
Re: Events
Mind running through the parameters there?Spawn("rock",1,16,20,0,2)
First designates it will be a rock, easy enough.
I'm going to assume three of them that are next to each other will be the map coordinate, to tell what map to spawn it in.
Then two of the others are the x, y coordinate within that map?
But then there could also be height, and I remember one in the first Grimrock was facing direciton... : /
- Chimera005ao
- Posts: 187
- Joined: Sun Jun 29, 2014 8:34 am
Re: Events
Ok, messing around with it a bit.
The first number seems to be the map, though I'm not sure how that works.
Numbers 2 and 3 indicate the x, y cordinates of the floor.
Number 4 is the facing direction.
Number 5 is the height it seems.
The first number seems to be the map, though I'm not sure how that works.
Numbers 2 and 3 indicate the x, y cordinates of the floor.
Number 4 is the facing direction.
Number 5 is the height it seems.
Re: Events
Appreciate the answer Skuggasveinn. I'll assume whatever script_entity I set on a level runs only when a player enters that level or do all the script_entities trigger on first load?
Ex 1. (assuming correct)
Party loads into the game on LevelB
LevelA [0,0,0] lua does nothing
LevelB [0,0,1] lua executes
LevelC [0,0,2] lua does nothing
--
Ex 2. (potentially what is happening; suppose I should just test =] )
Party loads into the game on LevelC
LevelA [0,0,0] lua executes
LevelB [0,0,1] lua executes
LevelC [0,0,2] lua executes
--
Ex 3. (what I was expecting being I came from a heavy event-run environment)
Party loads into the game on LevelA
onLoad init() run
LevelA [0,0,0] lua executes
LevelB [0,0,1] lua does nothing
LevelC [0,0,2] lua does nothing
--
Anyways I'll get a hold how it's done or figure out a way. I just wanted to get my bearings before starting a project.
Ex 1. (assuming correct)
Party loads into the game on LevelB
LevelA [0,0,0] lua does nothing
LevelB [0,0,1] lua executes
LevelC [0,0,2] lua does nothing
--
Ex 2. (potentially what is happening; suppose I should just test =] )
Party loads into the game on LevelC
LevelA [0,0,0] lua executes
LevelB [0,0,1] lua executes
LevelC [0,0,2] lua executes
--
Ex 3. (what I was expecting being I came from a heavy event-run environment)
Party loads into the game on LevelA
onLoad init() run
LevelA [0,0,0] lua executes
LevelB [0,0,1] lua does nothing
LevelC [0,0,2] lua does nothing
--
Anyways I'll get a hold how it's done or figure out a way. I just wanted to get my bearings before starting a project.
- SnowyOwl47
- Posts: 148
- Joined: Fri Sep 12, 2014 10:41 pm
Re: Events
I'll check to see if there is a way to do that you never know we ourselves the master coders xD don't know everything.NutJob wrote:Appreciate the answer Skuggasveinn. I'll assume whatever script_entity I set on a level runs only when a player enters that level or do all the script_entities trigger on first load?
Ex 1. (assuming correct)
Party loads into the game on LevelB
LevelA [0,0,0] lua does nothing
LevelB [0,0,1] lua executes
LevelC [0,0,2] lua does nothing
--
Ex 2. (potentially what is happening; suppose I should just test =] )
Party loads into the game on LevelC
LevelA [0,0,0] lua executes
LevelB [0,0,1] lua executes
LevelC [0,0,2] lua executes
--
Ex 3. (what I was expecting being I came from a heavy event-run environment)
Party loads into the game on LevelA
onLoad init() run
LevelA [0,0,0] lua executes
LevelB [0,0,1] lua does nothing
LevelC [0,0,2] lua does nothing
--
Anyways I'll get a hold how it's done or figure out a way. I just wanted to get my bearings before starting a project.
Re: Events
All the script entities are triggered when the game is started since the simulation runs on all the levels. If you want something to trigger when entering a level for the first time, one handy way to do it is to use a timer and enable its currentLevelOnly and disableSelf -parameters (but leave the timer component activated so the timer doesn't need to be started separately). Then when the player enters the level, the timer will start and its connectors will fire after the timer runs. A timerInterval of 0 seems to work for this purpose, but do remember the disableSelf! This will only work only for the first time though so if repeated use is needed, something more custom would need to be done.NutJob wrote:Appreciate the answer Skuggasveinn. I'll assume whatever script_entity I set on a level runs only when a player enters that level or do all the script_entities trigger on first load?
There's no way to detect when player loads the game as far as I know.
Steven Seagal of gaming industry
Re: Events
In Grimrock 1 you could detect reloads by creating an FX entity with an infinite lifetime and checking for its existence every so often, since reloads destroyed FX entities. Maybe there's something like that?
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Events
antti wrote:... one handy way to do it is to use a timer and enable its currentLevelOnly and disableSelf -parameters (but leave the timer component activated so the timer doesn't need to be started separately)...
Magnificent, and the information I sought.minmay wrote:...detect reloads by creating an FX entity with an infinite lifetime and checking for its existence every so often...
Great game and community.
Really looking forward to the Scripting Reference that's currently on the TODO list. What must I do, Buy a fourth bundle on Steam for a friend to get this going? /giving you a hard time =)
Re: Events
This appears to work like the first editor and is literally the order the levels descend (why there's a 'move up' and ' move down' when you right-click a level); under the Project Tab. Though the new way of assigning where the levels are placed [in the world] is much better in this editor.Chimera005ao wrote:Ok, messing around with it a bit.
The first number seems to be the map, though I'm not sure how that works.
The sixth variable is the "string_id"Numbers 2 and 3 indicate the x, y cordinates of the floor.
Number 4 is the facing direction.
Number 5 is the height it seems.
Ex. spawn("dungeon_pit",1,3,3,2,-7,"dungeon_pit_of_doooooom")