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!
For Lua, I skip between Notepad++ and Sublime Text here. I don't know if I would go as far to call them "IDEs" but they are good text editors with syntax highlighting. I'm not a big fan of Eclipse, so unless I work on something that turns out to be massive in terms of scripting, I think the text editors will do for me!
Glad the above helped though, and that you were able to fix it quickly . With this in mind, I have noticed a few scripts kicking around the forums that might have this bug in...
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
JohnWordsworth wrote:For Lua, I skip between Notepad++ and Sublime Text here. I don't know if I would go as far to call them "IDEs" but they are good text editors with syntax highlighting. I'm not a big fan of Eclipse, so unless I work on something that turns out to be massive in terms of scripting, I think the text editors will do for me!
Grimrock 1 & 2, more than 100k lines of code, have both been written using Sublime Text 2/3. It's a great text editor although I wish plugins could be written in Lua instead of Python
petri wrote:Grimrock 1 & 2, more than 100k lines of code, have both been written using Sublime Text 2/3. It's a great text editor although I wish plugins could be written in Lua instead of Python
The plug-ins are not in LUA because Python arrays correctly initialize at 0. /jesting
Notepad++ here, but Sublime text sure looks cool, have to try it (haven't even heard of it before). Eclipse...never again I have used Netbeans and IntelliJ IDEA for larger projects lately, when I need automatic code completion etc... Not for lua of course
You can use for example counters in scripts. The following code WILL work if put in a script_entity, and keep the state of the counter between save/load.
Edit: I see now i was stating the obvious, as it is all explained here already.
num = 0
bad = 2
while bad > 0 do
num = num + 1
obj = findEntity("dungeon_wall_lantern_" .. num)
if obj ~= nil then
val = obj:getWorldPosition()
val[2] = val[2] + .7
ix = (3 - (obj.facing % 2) * 2)
dx, dy = getForward(obj.facing)
val[ix] = val[ix] + .21 * (dx - dy)
obj:setWorldPosition(val)
else
bad = bad - 1
end
end
I have found hunting down root cause of the save fails has been the hardest thing in modding Grimrock 2. The error you get tells you nothing. The problem can be almost anywhere and it is often VERY hard to see. If you have a lot of code, what I have done to find it is comment out code until you find it. The error will only occur if the erroneous code executes.
What causes the problem I believe is multiple similar issues. The main one is when a game object is stored in file scope and not locally. You can create as many basic LUA objects as you want in file scope but you have to ensure none contain game objects or the save will fail.
In the code below, you didn't share all of it. I don't see where/if you declared "obj" as local. findEntity() returns a GameObject so obj MUST be local or the save will fail.