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 tjw

I would like the Weltmeister editor to automatically populate the Key / Value settings so that I know what values are editable, instead of digging into the Entity's source code, risking the chance of a typo, and typing out the key name each time.

Additionally, I would like an easy way to hide Entities from the Weltmeister drop-down Entity menu. The Particle Entity is a perfect example of one that you do not want in the editor, it's meant to be a base class.

Ok, so I'm kind of teasing here... I've actually written these features in my local branch of Impact and want to know how to share them. It contains patches to the Weltmeister editor's code that I don't feel comfortable with sharing unless Dominic gives me the thumbs up.


Here is how I ended adding these features into my branch.

In Weltmeister I check for a new magic key on the Entity _wmKeys, this key is an array of strings, each being the name of an editable key that I care about on this Entity. i.e.
_wmKeys: ['name', 'strength', 'duration'],

Then when loading the settings I check to see if this key already exists in the Entity's _wmSettings, if so I use that value, if not I check to see if the key exists on the Entity itself, if so I default it to that value, if not I default it to an empty string. Now when I go to write the entity back out, if you haven't changed the value, the value isn't actually saved to the settings and nothing additional or unnecessary is serialized out to the level file.

I have a solution for hiding classes as well. Just add a static class property named _wmIgnoreClass = true and when the Entity list is loaded, skip it if the key === true.

The code I have for the Entity keys is a nice starting point, but It would be even better to expand on the idea and allow for providing descriptions for each key that show up in Weltmeister, and to color code the keys so you know if it is a custom value or a default value sitting in the key. Additionally, it would be nice to provide a type hint for each key so you could have custom widgets for the value type... So the editor knows it's dealing with numbers, arrays, objects, etc. and can give a better input control for manipulating the values.

Let me know how I can share, and maybe we need to start talking about Weltmeister plugins as a whole!? (Or maybe we already did and I missed it)

1 decade ago by emati

I'am absolutely sure that we need to start talking about it, because there can be a lot more useful features as additional plugins created by users.

I have an idea to create bezier editor ( could be used as ground or something ), and i have already started but there is no way to share it without whole editor. Despite the fact that there is mess in weltmeister or i'am such a noob that i cant catch many things in it.

1 decade ago by Arantor

OK, let's go through these things:

* Hiding entities: yes, a method for this would be nice. You can put it outside the normal entities folder, which will effectively hide it, but then you have to not use game.entities.* as a prefix but simply game.* instead. Inelegant but not entirely impractical for some things.

* Having a list of pre-defined keys that are accessible: would be very nice. Not sure it really needs help in most cases, and if it does it means the name wasn't particularly descriptive. Type hint would be useful, though.

Perhaps implementing the list as:
_wmKeys: {
  name: 'int',
  strength: 'int',
  duration: 'int'
}

or similar. Just a thought, anyway.

* Weltmeister plugins generally... hmm, I haven't seen anyone discussing it and I know that I've also been interested in the past in implementing extra functionality, e.g. requiring tiles that weren't square in the past (which I did for 1.18)

* Sharing the code? There's no private forum, though I did ask about that. Seems to me that it would be a useful place to explain such a thing since it's hard to do much more than merely describe how to approach it publicly.

* Bezier editor: the huge problem with that is collisions. If you implement bezier curves, you need to implement collisions against it, which would be feasible if you're using Box2D but if you're not, it's going to be slow to actually handle movement and collision detection against it. That's partly why Dominic implemented slopes in 1.19 as discrete tiles rather than arbitrary angle slopes.

1 decade ago by zedd45

""Quote from Arantor

* Hiding entities: yes, a method for this would be nice. You can put it outside the normal entities folder, which will effectively hide it, but then you have to not use game.entities.* as a prefix but simply game.* instead. Inelegant but not entirely impractical for some things.


This doesn't always work, but if the entity is related to another entity (like the "slime grenades" projectile in jump & run) you can put it in the same file as the associated Entity that spawned it. I've found this very useful for projectiles, but I haven't run into a situation where I don't want an entity available in WeltMeister other than that, yet.

I really like the approach @tjw is using, though, and I'd love to implement some of that once our team gets a little farther in development.

1 decade ago by Datamosh

I add at line 361 of edit-entities.js of Weltmeister:

for(var key in this.selectedEntity._wmKeys) {
	if (this.selectedEntity._wmKeys.hasOwnProperty(key)) {
		if(this.selectedEntity._wmSettings[key] == undefined)
		this.selectedEntity._wmSettings[key] = this.selectedEntity._wmKeys[key];
	}
}

This way I can add properties to entities with default values:

_wmKeys: {
	inside: null,
	hidden: false,
},

Very useful at least in the game I'm working.

9 years ago by xEdFryed

Dont know if this will help any one but as weltmeister uses jQuery you can simply add the line

this.selectedEntity._wmSettings = $.extend(this.selectedEntity._wmDefaultSettings,this.selectedEntity._wmSettings);

at around line 390 of edit-entity.js in the weltmeister folder, just above the line

html += this.loadEntitySettingsRecursive( this.selectedEntity._wmSettings );

and then add

_wmDefaultSettings : {
	name 		        :  "Hairy Dave",
	coolDefaultVal 	:  "I love cheese"
},

in your entity file.

This will auto load the above settings into weltmeister.

To go one step further you can then add the following into your entities init function

for(var key in settings){
	this[key] = settings[key];
}

Which will then allow you to access the settings from the main entity object.

ie. you can now access the value set in _wmDefaultSettings by typing

this.coolDefaultVal

rather than

this.settings.coolDefaultVal
Page 1 of 1
« first « previous next › last »