Scripting cheat sheet

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Scripting cheat sheet

Post by JKos »

Hi,

I made a cheat sheet for LoG scripting:
https://sites.google.com/site/jkosgrimr ... heat-sheet

I think it could be useful to someone else too.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Scripting cheat sheet

Post by msyblade »

This is super useful JKos. I'm constantly using references for specific syntax or commands. This is perfect!
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: Scripting cheat sheet

Post by Diarmuid »

Very useful indeed! Thanks, this will save us a lot of time.
User avatar
Kuningas
Posts: 268
Joined: Wed Apr 11, 2012 10:29 pm
Location: Northern Finland

Re: Scripting cheat sheet

Post by Kuningas »

Fantastic! Saves a lot of time for me.

Thank you.
BASILEUS
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Scripting cheat sheet

Post by Komag »

yes! very concise and complete, love it! :D
Finished Dungeons - complete mods to play
User avatar
Nickydude
Posts: 44
Joined: Sun Oct 28, 2012 1:34 am
Location: UK

Re: Scripting cheat sheet

Post by Nickydude »

Thanks/ :)
"Hey look! A dungeons and Dragons ride...!"
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: Scripting cheat sheet

Post by Grimwold »

An excellent resource. Thanks for sharing!
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: Scripting cheat sheet

Post by Xanathar »

Fantastic! Will definitely use it!
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com

The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563

My preciousss: http://www.moonsharp.org
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: Scripting cheat sheet

Post by JKos »

Thanks for the great response. I got an idea for another cheat sheet: It would be nice to have a lua syntax/tips/warnings cheat sheet for LoG specific lua scripting because like we all know the lua support is a bit limited and there is also some restrictions. But because it's much more work than just copy pasting functions from documentation I was thinking that maybe we could make it together, just write your (short) lua tips/tricks here and I will make a another cheat sheet of them.

I can start of course so you get the idea.

STRINGS

Code: Select all

"a".."b" == "ab"
"a"..0 == "a0"

Code: Select all

multiLineString = [[
Hello
Grimrock!
]]
multiLineString = "Hello\nGrimrock!"

TABLES

Code: Select all

table1 = {'a','b','c'}
table1[1] == "a"
table2 = {key1='value1'}
table2.key1 == 'value1'
SCRIPT ENTITIES

Code: Select all

property = "a"
function getProperty()
	return property
end
function setProperty(value)
	property = value
end

entity_id.getProperty() == "a"
entity_id.setProperty('c') (ok)

entity_id:getProperty() == "c"
entity_id:setProperty('c') (error)

OBJECT ORIENTED

Code: Select all

local obj = {}
obj.property = "a"
obj.method = function(self) 
		return self.property 
	end
obj:method() == "a"
obj:method() == obj.method(obj)
obj.method() (error)

Code: Select all

-- magic self 
local obj2 = {}
obj2.property = 'b'
function obj2:method()
	return self.property
end
obj:method() == 'b'
obj.method() (error)
WARNINGS (works in editor but not in the game)

Storing entities to "global" variables

Code: Select all

variable = snail_1 (serialization error on save game)
variable = snail_1.id (ok)
local variable = snail_1 (ok)
Undefined "global" variables

Code: Select all

function breakTheGame()
	undefinedGlobal = 'crash'
end
Upvalues

Code: Select all

myMethods = {}
function breakTheGame()
	local upvalue = "causes serialization error"
	myMethods.useExternalLocalVariable = function() 
		print(upvalue) 
	end
end
breakTheGame()
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Scripting cheat sheet

Post by Komag »

Holy heck this is extremely valuable. I'm only just starting to get a grasp on most of this stuff, so thank you!
Finished Dungeons - complete mods to play
Post Reply