[Solved] Save game blowing up with my custom dungeon

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
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

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

Post 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...
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
Prozail
Posts: 158
Joined: Mon Oct 27, 2014 3:36 pm

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

Post 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.. ;)
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

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

Post 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 :)
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

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

Post 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
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

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

Post 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
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

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

Post 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.
User avatar
Prozail
Posts: 158
Joined: Mon Oct 27, 2014 3:36 pm

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

Post 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

User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

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

Post by cromcrom »

OMG I am right in the thickness of it :-( :-( :-(
A trip of a thousand leagues starts with a step.
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

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

Post 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.
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

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

Post 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.
Post Reply