Page 2 of 4

Re: [Solved] Save game blowing up with my custom dungeon

Posted: Tue Nov 04, 2014 9:23 pm
by JohnWordsworth
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...

Re: [Solved] Save game blowing up with my custom dungeon

Posted: Tue Nov 04, 2014 9:35 pm
by Prozail
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!
What he said.. ;)

Re: [Solved] Save game blowing up with my custom dungeon

Posted: Tue Nov 04, 2014 9:55 pm
by petri
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 :)

Re: [Solved] Save game blowing up with my custom dungeon

Posted: Tue Nov 04, 2014 11:01 pm
by NutJob
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

Re: [Solved] Save game blowing up with my custom dungeon

Posted: Tue Nov 04, 2014 11:14 pm
by JKos
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

Re: [Solved] Save game blowing up with my custom dungeon

Posted: Tue Nov 04, 2014 11:26 pm
by NutJob
So happy! I found my one Lone Hostile line of code killing my mod!

Code: Select all

function puzzleL1Room6(o)
	local str = string.sub(o.go.id, -1)
	obj = findEntity("someEntity_" .. str)
	--[[ code omitted ]]--
end
There, on display for others to not make the same mistake.

Re: [Solved] Save game blowing up with my custom dungeon

Posted: Wed Nov 05, 2014 1:25 pm
by Prozail
Just for clarification.

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.

Code: Select all


counter=0

function btn()
	counter= counter +1
	hudPrint("The counter says "..counter)
end


Re: [Solved] Save game blowing up with my custom dungeon

Posted: Mon Nov 10, 2014 9:25 pm
by cromcrom
OMG I am right in the thickness of it :-( :-( :-(

Re: [Solved] Save game blowing up with my custom dungeon

Posted: Fri Dec 19, 2014 11:16 am
by Soaponarope
I'm having this problem with my dungeon and I just found the cause. It was a nice script I found from Lark to fix the wall lanterns.

Code: Select all

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 don't know how to fix the saving fail though.

Re: [Solved] Save game blowing up with my custom dungeon

Posted: Fri Dec 19, 2014 3:28 pm
by MrChoke
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.