Jump to content

More accurate bonus values


Recommended Posts

Hello, can someone tell me how to make bonuses values eg in the form of "14.25%" instead of only "14%"? I have this character bonus window:
in the uicharacter.py file it looks like this:

self.GetChild("strzal_value").SetText(str(player.GetStatus(74))+"%")

And in the characterwindow.py file like this:

						{
							"name" : "strzaly",
							"type" : "text",
							
							"x" : 20, "y" : 30+125,
							
							"text" : "Odporność na Strzały:",
							
							"children" :
							(
								{
									"name" : "slot",
									"type" : "slotbar",
									
									"x" : 200, "y" : 0,
									
									"width" : 28, "height" : 18,
									
									"children":
									(
										{
											"name" : "strzal_value",
											"type" : "text",
											
											"x" : 0, "y" : 0,
											
											"text" : "0%",
											"all_align" : "center",
										},	
									),
								},
							),	
						},

 

Link to comment
Share on other sites

You must first change the data type used in the attributes to support floating point values
for example: "float"
If I remember correctly, these values are expressed in "long", without this the effect will be only visual.
You'll have fun with the code.

To express a floating point value in python, just use the appropriate representation.
 

>>> val=14.246
>>> print(val)
14.246
>>> print("%.2f" % val)
14.25


About Floating Point Arithmetic (python 2.7) 

You should handle it without too much trouble.
GLHF

  • Confused 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 13

      Metin2 Closed Beta Content (2003-2004)

    2. 25

      [SRC] Metin2 on LINUX - The Old Metin2 Project

    3. 2

      United/Club/Midgard serverfiles?

    4. 13

      Metin2 Closed Beta Content (2003-2004)

    5. 13

      Metin2 Closed Beta Content (2003-2004)

  • Recently Browsing

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

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.