[SOLVED] Animated bridge.. need help with an issue

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!
Post Reply
User avatar
vanblam
Posts: 243
Joined: Sun Nov 09, 2014 12:15 am

[SOLVED] Animated bridge.. need help with an issue

Post by vanblam »

The code below works just fine except one little problem. If you die and reload ( In game, not editor) the bridge is no longer extended. The bridge was built extended and I load an animation on initialize to retract it ( I only did this because the bridge kept disappearing on me :P ). I'm sure the problem lies in the "playOnInit", but I don't know what else to do there.

Image Image

Code: Select all

defineObject{
	name = "sg_stone_bridge_extend",
	baseObject = "base_wall_decoration",
	components = {
		{
			class = "Model",
			model = "mod_assets/models/env/sg_stone_bridge_extend.fbx",
			staticShadow = true,
		},
		{
			class = "Animation",
			animations = {
			extend = "mod_assets/animations/sg_stone_bridge_extend_activate.fbx",
			ready = "mod_assets/animations/sg_stone_bridge_extend_ready.fbx",
			},
			playOnInit = "ready",
			loop = false,
		},
		{
			class = "Controller",
			onOpen = function(self)
				self.go.animation:play("extend")
				playSound("floor_sliding_end")
				self.go.controller:disable()
			end,
		},
	},
	minimalSaveState = true,
	editorIcon = 92,
	tags = { "shadowgate", "dungeon extras" },
}
Last edited by vanblam on Sun Jan 31, 2016 4:59 am, edited 1 time in total.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Animated bridge.. need help with an issue

Post by minmay »

The problem is that you gave an object the minimalSaveState property, without knowing what that property does.
When you reload the game, minimalSaveState objects are effectively respawned, as by a spawn() call. The ONLY state information preserved for minimalSaveState objects is: name, id, level, x, y, facing, elevation. You can remember this because those are the 7 parameters for spawn(). If you change any other property of the object, that change will be completely erased when the game is loaded.
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
vanblam
Posts: 243
Joined: Sun Nov 09, 2014 12:15 am

Re: Animated bridge.. need help with an issue

Post by vanblam »

minmay wrote:The problem is that you gave an object the minimalSaveState property, without knowing what that property does.
When you reload the game, minimalSaveState objects are effectively respawned, as by a spawn() call. The ONLY state information preserved for minimalSaveState objects is: name, id, level, x, y, facing, elevation. You can remember this because those are the 7 parameters for spawn(). If you change any other property of the object, that change will be completely erased when the game is loaded.
That did the trick.. Yea when comes to code of any kind I'm dumber then a bag of hammers :P. I usually stick to visuals haha.
Thanks for the quick reply :)
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: [SOLVED] Animated bridge.. need help with an issue

Post by minmay »

Eh, you're not even close to being the first person to make this mistake =P
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.
Post Reply