How do I fix this?

0 favourites
  • 8 posts
  • when running the code the output is always null and includes the newline opperator \n. what i wrong here

    raw json thing :

    {"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"group","disabled":false,"title":"get sys info","description":"","isActiveOnStart":true,"children":[{"eventType":"variable","name":"index","type":"number","initialValue":"0","comment":"","isStatic":true,"isConstant":false},{"eventType":"variable","name":"e","type":"string","initialValue":"\"\"","comment":"","isStatic":false,"isConstant":false},{"eventType":"variable","name":"text","type":"string","initialValue":"\"\"","comment":"","isStatic":true,"isConstant":false},{"functionName":"get sys info","functionDescription":"","functionCategory":"","functionReturnType":"none","functionCopyPicked":false,"functionIsAsync":false,"functionParameters":[],"eventType":"function-block","conditions":[],"actions":[{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Canvas css height\"","value":"PlatformInfo.CanvasCssHeight"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"canvas css width\"","value":"PlatformInfo.CanvasCssWidth"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"canvas device height\"","value":"PlatformInfo.CanvasDeviceHeight"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"canvas device width\"","value":"PlatformInfo.CanvasDeviceWidth"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"connection effective type\"","value":"PlatformInfo.ConnectionEffectiveType"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"conection rtt\"","value":"PlatformInfo.ConnectionRTT"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"connection type\"","value":"PlatformInfo.ConnectionType"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Device memory\"","value":"PlatformInfo.DeviceMemory"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Device pixel ratio\"","value":"PlatformInfo.DevicePixelRatio"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Downlink\"","value":"PlatformInfo.Downlink"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Downlink max\"","value":"PlatformInfo.DownlinkMax"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"FPS\"","value":"PlatformInfo.FramesPerSecond"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Hardware concurrency\"","value":"PlatformInfo.HardwareConcurrency"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Renderer\"","value":"PlatformInfo.Renderer"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Renderer detail\"","value":"PlatformInfo.RendererDetail"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"SafeAreaInsetBottom\"","value":"PlatformInfo.SafeAreaInsetBottom"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"SafeAreaInsetLeft\"","value":"PlatformInfo.SafeAreaInsetLeft"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"SafeAreaInsetRight\"","value":"PlatformInfo.SafeAreaInsetRight"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"SafeAreaInsetTop\"","value":"PlatformInfo.SafeAreaInsetTop"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Screen height\"","value":"PlatformInfo.ScreenHeight"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"screen width\"","value":"PlatformInfo.ScreenWidth"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"TicksPerSecond\"","value":"PlatformInfo.TicksPerSecond"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"WindowInnerHeight\"","value":"PlatformInfo.WindowInnerHeight"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"WindowInnerWidth\"","value":"PlatformInfo.WindowInnerWidth"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"WindowOuterHeight\"","value":"PlatformInfo.WindowOuterHeight "}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"WindowOuterWidth\"","value":"PlatformInfo.WindowOuterWidth "}}]},{"eventType":"block","conditions":[{"id":"on-start-of-layout","objectClass":"System"}],"actions":[{"callFunction":"get sys info"}]},{"eventType":"block","conditions":[{"id":"for-each","objectClass":"System","parameters":{"object":"Dictionary"}}],"actions":[{"id":"add-to-eventvar","objectClass":"System","parameters":{"variable":"text","value":"\"\\n\" & str(Dictionary.TagAt(index)) & str(Dictionary.GetDefault(str(Dictionary.TagAt(index)),\"null\"))"}}]},{"eventType":"block","conditions":[{"id":"compare-eventvar","objectClass":"System","parameters":{"variable":"text","comparison":1,"value":"\"\""}}],"actions":[{"id":"set-text","objectClass":"sys_info","parameters":{"text":"\"\\n PRESET \\n\" & text & \"\\n [---END---]\" "}}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"}],"actions":[{"id":"set-text","objectClass":"sys_info","parameters":{"text":"\"Somethign went wrong here\""}}]}]}]}

    more simplified version:

    • gets all the infro from platform info plugin stores info into a dictionary itterates through dictionary and appends it to a text box

    output:

  • heres an image as i realise that the big block of text is not pealing.

    i realise this is very inefficient so any advice is greatly appreciated, just thought this would be good for debugging purposes as the console log is unavailable at my school for whatever reason

    heres what its currently looking like

  • Not sure yet everything that you are trying to accomplish here but here are a few issues that I see:

    1-Your Dictionary event ------> "For Each Key" ---> add to Global Text

    is running every tick so is constantly adding values to your global variable.

    If this is not what you intended, consider putting that event in a trigger like for example under "On start of layout" that you have above that, so it runs only once.

    2-On your dictionary you are using----> Dictionary.TagAt()

    what is that TagAt() mean??

    I have never seen it in my life, even the C3 Manual doesn't mention that :))

    Could be a new thing?

    Though in any case to get the dictionary values you need to use:

    Dictionary.Get("Your Key Name")

    For example:

    Dictionary.Get("Canvas CSS height")

    Dictionary.Get("canvas CSS width")

    Dictionary.Get("Downlink")

    etc...

    If you try to get the dictionary Values in a "For Each Key" you can even use

    Dictionary.Get(Dictionary.CurKey)

    CurKey = Current key

    But that expression only works when you use "For Each Key"

    3-To add new lines of text, normally you do --------> newline & "Your text"

  • ah yes i was under the impression that tag at would be give me the key itself as i couldnt find any other reference. except that of get which is used to get the value

    the format i wsa looking for is "key (the thing it is) adn value (the actuall vlue of the reference to the plugin)

    and im not even sure what tag at does but it appeares in the dropdown when you select which function to use

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ah yes i was under the impression that tag at would be give me the key itself as i couldnt find any other reference. except that of get which is used to get the value

    the format i wsa looking for is "key (the thing it is) adn value (the actuall vlue of the reference to the plugin)

    and im not even sure what tag at does but it appeares in the dropdown when you select which function to use

    Isee

    In that case you should use:

    Add to text ----> newline & dictionary.CurrentKey & ";" & dictionary.CurrentValue

    This will add on each line:

    Current key;Current Value

  • this is the current code

    the reload = 1 seems to not be working currently. i seem to have this issue with construct 3 alot where comparisons dont work is there something im not seeing?

  • i have found the issue it was the text != to "" that was doing this infinitely

    although the reload buttone seems to add a :0 every time

  • It seems that you are splitting the events unnecessary and it could be hard to track.

    Why not do everything under the trigger on mouse touch?

    For example:

    On (Touch or Mouse) touch reload button

    ----Sub Event: Clear dictionary

    ------------------- Function Call get sys info

    ----Sub Event: Dictionary "For each key" ---> Add to text ----> newline & ----dictionary.CurrentKey & ";" & dictionary.CurrentValue

    ----Sub Event: Append Newline & "PRESET" & Newline & text & & newline & "END"

    Not sure if it's clear enough the structure as it removes the empty spaces but there are 3 sub Events independent from each other, they should be one after the other

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)