Lauriel Posted January 25, 2020 Share Posted January 25, 2020 What I thought would be easy ... well, that's just never the case, is it. How would I go about concatenating a literal string with a string from a .tra file. Like: myNewString = ~I say 'tomato' but you say ~ + @900000 I tried the caret (^), but that's just for 2 literals. I tried PLUS, I tried the plus sign, I tried... I don't remember everything I tried. Help? Quote Link to comment
Jarno Mikkola Posted January 26, 2020 Share Posted January 26, 2020 (edited) Erhm, you are done nothing good. As in, what does this entail ? A dialog ? .d file ? A script string display ? Erhm flying eyes in a dream state... The ++ ~dialog phrase 1~ + ~dialog phrase 2~ ... can be done, but in a .d file involving CHAIN ... and those plusses are abbreviation of other functions. Edited January 26, 2020 by Jarno Mikkola Quote Link to comment
Lauriel Posted January 26, 2020 Author Share Posted January 26, 2020 1 minute ago, Jarno Mikkola said: Erhm, you are done nothing good. As in, what does this entail ? A dialog ? .d file ? A script string display ? Erhm flying eyes in a dream state... The ++ (dialog phrase) + (dialog phrase) ... can be done, but in a .d file involving CHAIN ... This is in a .tp2 file that inserts proper and upper case player1 pronouns into tokentxt 2da file and is used to build the line that is inserted into the table, allowing for multiple languages so it can be used in dialogues like: ~my dialogue line <UPPER_LORDLADY>~ Quote Link to comment
grodrigues Posted January 26, 2020 Share Posted January 26, 2020 (edited) First, you have to get the text corresponding to the tra reference -- there is a piece of black magic hackery (e.g. I use, but I do not really grok it) in IR to do this. Second, you have to concatenate the two strings. You would imagine weidu had a function for this: it does not (or if it does I have not found it). You have to sum the lengths of the two strings, create a buffer of that size, then WRITE_EVALUATED_ASCII the strings into it. Not difficult but... sigh. Edited January 26, 2020 by grodrigues Typos Quote Link to comment
Lauriel Posted January 26, 2020 Author Share Posted January 26, 2020 I think I understand. Thank you for the idea @grodrigues! I'll try it out. Quote Link to comment
grodrigues Posted January 26, 2020 Share Posted January 26, 2020 (edited) Wait, there is a better solution (I knew there had to be). Check the docs on SPRINTF (if you have coded in C this should be familiar) and use "%s%s" with the two variables as arguments. Do not forget to change the tra ref into text -- the code for this is in Item Revisions somewhere. If you can't find it, I have stolen it for my mods and can put it in here. Edited January 26, 2020 by grodrigues Quote Link to comment
Lauriel Posted January 26, 2020 Author Share Posted January 26, 2020 Ahh, I vaguely remember SPRINTF. It's been a couple decade.... I would never have thought of that. 4 minutes ago, grodrigues said: Do not forget to change the tra ref into text -- the code for this is in Item Revisions somewhere. If you can't find it, I have stolen it for my mods and can put it in here. And please, yes, share, please If you can find it. I just want to be able to share this with folks and move on to my actual mod. LOL Quote Link to comment
subtledoctor Posted January 26, 2020 Share Posted January 26, 2020 Something like: SPRINT last_text @3000 // ~world~ SPRINT EVAL whole_text ~hello %last_text%!~ PRINT ~%whole_text%~ // hello world! Maybe. Quote Link to comment
Lauriel Posted January 26, 2020 Author Share Posted January 26, 2020 1 minute ago, subtledoctor said: Something like: SPRINT last_text @3000 // ~world~ SPRINT EVAL whole_text ~hello %last_text%!~ PRINT ~%whole_text%~ // hello world! Maybe. I'll try it Quote Link to comment
Lauriel Posted January 26, 2020 Author Share Posted January 26, 2020 It worked! Thank you so much @Grammarsalad and @grodrigues!! I think one of the joys of doing this stuff is how good it feels to finally find the solution to a hair-pulling frustration. Thank you again! Quote Link to comment
subtledoctor Posted January 26, 2020 Share Posted January 26, 2020 Was going to say, you could also inline a text file, copy it to a workspace directory, and then APPEND_OUTER lines of text to it. (That adds a line break though.) I do that in several mods. It depends on precisely what you want to achieve. Quote Link to comment
subtledoctor Posted January 26, 2020 Share Posted January 26, 2020 I missed this: 2 hours ago, Lauriel said: I tried the caret (^), but that's just for 2 literals. If you put the .tra ref into a variable like I did with %last_text% above, then use the caret with the variable, I bet it would work. Quote Link to comment
Lauriel Posted January 26, 2020 Author Share Posted January 26, 2020 2 minutes ago, subtledoctor said: Was going to say, you could also inline a text file, copy it to a workspace directory, and then APPEND_OUTER lines of text to it. (That adds a line break though.) I do that in several mods. It depends on precisely what you want to achieve. Oh my goodness! What we will do to bash Weidu over the head to let us do what we want to do! LOL Quote Link to comment
Lauriel Posted January 26, 2020 Author Share Posted January 26, 2020 Just now, subtledoctor said: I missed this: If you put the .tra ref into a variable like I did with %last_text% above, then use the caret with the variable, I bet it would work. I would have bet it would have too, but it didn't. Quote Link to comment
Lauriel Posted January 26, 2020 Author Share Posted January 26, 2020 Just now, Lauriel said: I would have bet it would have too, but it didn't. Not saying I didn't screw something up, but I couldn't get the caret to work in any shape or form with a string built from the tra file. Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.