admir's Forum Posts

  • Well, I'm setting multidimensional array values from a JSON file to a C2 Array object:

    Take something like this for example:

    {
    	"c2array": true, 
    	"size": [3,2,1], 
    	"data": [
    		[
    			["title"],
    			["desc"]
    		],
    		[
    			["Frog"],
    			["Very green"]
    		],
    		[
    			["Camel"],
    			["Very yellow"]
    		]
    	]
    }
    [/code:30q6fhyr]
    
    I have something like this to load it up:
    
    [code:30q6fhyr]
    [On Start Layout ] -> AJAX -> Request words.json (tag "words")
    [On "words" completed] -> Words (Array) -> Load from JSON string AJAX.LastData
    [/code:30q6fhyr]
    
    Now I'm trying to use the data in this array in a Text object that I've programmatically spawned:
    
    [code:30q6fhyr]
    [On Start Layout] -> System -> Create Text on layer 0 at (200, 200)
    [On created Text]
        [Words is empty]
        [else]
            [Text] -> set text to Words.At[0,0,0]
    [/code:30q6fhyr]
    
    Using the .At() function, I'm only getting a value of "0" and not the text from the multidimensional array. Anyone know why this is so? The JSON data appears in the array viewer in the debugger.
  • ramones - thanks for the tips, I'll try these!

    LittleStain - Thanks for the suggestions. I'm not sure myself. I'm still figuring this out - I'm trying C2 again so I'm still getting settled with this WYSIWIG interface. Ideally, I'd like to show, up to which characters typed by the user matches the target word then break when the user enters a character that doesn't match up.

  • Hi,

    I've got 2 instance variables that both has String that I'd like to make a comparison of. I'm trying to make one of those typing games that take in the latest character typed and sees if the last character of the target word matches up. So I looked up the Regex function and I'm trying that out, but how do you enter the regex? Like for example, RegexSearch(). This takes in a String, Regex and Flag as parameters. Any clue as to how I can use this to search up instance var A using instance var B as a regex value? I'm a little confused as how the formatting goes.

    So I'm guessing I'm looking for something like:

    RegexSearch(InstanceVarA, /^InstanceVarB/, flags?)
    [/code:tjmg3i0q]
    
    So in JS, something like:  
    
    [code:tjmg3i0q]
    /^searchingforthisterm/.test("I am searchingforthisterm")
    [/code:tjmg3i0q]
    
    And is there a function to get the last character of a String?
  • As what the title says! I'm curious about this one. Has anyone tried this instead of the usual ad networks like AdMob etc? I'm talking about maybe using one's Amazon referral links as an ad banner, or maybe another shopping service out there that has an affiliate program - I don't know, like Rakuten, or Udemy, or even something like TripAdvisor? And how has it worked out for you?

  • Yes, something like that! Thanks for the example.

  • I suppose this'll work. Is there an equivalent of the clearTimeout(timer) part within in Construct 2 though?

  • Hmm it seems the wait is fixed at 1 sec. Is there a way to reset the wait counter (count back from 0) whenever a keypress (within the set timeout) is made?

  • Ah let me try that. That's a subevent no? And this subevent acts like a nested condition?

  • The title sounds off. Ok, here's what I've got. I'm detecting keyboard input from the INPUT box in the event sheet. So it looks something like this:

    On Text Change -> Wait for 1 sec and do my action here...

    This isn't what I'm looking for of course as every time I input a key and thus, a text change is detected, it fires accordingly. So if I type up "hello" quickly, it'll run the action 5 times (there are 5 letters).

    So I'm looking for a way to detect changes on the text box but only fire my action once given a certain time period where no more changes are detected. So if I type up "hello" quickly, it'll fire the action only 1 time. So in JS, it's something like this:

    var timer; 
    var interval = 3000;       // Delay in ms before the action will run
    
    $('#inputbox').keyup(function(e) { 
        if (timer)
            clearTimeout(timer);
    
        timer = setTimeout(action, interval); 
    }); 
    
    function action() {
       //My actions here
    }
    [/code:9lualxyu]
    
    Is there something of a rough equivalent to this that anyone knows about?
  • Oh nevermind. I tried your sample and it worked. I thought the c2dictionary part was just a filler example

  • Ok, I'm up to the point where I can use Ajax plugin to load up the data into a text box... But for some reason, the Dictionary isn't "importing". I've got:

    on start of layout, AJAX -> Request Hiragana-data.json (tag: "hiraganaData")

    on "hiraganaData" completed, Hiragana -> Load from JSON string Ajax.lastData

    Am I doing the dictionary loading right?

  • Looks like it's allergic to single quotes.. As for the JSON loading, do you know how to load up the JSON file after having imported it into the project files?

  • Looks like it's not being loaded? Key count is 0... Hmm.. I'm confused by that special json format. Which gets the double-double quotes?

  • Here you go.

    So as you can see, I've tried loading in the key-value pairs as JSON. Still wouldn't work. What I'm doing here is logging text into a text input field first before trying to see if Hiragana.Get (a dictionary) can work with the inputted keys. In this example, Hiragana.tsu works, but since this isn't what I need, .Get is what I'm trying to get working.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi,

    It's been awhile. I'm trying out the latest beta of Construct 2 and I'm trying to create a virtual QWERTY keyboard that as you enter, will detect Japanese kana characters in romaji and convert them to the right character. Ex: if I type in "ru", the game should detect and translate it to "る". So I'm trying to make use of the Dictionary object. Now, while I was able to input a series of romaji -> kana instance variables, I notice that I'm not able the use the Dictionary.Get('name') command. It always returns a 0. However, when I do get something when I use Dictionary.name.

    So for example, Dictionary.ru will return me "る". But Dictionary.Get("ru") will return me 0.

    I need to use the first method because my source is a hidden text element or global string variable that detects keyboard input.

    Any thoughts what my problem is here? Or maybe there's another way to go about this?

    Thanks!