Lunarovich's Forum Posts

  • Glad you like it Please test it if you can and send comments and eventual feature requests: rot.js is a feature packed library. I'll implement those features not covered by C2 first.

  • For all Roguelike fans, here is an early work in progress version C2 interface to an excellent rot.js javascript roguelike library.

    "Generate map" action generates the map data and stores it in the plugin internal dictionary (the plugin is based on the Dictionary plugin): the key represents map coordinates and is of the format "x,y" (e.g. "12,34"); the value is a text character - "." for floors/passable tiles and "#" for walls/solids.

    Plugin can compute a discrete (map cell based) FOV (Field of vision) from a given map coordinate:

    Plugin can compute a discrete (map cell based) path (Dijkstra algorithm) from a given map coordinate to a given map coordinate:

    Configurable room width & height and corridor length:

    Loop through all rooms and access room edges and center (useful for a map object placement):

    Added door hooks. You can get X & Y coords foor each room's door...

  • Thanks Do you know where I can read more on pushCopySol(), popSol() and solModifiers?

  • Hello! Could someone be so kind to explain me this piece of code from Dictionary plugin or point me to the place where I can read more about it...

    	Cnds.prototype.ForEachKey = function ()
    	{
    		var current_event = this.runtime.getCurrentEventStack().current_event;
    	
    		for (var p in this.dictionary)
    		{
    			if (this.dictionary.hasOwnProperty(p))
    			{
    				this.cur_key = p;
    				this.runtime.pushCopySol(current_event.solModifiers);
    				current_event.retrigger();
    				this.runtime.popSol(current_event.solModifiers);
    			}
    		}
    
    		this.cur_key = "";
    		return false;
    	};
    [/code:yyh3hc1z]
    
    Thanks!
  • Thank you for your response. I should have supposed that there is a good reason behind the absence of a straightforward way to access other plugins' ACEs. I think that everyone, including me in the first place, would appreciate very much a manual page or a blog post on plugin development best practices.

    While we are at it, I just wanted to share with you a few bumps i ran into while I was reading the SDK manual. For example, the Runtime reference explains how to access the runtime. However, I had to figure out on my own how to access layouts, layers, types and instances. Maybe a small adition to the first paragraph of the corresponding pages would facilitate the access.

    Be that as it may, I am thankful for this wonderful piece of software. Less frustration, more fun, elegant solutions

  • Hey, troublesum, thanks for the great explanation!

    I already quite figured it out on my own (thanks to your help from the previous post), but I appriciate always a clear and systematic explanation. Stays here for the benefit of the C2 mankind Plus, I think it should be in the official manual. It would have saved my time, anyway...

    The only critique goes to the sequence of your emails... The last one should have been the firt one

  • Hey, I've got it ))

    This works and makes sense (although it's a bit convoluted for my taste...):

    var dictInst = dict.getFirstPicked();
    dictInst.type.plugin.acts.AddKey.call(dictInst, "ace", 51);
    console.log("SUCCESS: " + dictInst.dictionary["ace"]);
    [/code:1e4ffs47]
    
    Hope to finish soon rot.js C2 integration and offer an intuitive way to make a roguelike for all those roguelike fans
  • Thanks for your thorough and informative answer. I don't know why such a useful functionality should be bogged down by this intricate function call chain / object reference chain.

    Could you please point me to some plugins where I can see the examples of this going on?

    P.S. Here are the first results of making a plugin out of rot.js library:

  • Hello, I've just started to "roll my own" plugin <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

    However, I am confused about how to access ACEs (conditions, actions, expressions) inside the runtime.js. For example, I have this piece of code in my edittime.js:

    AddNumberParam("Size", "Enter a map size.");
    AddObjectParam("Object", "An array to store the map in.");
    AddAction(1, af_none, "Generate map", "Generator", "Generate map of size {0} and store it in {1}", "Generate a 2D map", "GenerateMap");
    [/code:1wll1i8q]
    
    I send an Array object form inside the C2,
    
    [img="http://i.imgur.com/J2xQS3e.png"]
    
    Now, from inside my runtime.js, I would like to be able to call, for example, SetX() function of the Array object. I've managed to do something similar with
    
    [code:1wll1i8q]
        	Acts.prototype.GenerateMap = function (size, array)
    	{
                var arrayInstance =  array.getFirstPicked();             
                arrayInstance.set(0, 0, 0, 23);
    	};
    [/code:1wll1i8q]
    
    However, this one will not work
    
    [code:1wll1i8q]
        	Acts.prototype.GenerateMap = function (size, array)
    	{
                var arrayInstance =  array.getFirstPicked();             
                arrayInstance.SetX(0, 23);
                // this one neither: arrayInstance.acts.SetX(0, 23);
    	};
    [/code:1wll1i8q]
    
    I have understood that I can access all the functions which are attached on the [b]instanceProto[/b] object. This makes sense, since I am accessing functions of the instance of the plugin. For example,
    
    [code:1wll1i8q]
    	instanceProto.set = function (x, y, z, val)
    	{
    		x = Math.floor(x);
    		y = Math.floor(y);
    		z = Math.floor(z);
    		
    		if (isNaN(x) || x < 0 || x > this.cx - 1)
    			return;
    			
    		if (isNaN(y) || y < 0 || y > this.cy - 1)
    			return;
    			
    		if (isNaN(z) || z < 0 || z > this.cz - 1)
    			return;
    			
    		this.arr[x][y][z] = val;
    	};
    [/code:1wll1i8q]
    
    However, I see that ACEs are neither attached to the [b]pluginProto.Type.prototype[/b] nor to the [b]pluginProto.Instance.prototype[/b], but directly to the [b]pluginProto[/b]. (The latter is the "shortcut" to the [b]cr.plugins_.MyPlugin.prototype[/b]). So, if I access types and instances functions/properties via type. and inst., how do I access ACEs which are attached directly to the prototype of the plugin?
    
    I want to do all this, in order to learn how to implement plugins/behaviors and to implement a C2 http://ondras.github.io/rot.js/hp/  interface. This will facilitate the job of making roguelikes in C2.
  • If you have a sufficently small number of objects, you can simply move objects around placing them on different layers. Afterwards, you can test the layer the sprite is on with the Sprite.LayerName expression or similar.

  • Hello. The best way to show and hide the sprite would be to use the set visible action which "sets the object visible or invisible (hidden)." Measure the time with the dt expression (which gives you the amount of time in seconds since the last tick.) You can set up a variable and do a variable = variable + dt and than compare that variable to some given value, say 5 sec.

    To count the number of times the sprite is visible/invisible, use a counter variable (instsance variable or a global one) and increment it when the sprite is shown or hidden.

    For the gradual reduce of the time, the best way would be, in my opinion, to use some quadratic function of the counter variable mentioned above.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi, you can try to inspect the z-order of the sprites in question...

    Basically, ZIndex property gives you "the zero-based index of the Z order of the instance within its current layer. 0 is the bottom instance, increasing up to the top instance."

    Do a simple < or > test on your sprites...

  • Maybe a number of your lightmasks is simply too small to notice any performance difference...

  • Yeah, thanks for the tip.

    Although C2 does not render non visible parts of the layout and there is no performance loss, Paster still renders off screen to the intermediate texture, I suppose. Did you test the performance on the large layout or is it just an educated guess?

  • Katala, thanks for the blend mode additive tip for pre-baked light tints. Probably a better solution on the level of aesthetics and performance than my TintMask application.