HailHell Posted January 13, 2015 Share Posted January 13, 2015 So in python i can write: g = 'hey there number'h = 1print("%s, %d" % (g, h)) how do i do that in papyrus?i basically need this - debug.notification('you killed this enemy an X number of times') Link to comment Share on other sites More sharing options...
jaxonz Posted January 14, 2015 Share Posted January 14, 2015 Natively?newstring = oldstringprefix + iValue + oldstringsuffix I ended up writing a string substitution script that would do the trick. Scriptname JaxonzStringUtil {string manipulation utility} import StringUtil import Debug String Function StringSubst (String sOriginal, String sFind, String sReplace) global ;replace all occurrances of sFind in sOriginal with sReplace int iFoundLocation int iFindLen = GetLength(sFind) int iReplaceLen = GetLength(sReplace) int iFindReplaceLenDiff = iReplaceLen - iFindLen iFoundLocation = Find(sOriginal, sFind, iFoundLocation) While iFoundLocation > -1 if iFoundLocation == 0 ;a little weirdness here because asking Substring to return 0 length actually returns entire to string end sOriginal = sReplace + Substring(sOriginal, iFoundLocation + iFindLen) Else sOriginal = Substring(sOriginal, 0, iFoundLocation) + sReplace + Substring(sOriginal, iFoundLocation + iFindLen) EndIf iFoundLocation = Find(sOriginal, sFind, iFoundLocation + iFindReplaceLenDiff) EndWhile return sOriginal EndFunction That way you could just do:Notification(StringSubst("You have # arrows left", "#", iNumArrows) Would be great if we had a C version of this in StringUtil. It would be a simple passthrough to the native function and much faster. Hope that helps. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 14, 2015 Share Posted January 14, 2015 That sure looks complicated.... Glad I have no need to do that. @HailHellAssuming you already have an integer or float that tracks the # killed...For the example we'll call that variable NumKilled. Debug.Notification("You have killed this enemy "+NumKilled+" times.") Link to comment Share on other sites More sharing options...
HailHell Posted January 14, 2015 Author Share Posted January 14, 2015 thanks! wrote the same thing lol but i added spaces next to the var, thats why it didn't work. Link to comment Share on other sites More sharing options...
elezraita Posted January 14, 2015 Share Posted January 14, 2015 Hah, I was just thinking about asking this very question. Nice to know I'm not the only one. Link to comment Share on other sites More sharing options...
lofgren Posted January 19, 2015 Share Posted January 19, 2015 If you're going to be reusing the same text and only want to change the numerical value, you can use message.show(Number) http://www.creationkit.com/Show_-_Message And format the message according to the flags on that page. In your case it would look like: "You killed this enemy %.0f times." Preferable in my opinion to putting the string in your script. Link to comment Share on other sites More sharing options...
Recommended Posts