LUA clueless, need help.

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!
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: LUA clueless, need help.

Post by Azel »

Well then I very much expect there to be a House Wife and Chauffeur NPC in your Mod. MAKE IT HAPPEN :P
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: LUA clueless, need help.

Post by minmay »

utopia570 wrote:Ok so for now, my only other question would be, is it possible to edit someone else's dungeon? I have 0 intention of reuploading a modified dungeon or "ruining" someone else's work. I simply want to alter a dungeon to my play style. It would be just an offline change for my own purposes. Thank you.
Some modders distribute their source files so that you can edit their dungeons. If the dungeon does not have source files released then you would need to extract the .dat file with a tool like offzip and match up the resulting hashed filenames to their original filenames. I do not recommend this.
However there are a lot of changes you can make simply by using the debug console (enable with "console = true" in your grimrock.cfg and press the consoleKey ingame to open, '\' by default.) which is simply a Lua console; see the scripting reference for what you can do with it. For example, to make secret buttons more noticeable, you can run this line to draw white boxes around all ClickableComponents on objects with ButtonComponents:

Code: Select all

for l = 1,Dungeon.getMaxLevels() do for e in Dungeon.getMap(l):allEntities() do local clickables = {} local button = false for _,c in e:componentIterator() do if c.getFrontFacing then table.insert(clickables,c) elseif c.getDisableSelf and c.getSound and not (c.isActivated) then button = true end end if button then for _,c in ipairs(clickables) do c:setDebugDraw(true) end end end end
Or in 2.4.4, you can give the party Toorum movement speed (turning speed is still stuck at 1.0 though) with this line:

Code: Select all

party.party:setMovementSpeed(1.5)
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.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: LUA clueless, need help.

Post by Isaac »

utopia570 wrote:Ok so for now, my only other question would be, is it possible to edit someone else's dungeon? I have 0 intention of reuploading a modified dungeon or "ruining" someone else's work. I simply want to alter a dungeon to my play style. It would be just an offline change for my own purposes. Thank you.
Any modding of a user dungeon that is not offered as an editor project, will [usually] be done in-game through the Lua console, using Lua script commands.

If the idea is to remove spiders ~for instance, it's possible in theory (to swap them for another monster), but in practice, some of them are spawned via scripts, and it's not as simple as replacing all monsters of a given type with another. Basic console commands can add equipment, open doors, kill monsters, and even move the party around, but in a complex scripted mod, it's sometimes possible to cause problems in it by changing things (unexpectedly); use with caution.
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: LUA clueless, need help.

Post by petri »

minmay wrote:

Code: Select all

for l = 1,Dungeon.getMaxLevels() do for e in Dungeon.getMap(l):allEntities() do local clickables = {} local button = false for _,c in e:componentIterator() do if c.getFrontFacing then table.insert(clickables,c) elseif c.getDisableSelf and c.getSound and not (c.isActivated) then button = true end end if button then for _,c in ipairs(clickables) do c:setDebugDraw(true) end end end end
btw. Component:getClass() was added in 2.2.4.
Post Reply