tmntppn's Recent Forum Activity

  • I had done this before, but with sprites only (I didn't use tilemap on my project at that time).

    You can do like this:

    for each [object] order by [object].Y descending {
    	[object] move to top of layer
    }[/code:gmbonft5]
  • I have a project with quite a lot of multitasking inside, with each task might call for specific function, or 2 tasks call for 1 function with different parameter(s), either manually called or automatically scheduled.

    From what I have experienced, return value applies globally, meaning that whichever condition at the same tick request a return value, all will read the same value returned.

    On my project, I have a "synchronize" group that call for a sync function at every set duration. The sync will send an AJAX request to a remote server so the syncing process took several ticks to complete (~10 ticks). At the same time, I have a "user interface" group that will call for a function whenever a user calls them (~5 ticks).

    Short illustration of the sync group:

    every 300 tick {
    	value = get_sync();
    	[some actions...]
    	end
    }
    get_sync() {
    	var x;
    	[some actions...]
    	set return value to x;
    }
    [/code:30024806]
    Short illustration of the UI group:
    [code:30024806]if ( button_a pressed ) {
    	pin = get_auth(user_a);
    	[some actions...]
    	end
    }
    get_auth(var user) {
    	var y;
    	[some actions...]
    	set return value to y;
    }
    [/code:30024806]
    The problem will occur if:
    [code:30024806]
    @ 1670 tick: get_sync (supposed to end at 1680)
    @ 1675: get_auth()
    @ 1680: value = pin = [returned value from one of the function above]
    [/code:30024806]
    Is there a way to differentiate a return value, to identify which function calls for it? Maybe like Function.ReturnValue("my_function")?
  • Ah okay, I get it now. Thanks.

  • tmntppn

    I guess that you might run the older version of firebase, which does not have api key. i.e. api key is necessary in current version (v3).

    I already use firebase_apiV3, but I usually just set the database URL and leave the rest blank.

  • tmntppn

    Do you put rex_firebase_apiV3 plugin into project? sample capx

    Yes, I did. The "basic" firebase plugin works just fine. The sample above works, but others from that OneDrive page (such as "itemtable v3 - foreach item, foreach key.capx") doesn't work.

    EDIT: It turns out the itemtable doesn't work because I didn't set the API key. After I set the key, it works. However, without the key, the basic firebase plugins works (that's why I didn't suspect it before seeing your sample above). What does this API key for?

  • rexrainbow

    Hi rex, I'm just starting to try your itemtable plugins, but don't quite understand how to begin with. I've tried some of your samples but got this error instead:

    Javascript error!
    Uncaught Error: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp().http://localhost:50000/firebase.js, line 26 (col 293)[/code:35ztt4sm]
    What am I doing wrong?
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

tmntppn's avatar

tmntppn

Member since 23 Mar, 2015

None one is following tmntppn yet!

Trophy Case

  • 9-Year Club
  • Email Verified

Progress

10/44
How to earn trophies