Page 1 of 1

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

Posted: Sun Jan 31, 2016 2:40 am
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" },
}

Re: Animated bridge.. need help with an issue

Posted: Sun Jan 31, 2016 4:08 am
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.

Re: Animated bridge.. need help with an issue

Posted: Sun Jan 31, 2016 4:54 am
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 :)

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

Posted: Sun Jan 31, 2016 5:20 am
by minmay
Eh, you're not even close to being the first person to make this mistake =P