cdcooley Posted July 10, 2016 Share Posted July 10, 2016 How do I concatenate a float into a string and only displaying 2 decimal points?For example: float pi = 3.14 Debug.Notification("Pi is equal to " + pi)And then rather than the string outputting "Pi is equal to 3.1400000" it would only be "Pi is equal to 3.14"The developers expect you to use messages instead of Debug.Notification. If you really need to do it you have to format it yourself. Here's a basic function to convert float values to an appropriately rounded string representation. You can only get 6-7 digits of accuracy (total with digits before and after the decimal point) from a float value so choosing a precision too large will give strange results. string Function RoundAsString(float number, int precision) {Usage: Debug.Notification("Pi is approximately " + RoundAsString(3.141592, 4)) ; shows 3.1416} ; only 7 significant digits are valid in total (both before and after the decimal point) string result = number as int if precision > 0 result += "." number = number - (number as int) while precision > 0 precision -= 1 number *= 10 endwhile result += (number + 0.5) as int endif return result EndFunction Link to comment Share on other sites More sharing options...
Mornedil Posted July 10, 2016 Share Posted July 10, 2016 (edited) put it in a message and use the format here: http://www.creationkit.com/index.php?title=Show_-_Message#Notes I'm using it together with this code example to display a notification when the mod version updates, so I think a message might annoy the player I decided to multiply the decimal by 100 and turn it into an int, and it worked :smile:I might as well share the code, since it could be useful for any mod displaying the version number: Function ShowVersion(float fVersion) int whole = Math.Floor(fVersion) int decimal = Math.Floor((fVersion - whole) * 100) If( decimal < 10 ) Debug.Notification("MOD NAME version " + whole+".0"+decimal + " installed") Else Debug.Notification("MOD NAME version " + whole+"."+decimal + " installed") EndIf EndFunctionEDIT: Sorry cdcooley, I didn't see your anwer before I experimented it out myself, I was updating the previous page for replies. thanks though! I learned a lot from your post, it's a more versatile way of doing it that can be re-used for different things as well :> Edited July 10, 2016 by Mornedil Link to comment Share on other sites More sharing options...
iloathenexusmods Posted July 10, 2016 Share Posted July 10, 2016 Is there a way to quickly move a selected group of items from one cell to another, maintaining the linked refs? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted July 10, 2016 Share Posted July 10, 2016 Is there a way to quickly move a selected group of items from one cell to another, maintaining the linked refs?I know you can select a bunch of references and copy them (Ctrl+C) but whether linked refs are maintained, I don't know. You'd have to test or wait to see if someone with more experience in manipulating cell objects replies. Link to comment Share on other sites More sharing options...
lofgren Posted July 10, 2016 Share Posted July 10, 2016 put it in a message and use the format here: http://www.creationkit.com/index.php?title=Show_-_Message#Notes I'm using it together with this code example to display a notification when the mod version updates, so I think a message might annoy the player I decided to multiply the decimal by 100 and turn it into an int, and it worked :smile:I might as well share the code, since it could be useful for any mod displaying the version number: Function ShowVersion(float fVersion) int whole = Math.Floor(fVersion) int decimal = Math.Floor((fVersion - whole) * 100) If( decimal < 10 ) Debug.Notification("MOD NAME version " + whole+".0"+decimal + " installed") Else Debug.Notification("MOD NAME version " + whole+"."+decimal + " installed") EndIf EndFunctionEDIT: Sorry cdcooley, I didn't see your anwer before I experimented it out myself, I was updating the previous page for replies. thanks though! I learned a lot from your post, it's a more versatile way of doing it that can be re-used for different things as well :> The player can't tell the difference between a message and debug.notification(). They look exactly the same from the player perspective. Your comment makes no sense. Link to comment Share on other sites More sharing options...
iloathenexusmods Posted July 10, 2016 Share Posted July 10, 2016 Is there a way to quickly move a selected group of items from one cell to another, maintaining the linked refs?I know you can select a bunch of references and copy them (Ctrl+C) but whether linked refs are maintained, I don't know. You'd have to test or wait to see if someone with more experience in manipulating cell objects replies. Unfortunately copying/pasting doesn't maintain the linked refs, neither does cut... I'm just trying to convert 33 BYOHPlanterContainers to BYOHPlanterNPCs, but I want those NPCs to be in a utility cell so it doesn't cause massive lag. Perhaps I'm just lazy but I really don't want to do it one-by-one again. :sad: Link to comment Share on other sites More sharing options...
Mornedil Posted July 10, 2016 Share Posted July 10, 2016 The player can't tell the difference between a message and debug.notification(). They look exactly the same from the player perspective. Your comment makes no sense. Really? I thought messages were those black boxes that pop up where you have to press OK to close them. I did not realize they could also be used as notifications. Link to comment Share on other sites More sharing options...
lofgren Posted July 10, 2016 Share Posted July 10, 2016 (edited) They are both, but that certainly explains why you would think it might be annoying. Edited July 10, 2016 by lofgren Link to comment Share on other sites More sharing options...
Feracitus Posted July 10, 2016 Share Posted July 10, 2016 (edited) . Edited July 14, 2016 by Feracitus Link to comment Share on other sites More sharing options...
Mornedil Posted July 11, 2016 Share Posted July 11, 2016 (edited) Conditional function to see if a furniture is currently being used?I can only seem to find conditions applied to actors to see if they are sitting on a furniture, but not a check on the furniture itself if it has someone occupying it Edited July 11, 2016 by Mornedil Link to comment Share on other sites More sharing options...
Recommended Posts