How do I get value between characters and loop

0 favourites
  • 4 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • With the help of R0J0hound I made a script that reads SVG polygon coordinates and creates a terrain.

    Currently it reads it from a .txt file (using tokenat() and creating loop for each shape) which has to be manually populated with information. I was wondering if this step can be eliminated and improve the workflow. However to read directly from the SVG file it needs to get the coordinates in between characters and create a loop.

    For example this is an SVG code

    <polygon class="st0" points="1520.4,280.6 1456.7,280.6 1456.7,339.7 1527.7,339.7 1527.7,357.4 1435.5,357.4 1435.5,193.5 
    	1524.1,193.5 1524.1,211.3 1456.7,211.3 1456.7,263.1 1520.4,263.1 1520.4,280.6 1520.4,280.6 1520.4,280.6 "/>
    <polygon class="st0" points="1550.3,345 1550.6,341.9 1551.4,339 1552.7,336.4 1554.4,334.2 1556.5,332.4 1558.9,331.1 
    	1561.7,330.2 1564.7,329.9 1567.8,330.2 1570.6,331.1 1573,332.4 1575.1,334.2 1576.8,336.4 1578,339 1578.7,341.9 1579,345 
    	1578.7,348.1 1578,351 1576.8,353.5 1575.1,355.8 1573,357.6 1570.6,358.9 1567.8,359.8 1564.7,360.1 1561.6,359.8 1558.8,358.9 
    	1556.4,357.6 1554.3,355.8 1552.6,353.5 1551.3,351 1550.6,348.1 1550.3,345 1550.3,345 1550.3,345 "/>
    <polygon class="st0" points="1556.4,310.2 1553,193.5 1576.3,193.5 1572.9,310.2 1556.4,310.2 1556.4,310.2 1556.4,310.2 "/>[/code:572xu8az]
    
    So it needs to - for each <polygon> get coordinates between points=" and ", and create for each loop.
    
    My question is how to get the value between points=" and "? Is there a system function that can do that (something like PHP's preg_match() maybe)?
  • tokenat()

    https://www.scirra.com/manual/126/system-expressions

    Use nested tokens, first one would be for polygon, second one would be for points, third one for commas.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You probably should be able to use the xml plugin to do this. Take a look at it, it has methods to loop over tags and such.

  • I'm a huge dum-dum... there're regular expression functions - RegexMatchAt(), RegexMatchCount(), etc.

    oosyrag tokenat() uses separator to create keys, I need to get the value in between given characters (what regular expressions do)

    R0J0hound I checked it out, but I'm not quite sure how to work with XML files and this plugin in particular. I think the functions I mentioned above would work in this case.

    Thanks for the suggestions!

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