Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by dkollmann

I have an object with some properties that I modify internally in the code while editing. Those values are not saved when I save the map. I already set the map as modified.

I was wondering how to tell Weltmeister that a certain property of an object needs to be saved even when it is not added to the property panel.

1 decade ago by dkollmann

With object I of course mean the entity I am editing.

1 decade ago by stahlmanDesign

I'm not sure what you mean exactly, but could it be that you are adding properties to your entity code in the javascript file, and you want that to show up in Weltmeister? If so, maybe you need to refresh WM or restart the browser.

For example, I altered the entity offset value so the graphic would be outside the collision area, but it would not take effect until I restarted WM. It was just a cache problem.

1 decade ago by dkollmann

Sorry but you got me wrong.

My entity has properties that I change in the code while editing the level. It seems that because these properties are not in the property panel (as the code changes them not the level designer) they are not saved although they do not contain the default values.

It is a purely technical issue. But thanks for taking the time to answer to my post :)

1 decade ago by Alex

Quote from dkollmann
I was wondering how to tell Weltmeister that a certain property of an (entity) needs to be saved even when it is not added to the property panel.

Add a default property for that entity?

1 decade ago by dkollmann

It is modified and differs from the default value. This modified value needs to be saved but Weltmeister assumes it is still the default value and does not save it.

1 decade ago by dkollmann

As there does not seem to be a way to do this I just added the feature myself:

This function updates the getSaveData method in edit-entities.js

If an entity has a method _wmPreSaveSettings(settings) it is called and can add whatever properties it wants to save.

	getSaveData: function() {
		var ents = [];
		for( var i = 0; i < this.entities.length; i++ ) {
			var ent = this.entities[i];
			var type = ent._wmClassName;
			var data = {type:type,x:ent.pos.x,y:ent.pos.y};
			
			
			var hasSettings = false;
			for( p in ent._wmSettings ) {
				hasSettings = true;
			}
			if( hasSettings ) {
				data.settings = ent._wmSettings;
			}
			
// code addition by dkollmann
			if(ent._wmPreSaveSettings !=undefined)
			{
				if(data.settings ==undefined)
				{
					data.settings= {};
				}
				
				ent._wmPreSaveSettings(data.settings);
			}
// code addition by dkollmann
			
			ents.push( data );
		}
		return ents;
	},
Page 1 of 1
« first « previous next › last »