Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Working with save names

Using the example from docs, I can set a var as a save file name, like:
(save-game: $playerName)
Ok. But let's say my save is:
(save-game:"Slot A", $playerName +","+ $day + "days , LVL " + $playerLevel)
...where vars are obviously a day (from my calendar system), and player level.

Using:
(if: (savedgames:) contains "Slot A")[(print: (saved-games:)'s "Slot A")]
...it could result in "Slot A, John, 15 days, LVL 10".

Any chance to break this with Javascript or something? So I can maybe build a table and offer load options in a more friendly way like:
<table>
  <tr>
    <th>Slot</th>
    <th>Name</th>
    <th>Days</th>
    <th>Level</th>
  </tr>
  <tr>
    <td>A</td>
    <td>John</td>
    <td>15</td>
    <td>101</td>
  </tr>
  <tr>
    <td>B</td>
    <td>Mary</td>
    <td>250</td>
    <td>1250</td>
  </tr>
</table>
The table is just an idea. The main point is: how to break the save name in parts?

Comments

  • Irony is: hours spent trying and just after ask, find a way with str.split. I just need to adjust the format of my save files to:
    (save-game:"Slot A", $playerName +" "+ $day + " " + $playerLevel)
    
    Then:
    (set: $save_name to ((saved-games:)'s "Slot A").split(" ")[0])
    
    gives the $playerName, then a "split(" ")[1] will get the $day and so on.

    Other approaches are welcome anyway.
  • Nice one. I always find it annoying when you answer your own question, and you can't accept your own answer, so if you want to just use this comment as the accepted answer and outsmart the system, that's fine!
  • Sadly I forgot to publish it as "question"; it's marked as "discussion" so I can't choose a best answer...
Sign In or Register to comment.