Ask a simple question, get a simple answer

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
Xardas
Posts: 83
Joined: Fri Jul 28, 2017 12:30 am

Re: Ask a simple question, get a simple answer

Post by Xardas »

The script was very helpful and it was easy to modify, so it spawns 3 different kind of Floors. It was exactly, what i needed.
thank you
In order to get to the other side of the pit you have to get hit by the fireball and die....
Yep.....moving on!
ColdDeadStone
Posts: 24
Joined: Sat Nov 26, 2016 12:12 pm

Re: Ask a simple question, get a simple answer

Post by ColdDeadStone »

Hello... i need some help with a local variable. I searched the Lua Tutorials but i don't find any answer. Thats maybe because there are not about Grimrock... Anyway, heres the problem:

This is working of course:

Code: Select all

function test()
local a = lever_1
a.lever:toggle()
end
As String it dont work but thats not what i want anyway:

Code: Select all

function test2()
local a = "lever_"
local b = "1" (tried a number with tostring() and a string with tonumber())
local c = a..b
c.lever:toggle()
end
This is what i need:

Code: Select all

function test3()
local a = lever_
local b = 1
local c = a..b
c.lever:toggle()
end
As string its possible to have "lever_1" as a result but you cant access ".lever" from string. So i need the real (don't know how to call it) thing.

I tried the stuff from the Lua Local Variable Tutorials but nothing worked. Im kinda out of ideas. Someone here to give me a hint? Please... :oops:
Sorry for my poor english... hope you understand what i try to say! :)
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Try this:

Code: Select all

function test3()
	local b = 1
	local c = findEntity("lever_"..b) --returns nil if nonexistent
	if c ~= nil then
		c.lever:toggle()
	end
end
** The official LoG2 script reference is good, but a bit out of date. There is an up-to-date reference on Github:

https://github.com/JKos/log2doc/wiki
ColdDeadStone
Posts: 24
Joined: Sat Nov 26, 2016 12:12 pm

Re: Ask a simple question, get a simple answer

Post by ColdDeadStone »

Isaac wrote:Try this:
Yes that is what i tried to achieve! Thanks for your help! About the reference (both), i use them but only for "what can i do with .particle:" or something... but are there any infos about variables on those sites? Hmm... But anyway: Thanks again! Its a nice helpful Community here! Thank you! :)
Sorry for my poor english... hope you understand what i try to say! :)
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

ColdDeadStone wrote:
Isaac wrote:Try this:
Yes that is what i tried to achieve! Thanks for your help! About the reference (both), i use them but only for "what can i do with .particle:" or something... but are there any infos about variables on those sites? Hmm... But anyway: Thanks again! Its a nice helpful Community here! Thank you! :)
Grimrock (afaik) uses a limited version of Lua 5.1

There is information on Lua here: https://www.lua.org/manual/5.1/
Most of it works, but Grimrock 1 & 2 do not support certain functions, and they do not have the conventional way to store global variables; though technically it is not impossible to have them. One limited method for LoG2 is seen in the water script of its asset pack, but those values don't get stored in the saved games, and need replaced at every reload; or they won't be there.

*If you don't have the asset pack, then you should, because with it you can read all of its scripts, and learn from them.
Assets for LoG2 http://www.grimrock.net/modding/grimrock-2-asset-pack/


Among the members here, minmay probably has the best grasp on the limits of the Grimrock Lua interpreters.
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

Simple question: When you hudprint a text ingame. Is there a way to change the text color (instead of the normal white) ?
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

kelly1111 wrote:Simple question: When you hudprint a text ingame. Is there a way to change the text color (instead of the normal white) ?
No! You can't do that with hudPrint.
User avatar
Xardas
Posts: 83
Joined: Fri Jul 28, 2017 12:30 am

Re: Ask a simple question, get a simple answer

Post by Xardas »

Hey guys,
i´m a bit confused about the castle tileset. The walls do overlap, when i have more than 1 Level. Even in a brand new Project i have this strange bug... Am i missing something here?
In order to get to the other side of the pit you have to get hit by the fireball and die....
Yep.....moving on!
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Xardas wrote:Hey guys,
i´m a bit confused about the castle tileset. The walls do overlap, when i have more than 1 Level. Even in a brand new Project i have this strange bug... Am i missing something here?
Levels in Grimrock have a module height; this is usually set to 3, but the castle levels have it set to 4; it is per-floor. The castle assets are built to that height. To change the module height on your castle levels, right-click on the map name in the project panel, and choose properties. There you can name your floors, set their position, in relation to other floors, set the module height, and choose what background audio track plays while on the map (if any).
User avatar
THOM
Posts: 1266
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

The castle tileset is a bit larger than the others.

You have to open the level properties by doing a right click on the level's name. Then change Module Height from 3 to 4.
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
Post Reply