Need help with replace()

0 favourites
  • 5 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I'm working on a system that saves all the instances of an object, by pushing each of their json value to one global variable.

    For example like this: json1/json2/json3/

    The reason I'm doing this instead of simply using the savegame feature is because I have an event that deletes the json value of an instance when it contains a certain instance variable.

    For example if a sprite has an instance variable 'Delete' set to true, that will be shown in its json value and by using the find() expression I can delete all json values that contains that.

    Which is what I tried:

    'TaskCardsSave' is the global variable and "359499435322149" is the instance variable value I'm looking for.

    In theory, it will look at each of the json values and check the value of the instance variable. If it is empty, it remains. If it contains something, the whole json value and the "/" attached after it gets replaced to "".

    But for some reason all the other "/" in the global variable gets deleted as well, which makes it unable to be read.

    e.g.)

    What's supposed to happen: json1/json2/json3/ -> json1/json3/

    What actually happens: json1/json2/json3/ -> json1json3

    need help plz

  • Let's get log of the string that will be replaced by using Browser.Log

    You can remove the &"/" in replace string and replace one more time "//" with "/".

  • Thanks! Your solution worked :)

    But I don't get what mean by 'Browser.Log'? Is it useful for fixing bugs?

    And also do you have any idea why the problem occurred?

  • Browser Log help me a lot when I need debug anything.

    You add Browser plugin and then you display the log when pressing F12 in runtime.

    You can know the conditions/actions correct or not.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • And with your condition find, you can try with:

    If tokenat(TaskCardsSave,loopindex,"/")=X, then do action.

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