tmntppn's Forum Posts

  • So you are saying that the problem is that it will execute with a negative value?

    That sounds like what it should do because if the ending index is lower than the starting it should change to for(i = 0; i > array_width; i--)

    If your only issue is the loop executing when empty why don't you just but a pre-condition as array.width > 0 ?

    Yes, I know by logic on what you put in the parameters, it makes sense. That's why I didn't say it's a bug or anything, just IMO a bit odd behavior as you can't have the loop run 0 times.

    What I use now is "repeat for array.width" but I have to have a variable to keep the loopindex in a nested loop. I was hoping by using loopindex("name"), I could make it simpler. Using pre-conditioning sure can do the trick, but that add some complexity, so it will just the same as using repeat.

  • The problem isn't about the negative index itself, but the behavior of the loop itself. By using end = -1, what I expect is that the loop shouldn't run at all.

    This is what I was doing:

    for "spawn" from 0 to array.width-1 {
    	create enemy...
    }
    [/code:hpp5z9qp]
    So if the array size (width) is 2, I will get loop: from 0 to (2-1) ==> result: new enemy.IID 0 & 1.
    If the array size is 1, I will get loop: from 0 to (1-1) ==> result: new enemy.IID 0.
    If the array size is 0, I will get loop: from 0 to (0-1) ==> result: new enemy.IID 0 & -1???
    
    Using multiple by -1 will make: from 0 to 1 ==> result: new enemy.IID 0 & 1, which is still wrong as I got empty array.
    
    In short, the for-loop is more like do-while.
  • I found an odd behavior (in my opinion of course) about for loop.

    According to the manual (link: https://www.scirra.com/tutorials/40/basic-loops-and-arrays), if the start index is greater than the end index, the loop will not execute. However, the reality isn't like this.

    If in construct 2, I put "for loop" like this:

    • start = 0; end = 0; loop run once (0)
    • start = 0; end = 1; loop run twice (0, 1)
    • start = 0; end = -1; loop run twice (0, -1)

    This isn't what I expected. What I expect from "for loop" is supposed to be what I expect to happen in C++:

    for(i = 0; i < array_width; i++)[/code:1jci93sg]
    "i < array_width" and "i++" should be the deciding factor. So if end = -1, the loop shouldn't start.
    
    So is there a way to create a "for loop" without negative index? Or if this is by design, what is the reason?
    
    I could use repeat instead of for loop, but I would prefer for loop because I can get loopindex("name") by using for loop, instead of having to add several variable just to store loopindex (I'm using nested loop, so I need to get loopindex of the parent loop).
  • Update

    rex_firebase_apiV3, rex_firebase_authentication, rex_firebase, rex_firebase_curTime plugins: add initialize connection by action.

    In rex_firebase_apiV3, set property "Api key" to empty string "" then call "Action:Initialize" to initialize connection later.

    That's quick... Much thx.

    Here is another application plugin to get server timestamp continuously.

    I've tried download and installing the plugin in this link and open the sample but it says the plugin 'Current timestamp' is not installed. The plugin in the link is rex_firebase_counter, is this correct?

  • tmntppn

    I could try to add this feature, it might take some days.

    Thanks a lot.

  • rexrainbow Thx, I'll try your curtime plugin.

    One more thing is with the FirebaseAPIV3. Is there a way to set the database URL value from construct action (such as Firebase-set domain)? The reason is because I want to be able to set this URL dynamically (I use AJAX plugin to read external config file) so I can deploy my project in two places, both needs their own db, without needing to change the programming code.

  • Hi rex, I've come across something that I'm not sure whether it's a bug or it's intended to be.

    • If I set a value (with send-set) into, lets say a tickcount, I received one callback as I think it should.
    • But if I set server timestamp, I received two callbacks, both with different Firebase.LastData value.

    Is this a bug?

  • rexrainbow

    Hi, I've just started using your plugins and I need help with some of the basic, of probably some suggestion of the best practice using firebase. Lets say I have firebase db like this:

    "queue":
    	- "queue_a":
    		- "1":
    			- "pax":2
    			- "status":"CALLED"
    		- "2":
    			- "pax":1
    			- "status":"WAITING"
    	- "queue_b":
    		- "1"
    			- "pax":4
    			- "status":"WAITING"
    		- "2"
    			- "pax":4,
    			- "status":"WAITING"
    "other_key":...
    [/code:3bzwuc16]
    
    How can I get the count of groups waiting in each queue_a and queue_b?
    
    So far, I've tried using your itemtable plugins: I load all items at the start of layout and display result with ItemTable.Count, but I only get the count result of the root domain. How can I get the count of subdomain? Do I need to set domain to each specific subdomain, get count, and set to another subdomain, get count again? Or in related with construct 2, is it probably better if I load all items then store it in local JSON plugin (I'm using Yann's JSON plugin) and count it from there?
    
    I hope my question is clear enough. Thank in advanced.
  • Yann

    Great plugins tho. I've been using it in some of my projects and it helps a lot, so thx for the plugins.

    Feature suggestion: Find indexof("value"). Is it possible to add a feature to find index in an array? Similar to indexof expression in Array object. What I'm doing now is loop through each element and compare its value one by one. Indexof will make a shorter line of code.

  • So I create a fix for myself. Now it is able to delete an element of an array.

    Say we have JSON like this:

    {"models":[{"id":1,"type":"Type 0"},{"id":2,"type":"Type 1"}]}[/code:1ip9crp5]
    Previously, if I set action:
    [code:1ip9crp5]delete root@"models", 0[/code:1ip9crp5]
    The result will be like this: (Note that the first element becomes [i]null[/i].)
    [code:1ip9crp5]{"models":[null,{"id":2,"type":"Type 1"}]}[/code:1ip9crp5]
    
    So I change the runtime.js at line 405, from this:
    [code:1ip9crp5]function deleteIfValid(obj,prop) {
    	if ( obj !== undefined && obj !== null && 
    		(typeof obj === "object") && obj[prop] !== undefined){
                    
    		delete obj[prop];
    	} else {
    		log("invalid path: root@"+ path_.toString(),"warn");
    	}
    }[/code:1ip9crp5]
    Into this:
    [code:1ip9crp5]function deleteIfValid(obj,prop) {
    
    	if ( obj !== undefined && obj !== null && obj[prop] !== undefined ) {
    
    		if( Object.prototype.toString.call( obj ) === '[object Array]' ) {				// If object is an element of an array
    			obj.splice(prop,1);															// delete element at index prop
    		} else if( Object.prototype.toString.call( obj ) === '[object Object]' ) {		// If object is an object
    			delete obj[prop];
    		}
    
    	} else {
    		log("invalid path: root@"+ path_.toString(),"warn");
    	}
    }[/code:1ip9crp5]
  • Hi,

    Is it possible to delete an element of an array? Currently, what I've tried so far is that I can delete an element of an object, but not array. When I use "delete" action and set the keys into an array, it just emptied the array, making it null. What matter is when I try to get the size (eg: JSON.Size(0, "data"), the null elements are counted as well. Can I delete the element entirely so it wont be counted? Or am I doing it wrong?

    Regards,

    Alvin

  • I bumped on this very same problem about layer visibility just 2 days ago and I can say that I'm also disappointed that this doesn't even mentioned in the manual.

    I spend whole yesterday trying to figure out what was I doing wrong. Tried with different settings, different methods, I read manuals about layers, system action/expression, etc. all with same result. Jeez, it even cross my mind to rewrite everything because I wasn't sure if the bug was coming from corrupted save file. That would have set me back a week worth of works. This should have been mentioned in the manual.

  • I'm having the same problem here (r221). So is there a workaround for this to make the newline visible in the basic notepad? I'm asking because at this moment, I still need the output file to be opened with basic notepad.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi septeven, sorry for reviving an old thread. I wonder if you have update for the font properties? Particularly the font type, size, and line spacing. Also, is it possible to change size of the circle/square?

  • Hi, I've just purchased your plugin through paypal. Please confirm and send me the plugin? Thanks.

    PS: The email address is: j39drxxxx gmail . com (same as paypal).