Jump to content

[LE] Quick Questions, Quick Answers


Recommended Posts

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

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
EndFunction

EDIT: 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 by Mornedil
Link to comment
Share on other sites

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

 

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
EndFunction

EDIT: 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

 

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

 

 

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

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 by Mornedil
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...