Page 212 of 400

Re: Ask a simple question, get a simple answer

Posted: Tue Sep 12, 2017 11:06 pm
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

Re: Ask a simple question, get a simple answer

Posted: Thu Sep 14, 2017 6:52 pm
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:

Re: Ask a simple question, get a simple answer

Posted: Thu Sep 14, 2017 7:07 pm
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

Re: Ask a simple question, get a simple answer

Posted: Thu Sep 14, 2017 7:48 pm
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! :)

Re: Ask a simple question, get a simple answer

Posted: Thu Sep 14, 2017 9:57 pm
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.

Re: Ask a simple question, get a simple answer

Posted: Fri Sep 15, 2017 2:23 pm
by kelly1111
Simple question: When you hudprint a text ingame. Is there a way to change the text color (instead of the normal white) ?

Re: Ask a simple question, get a simple answer

Posted: Fri Sep 15, 2017 2:26 pm
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.

Re: Ask a simple question, get a simple answer

Posted: Sat Sep 16, 2017 9:04 pm
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?

Re: Ask a simple question, get a simple answer

Posted: Sat Sep 16, 2017 10:22 pm
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).

Re: Ask a simple question, get a simple answer

Posted: Sat Sep 16, 2017 10:25 pm
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.