Stamp renaming tutorial

  • AlphaXero
    3rd Feb 2013 Member 0 Permalink

    I was just a moment ago trying to figure out how to rename stamps, and belive I have finally struck upon the correct method (I am aware there is another post about renamins stamps, but the mothod used there does nto seem to work, or may be outdated)!

     

    It would appear, after some exprminetation, that the only 'trick; to renamign stamps is simply to make certain that [filename].stm is EXACTLY 10 characters long. I am aware there was some previous conjecture that stated that you only needed to make sure that your filename was under 10 characters, and ended with '00' before the .stm . This is not the case, and filenames that do not end in zeros will work just fine!

     

    If anyone can find any different/better information, please comment! 

  • jacob1
    3rd Feb 2013 Developer 0 Permalink
    @AlphaXero (View Post)
    they all have to be 10 characters, because they are stored in stamps.def in that format. Any 10 letter / number combination should work, maybe add 0's to the end or something.

    Also, the last 2 zeros are in case, somehow magically, you save 2 stamps in the same second. Then it ends in 01, 02, 03, until another second goes by and it can name it something else.

    I was thinking of redoing this, to allow you to name them yourself, but i'm not sure. There is always local saves for that (hold ctrl)
  • AlphaXero
    3rd Feb 2013 Member 0 Permalink

    I am just going to assume that you are a Dev/modder, as this is a bit technical.

     

    Persumeably, from what I can observe, you are saving the strings to strings.def on the same line, then simply reading them like this:

    counter = 0

    for counter < len(strings.def) /10 # note than len is something that returns the length of a sting, and we are #going to assume for the purpose of this post that string.def is actually a function returning the first line of #strings.def.

     toDisplayIngame.append(strings.def[counter:counter + 10]

     

    This is a bit rough, but it get the idea across.

     

    So here's my throught: just store a different filename on each line of stamps.def. In python, it is relativly trivial to do this with 'linecache.getlien(lineNumber)', although I am not sure if there is a lua/C/C++ equivilant. To prevent it from just loopign forever, you could have a counter, call it 'blanks', each time it reads a blank line, it ignors it and incriments 'blanks' by one. If 'blanks' exceeds a certain value, it stops reading the file. The reason for having this counter is just in case someone edits styrings.def and leaves a line or two blank. 

     

    All told, unless I am grossly misunderstanding the capabilities of Lua and how powderToy is written, it shoul dbe pretty simple to impliment this, and would allow users to rename stamps to be whatever they want, with filenames as long as they want, and should make it trivial to impliment an ingame renaming feature in teh future. 

     

    Let me know what you think! 

     

  • jacob1
    3rd Feb 2013 Developer 0 Permalink
    @AlphaXero (View Post)
    ok, that would work, I do think the format is a little old, that is actually how it was written originally so long ago. It hasn't been changed ever since, even in the rewrite to c++ from c. But that is about how the file is read currently.
    But it might be better to save it in the same JSON format powder.pref has. I'm still not sure on renaming them though, but maybe.


    And by the way, tpt is written in c/c++
  • AlphaXero
    3rd Feb 2013 Member 0 Permalink

    Sounds like a plan! 

     

    I would offer to help, but I am not very familiar with C++, although I have been meaning to get into it! Maybe I'll drop by the Dev forum later and see if I could do anything helpful.