bladedpenguin's Recent Forum Activity

  • That's a really clever solution, Somebody. It never gets larger than the number of pixels in your background, no matter how many corpses you paste onto it.

    Does the canvas save/load alright after being modified?

  • Any browser that is able to accept cookies will work with webstorage.

  • I apologize for the necromancy, but the forums won't let me send PMs yet. I would have just PM's Yann instead of raising a thread from the fossil record. I also don't see a rules post forbidding the resurrection of fossils.

    Yann, I'm interested in the examples you posted earlier in the thread. Your dropbox links seem to have gone stale. Do you, by chance, still have them?

    I too am looking to set up an RPG with branching dialog, and while I see a bunch of ways to do it, and Yann's descriptions have been informative, I think I can still learn more from an example. My goal is to set up a system that it will make it as easy as possible to set up dialog for hundreds of conversations, even if that means writing a plugin. It looks like all the dialog will be in one array though. Is there a way to make an array local to a specific layout? I would like to deal with each layout separately, since we seem to be making levels in no particular order.

  • Do you have a Javascript API for that midi controller? Take a look at the example plugins, which will show you how to create actions, expressions, and conditions. My guess would be that you should start mapping actions and expressions to the things the API allows you to do.

  • I realize that dropbox is not intrinsically unstable, but Instabilities due to users forgetting their stuff and deleting it is still instability.

    Perhaps there should be an initiative to clean up tutorials with broken links? I wouldn't mind having a go at enumerating the broken ones for mods to clean up. Perhaps I could even recreate a couple of them or message the original user, so if they are still around and still have the file, they can reupload as a forum attachment.

    I appreciate the history. It makes it a lot less frustrating to know why. As a student, i don't mind dealing with ads on mediafire or whatever, but for debugging, wait free downloading is a must, especially since you probably have to grab multiple versions of the same capx.

  • It seems like 60% of the tutorials and old forum posts I stumble across post their examples with Dropbox. While it's a great way to get files up very quickly and easily, Dropbox is highly unstable, and most of the links are broken, and alot of the comments and replies are unanswered requests for a repost. Why don't people use a more stable host, or upload their capx as an attachment to the forum post? It seems to me that there is little purpose in adding an example to a tutorial if the example is just going to disappear soon after the tutorial is created....

  • Awesome! Thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm working on a behavior, and I am invoking

    this.runtime.trigger(cr.behaviors.RPGChar.prototype.cnds.Damaged, this);[/code:499z4zop] In the hopes of running an event whenever a character takes damage. However, when I shoot a character,  I get an error on line 4421 of preview.js, and it seems to be about families. I couldn't figure out how to run a stacktrace, but I had my behavior spit out this.type and sure enough, this.type.families was undefined.  It seems odd to me that  triggering a condition in a behavior should expect to find a family. My understanding from reading the manual is that families only apply to plugins/objects, not behaviors. Am I using runtime.trigger incorrectly?
    
    Please help. I feel like I've done enough detective work, and i need someone with understanding.
  • I just picked up Construct 2 this Monday. Our studio is switching from RPG maker, and so far I am finding Construct 2 to be vastly more powerful, full featured, and transparent! I'm new to Javascript, and I'm working on setting up our damage dice etc, and I want to have a popup appear over a character's head when they take damage. I figured out how to get it to instantiate a text object with runtime.createInstance(), which will drift up and fade, but I'm having trouble accessing the SetText action in the text so I can insert the damage value. I've . The area I seem to be having trouble is around Line 173. I can also paste the whole capx if needed.

    Thank you!

    Edit: apparently I am too new to pastebin the code, but here it is. BBCode doesn't seem to support line numbers, but it's about 3/4 of the way to the bottom, under the "Defend" action.

    // ECMAScript 5 strict mode
    "use strict";
    
    assert2(cr, "cr namespace not created");
    assert2(cr.behaviors, "cr.behaviors not created");
    
    /////////////////////////////////////
    // Behavior class
    // *** CHANGE THE BEHAVIOR ID HERE *** - must match the "id" property in edittime.js
    //           vvvvvvvvvv
    cr.behaviors.RPGChar = function(runtime)
    {
        this.runtime = runtime;
    };
    
    (function ()
    {
        // *** CHANGE THE BEHAVIOR ID HERE *** - must match the "id" property in edittime.js
        //                               vvvvvvvvvv
        var behaviorProto = cr.behaviors.RPGChar.prototype;
            
        /////////////////////////////////////
        // Behavior type class
        behaviorProto.Type = function(behavior, objtype)
        {
            this.behavior = behavior;
            this.objtype = objtype;
            this.runtime = behavior.runtime;
        };
        
        var behtypeProto = behaviorProto.Type.prototype;
    
        behtypeProto.onCreate = function()
        {
        };
    
        /////////////////////////////////////
        // Behavior instance class
        behaviorProto.Instance = function(type, inst)
        {
            this.type = type;
            this.behavior = type.behavior;
            this.inst = inst;               // associated object instance to modify
            this.runtime = type.runtime;
        };
        
        var behinstProto = behaviorProto.Instance.prototype;
    
        behinstProto.onCreate = function()
        {
            // Load properties
            this.HP =       this.properties[0];
            this.MaxHP =    this.properties[1];
            this.Armor =    this.properties[2];
            
            this.InvulnerabilityTimer = false;
            this.InvulnerabilityDelay = 1000;
            this.AttackTimer = false;
            this.AttackDelay = 300;
    		this.Popup = undefined;
    		this.PopupImgPt = 0;
    		// object is sealed after this call, so make sure any properties you'll ever need are created, e.g.
            // this.myValue = 0;
        };
        
        behinstProto.onDestroy = function ()
        {
            // called when associated object is being destroyed
            // note runtime may keep the object and behavior alive after this call for recycling;
            // release, recycle or reset any references here as necessary
        };
        
        // called when saving the full state of the game
        behinstProto.saveToJSON = function ()
        {
            // return a Javascript object containing information about your behavior's state
            // note you MUST use double-quote syntax (e.g. "property": value) to prevent
            // Closure Compiler renaming and breaking the save format
            return {
                // e.g.
                "hitPoints": this.HP
            };
        };
        
        // called when loading the full state of the game
        behinstProto.loadFromJSON = function (o)
        {
            // load from the state previously saved by saveToJSON
            // 'o' provides the same object that you saved, e.g.
            // this.myValue = o["myValue"];
            // note you MUST use double-quote syntax (e.g. o["property"]) to prevent
            // Closure Compiler renaming and breaking the save format
        };
    
        behinstProto.tick = function ()
        {
            var dt = this.runtime.getDt(this.inst);
            
            // called every tick for you to update this.inst as necessary
            // dt is the amount of time passed since the last tick, in case it's a movement
        };
        
        // The comments around these functions ensure they are removed when exporting, since the
        // debugger code is no longer relevant after publishing.
        /**BEGIN-PREVIEWONLY**/
        behinstProto.getDebuggerValues = function (propsections)
        {
            // Append to propsections any debugger sections you want to appear.
            // Each section is an object with two members: "title" and "properties".
            // "properties" is an array of individual debugger properties to display
            // with their name and value, and some other optional settings.
            propsections.push({
                "title": this.type.name,
                "properties": [
                    // Each property entry can use the following values:
                    // "name" (required): name of the property (must be unique within this section)
                    // "value" (required): a boolean, number or string for the value
                    // "html" (optional, default false): set to true to interpret the name and value
                    //                                   as HTML strings rather than simple plain text
                    // "readonly" (optional, default false): set to true to disable editing the property
                    {"name": "My property", "value": this.myProperty},
                    {"name": "Attack Timer", "value": this.AttackTimer},
    				//{"name": "Popup", "value": this.Popup}
                ]
            });
        };
        
        behinstProto.onDebugValueEdited = function (header, name, value)
        {
            // Called when a non-readonly property has been edited in the debugger. Usually you only
            // will need 'name' (the property name) and 'value', but you can also use 'header' (the
            // header title for the section) to distinguish properties with the same name.
            if (name === "My property")
                this.myProperty = value;
        };
        /**END-PREVIEWONLY**/
    
        //////////////////////////////////////
        // Conditions
        function Cnds() {};
    
        // the example condition
        Cnds.prototype.IsDead = function ()
        {
            // ... see other behaviors for example implementations ...
            return this.HP < 0;
        };
        
        // ... other conditions here ...
        
        behaviorProto.cnds = new Cnds();
    
        //////////////////////////////////////
        // Actions
        function Acts() {};
    
        // the example action
        Acts.prototype.Attack = function ()
        {
            // ... see other behaviors for example implementations ...
        };
        Acts.prototype.Defend = function (damage)
        {
            if (damage === undefined) {
                damage = "0";
            }
            var dmg = (Number(damage) - this.Armor);
            if (dmg > 0) {
    			this.HP -= dmg;
    			if (this.Popup != undefined ) {
    				var popinst = this.inst.runtime.createInstance(this.Popup, this.inst.layer, this.inst.getImagePoint(this.PopupImgPt, true), this.inst.getImagePoint(this.PopupImgPt, false));
    				if (popinst === undefined) {alert("wtf")} else {
    					popinst.SetText(String(dmg));
    				}
    				
    			} else {alert("Popup undefined!")}
    		}
            // ... see other behaviors for example implementations ...
        };
    	Acts.prototype.SetPopup = function (object, imgpt)
        {
    		//alert("setting popup on " & this.inst.toString() & " to " & this.Popup);
            this.Popup = object;
    		this.PopupImgPt = imgpt;
    		
        };
        
        // ... other actions here ...
        
        behaviorProto.acts = new Acts();
    
        //////////////////////////////////////
        // Expressions
        function Exps() {};
    
        // the example expression
        Exps.prototype.HP = function (ret)  // 'ret' must always be the first parameter - always return the expression's result through it!
        {
            ret.set_int(this.HP);               // return our value
            // ret.set_float(0.5);          // for returning floats
            // ret.set_string("Hello");     // for ef_return_string
            // ret.set_any("woo");          // for ef_return_any, accepts either a number or string
        };
        Exps.prototype.Attack = function (ret)  // 'ret' must always be the first parameter - always return the expression's result through it!
        {
            if (this.AttackTimer ) {
                ret.set_string("0");
            } else {
                ret.set_string( String(1+Math.floor(Math.random()*5)));
                
                this.AttackTimer = true;
    			var self = this;
                setTimeout(function(){ self.AttackTimer = false},this.AttackDelay)
            }
            // ret.set_float(0.5);          // for returning floats
            // ret.set_string("Hello");     // for ef_return_string
            // ret.set_any("woo");          // for ef_return_any, accepts either a number or string
        };
        
        // ... other expressions here ...
        
        behaviorProto.exps = new Exps();
        
    }());[/code:3b0o1be9]
    
    While I was poking around I stumbled accross the inst.text and inst.text_changed. I set the text to what I wanted and text_changed to true, and that seemed to work. I checked in the settext action of the text plugin, and I found that there were three lines there. [code:3b0o1be9]popinst.text = String(dmg);
    					popinst.text_changed = true;
    					this.runtime.redraw = true;[/code:3b0o1be9]
    I added the redraw line to my code, but I don't imagine it's good coding practice to duplicate the action this way. I would much rather find a way to test to make sure I spawned a text object, then invoke it's SetText action, so it can handle the text change itself. Any ideas on how I might do this in a more correct manner?
    
    Edit: I found inst.type.plugin.acts.SetText(dmg); But it seems to crash Text_Plugin.js at line 707, column 24.  This is the redraw line above. It says "cannot set property 'redraw' of undefined".  I'm guessing that I am trying to call the action before the text object is properly intialized. Is there a way to schedule an action for the next frame? Or should I initialize the popup instance somehow? I tried runtime.trigger(Object.getPrototypeOf(this.Popup.plugin).cnds.OnCreated, popinst); but that didn't seem to work.
bladedpenguin's avatar

bladedpenguin

Member since 5 Feb, 2015

None one is following bladedpenguin yet!

Trophy Case

  • 9-Year Club
  • Email Verified

Progress

10/44
How to earn trophies