Scripting Language

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!
Hermundure
Posts: 46
Joined: Wed Sep 26, 2012 5:44 pm

Scripting Language

Post by Hermundure »

Sorry for this dumb question guys, but:

Is the scripting language for Grimrock 2 Lua 5.1 or 5.2?

Do you know any resource for complete starters which can be used to learn this language and get a start-up?
Hermundure
Posts: 46
Joined: Wed Sep 26, 2012 5:44 pm

Re: Scripting Language

Post by Hermundure »

Thank you for this quick answer!

Two more questions just came up:

1.) what does this () mean behind some lines for example here: combination_lever_1.lever:isActivated() or here checkLevers() ?
and 2.) what purpose do these { have in the functions as I often see many of them just below each other for example here:

defineObject {
name = "door_of_closing",
baseObject = "dungeon_door_portcullis",
components = {
{
class = "Door"
}
}
}

Herm
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: Scripting Language

Post by Isaac »

Hermundure wrote:1.) what does this () mean behind some lines for example here: combination_lever_1.lever:isActivated() or here checkLevers() ?
and 2.) what purpose do these { have in the functions as I often see many of them just below each other for example here:
Parentheses ~in this context... indicate a function call, and parameters for that function can be included within those parentheses.

The "Curly Braces" normally indicate a collection of data; a table; array.

eg. myVar = {10,20,30,"goblins"} ; print(myVar[3], myVar[4]) ..... would print: 30 goblins
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Scripting Language

Post by NutJob »

The thing that caught me off guard are arrays start at 1. How silly (lua). At least starting at 1 is going very old-school. ~laughs~
Hermundure
Posts: 46
Joined: Wed Sep 26, 2012 5:44 pm

Re: Scripting Language

Post by Hermundure »

Thank you for the infos!

@NutJob
Sorry, I didnt get what you tried to tell me here, which arrays have to start with 1 and why? I am a bit puzzled oO
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Scripting Language

Post by Komag »

Not being a programmer, I've not yet understood why arrays often start with 0
Finished Dungeons - complete mods to play
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Scripting Language

Post by NutJob »

Then if you're ever extremely bored some day you'll have this to read.
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Scripting Language

Post by petri »

Komag wrote:Not being a programmer, I've not yet understood why arrays often start with 0
It's a relic from old programming languages like the C language. Of course all sensible languages like Lua start with 1. The 1st item of an array is logically at index 1 :)
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: Scripting Language

Post by Isaac »

petri wrote:
Komag wrote:Not being a programmer, I've not yet understood why arrays often start with 0
It's a relic from old programming languages like the C language. Of course all sensible languages like Lua start with 1. The 1st item of an array is logically at index 1 :)
I'm neutral... but... is it just me or doesn't it seem that starting from 1 has the stigma of VB all over it. :D

*(Coming from someone with VB6 still.)
Last edited by Isaac on Fri Oct 24, 2014 2:40 pm, edited 1 time in total.
Post Reply