Jump to content
×
×
  • Create New...
  • 0

[PY]Help with my script


安冲.

Question

Hi,

I need to show the horse level in :

		self.Niveau = ui.TextLine()
		self.Niveau.SetDefaultFontName()
		self.Niveau.SetParent(self.Board)
		self.Niveau.SetPosition(257, 78)
		self.Niveau.SetText("Niveau:		NONE")
		self.Niveau.SetOutline()
		self.Niveau.Show()

How do I get and display the TextLine level horse please? I start Python.

 

 

Thanks,

 

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

In constinfo.py add this:
 

horse_level = 0

after that open game.py find this:
 

def __Horse_UpdateState(self, level, health, battery):

and add under this:
 

constInfo.horse_level = str(level)

then take this script:
 

import constInfo
self.Niveau = ui.TextLine()
self.Niveau.SetDefaultFontName()
self.Niveau.SetParent(self.Board)
self.Niveau.SetPosition(257, 78)
self.Niveau.SetText("Niveau:"+str(constInfo.horse_level))
self.Niveau.SetOutline()
self.Niveau.Show()


and you're done

  • Love 4
Link to comment
Share on other sites

  • 0

Hi, I have some questions with the script.

 

- constInfo.Py

horse_level = 0
horse_health = 0

- Game.py (ServerCommandList)

			# HORSE GUI by Kyo - ArenaPvP #
			"horsegui"				: self.__horsegui,
			"horseclose"			: self.__horseclose,
			"monter"				: self.__monter,
			"descendre"				: self.__descendre,
			##

- Game.py (part 2)

## HorseGUI - Dev by ArenaPvP (Kyo ⓒ)
	def __horsegui(self):
		self.Board = ui.BoardWithTitleBar()
		self.Board.SetSize(510, 166)
		self.Board.SetCenterPosition()
		self.Board.AddFlag("movable")
		self.Board.AddFlag("float")
		self.Board.SetTitleName("ArenaPvP - Gestion de votre cheval")
		self.Board.SetCloseEvent(self.__horseclose)
		self.Board.Show()

		self.horse_button1 = ui.Button()
		self.horse_button1.SetEvent(self.__horseclose)
		self.horse_button1.SetParent(self.Board)
		self.horse_button1.SetPosition(440, 137)
		self.horse_button1.SetUpVisual("d:/ymir work/ui/public/middle_button_01.sub")
		self.horse_button1.SetOverVisual("d:/ymir work/ui/public/middle_button_02.sub")
		self.horse_button1.SetDownVisual("d:/ymir work/ui/public/middle_button_03.sub")
		self.horse_button1.SetText("Quitter")
		self.horse_button1.Show()

		self.horse_proprio = ui.TextLine()
		self.horse_proprio.SetDefaultFontName()
		self.horse_proprio.SetParent(self.Board)
		self.horse_proprio.SetPosition(257, 65)
		self.horse_proprio.SetText("Proprietaire: " + chr.GetName())
		self.horse_proprio.Show()

		self.Niveau = ui.TextLine()
		self.Niveau.SetDefaultFontName()
		self.Niveau.SetParent(self.Board)
		self.Niveau.SetPosition(257, 78)
		self.Niveau.SetText("Niveau: "+str(constInfo.horse_level))
		self.Niveau.SetOutline()
		self.Niveau.Show()

		self.Vie = ui.TextLine()
		self.Vie.SetDefaultFontName()
		self.Vie.SetParent(self.Board)
		self.Vie.SetPosition(257, 91)
		self.Vie.SetText("Etat du cheval: "+str(constInfo.horse_health))
		self.Vie.SetOutline()
		self.Vie.Show()

		self.Vie_infos_0 = ui.TextLine()
		self.Vie_infos_0.SetDefaultFontName()
		self.Vie_infos_0.SetParent(self.Board)
		self.Vie_infos_0.SetPosition(257, 115)
		self.Vie_infos_0.SetText("0 - Votre cheval est mort")
		self.Vie_infos_0.SetOutline()
		self.Vie_infos_0.Show()

		self.Vie_infos_1 = ui.TextLine()
		self.Vie_infos_1.SetDefaultFontName()
		self.Vie_infos_1.SetParent(self.Board)
		self.Vie_infos_1.SetPosition(257, 125)
		self.Vie_infos_1.SetText("1 - Votre cheval a faim")
		self.Vie_infos_1.SetOutline()
		self.Vie_infos_1.Show()

		self.Vie_infos_2 = ui.TextLine()
		self.Vie_infos_2.SetDefaultFontName()
		self.Vie_infos_2.SetParent(self.Board)
		self.Vie_infos_2.SetPosition(257, 135)
		self.Vie_infos_2.SetText("2 - Votre cheval est en bonne sante")
		self.Vie_infos_2.SetOutline()
		self.Vie_infos_2.Show()

		self.Vie_infos_3 = ui.TextLine()
		self.Vie_infos_3.SetDefaultFontName()
		self.Vie_infos_3.SetParent(self.Board)
		self.Vie_infos_3.SetPosition(257, 145)
		self.Vie_infos_3.SetText("3 - Votre cheval est en excellente sante")
		self.Vie_infos_3.SetOutline()
		self.Vie_infos_3.Show()

		self.horse_button2 = ui.Button()
		self.horse_button2.SetEvent(self.__monter)
		self.horse_button2.SetParent(self.Board)
		self.horse_button2.SetPosition(190, 35)
		self.horse_button2.SetUpVisual("d:/ymir work/ui/public/middle_button_01.sub")
		self.horse_button2.SetOverVisual("d:/ymir work/ui/public/middle_button_02.sub")
		self.horse_button2.SetDownVisual("d:/ymir work/ui/public/middle_button_03.sub")
		self.horse_button2.SetText("Monter")
		self.horse_button2.Show()

		self.horse_button3 = ui.Button()
		self.horse_button3.SetEvent(self.__descendre)
		self.horse_button3.SetParent(self.Board)
		self.horse_button3.SetPosition(260, 35)
		self.horse_button3.SetUpVisual("d:/ymir work/ui/public/middle_button_01.sub")
		self.horse_button3.SetOverVisual("d:/ymir work/ui/public/middle_button_02.sub")
		self.horse_button3.SetDownVisual("d:/ymir work/ui/public/middle_button_03.sub")
		self.horse_button3.SetText("Descendre")
		self.horse_button3.Show()

	def __monter(self):
		net.SendChatPacket("/user_horse_ride")

	def __descendre(self):
		net.SendChatPacket("/unmount")

	def __horseclose(self):
		self.Board.Hide()
## END_OF_HORSE_GUI

Picture:

218183ArenaPvPGestion.png

I try to display an image based on the level of the horse.

0 = Square blank
1-10 = Square with an image
11-20 = Square with an image
21 + = Square with an image

However, I really do not understand how to do ..

666403carr.png

Link to comment
Share on other sites

  • 0
self.img = ui.ExpandedImageBox()
self.img.SetParent(self.Board)
if horse_level == 0:
	self.img.LoadImage("image _ path")
elif horse_level >= 1 and horse_level <= 10:
	self.img.LoadImage("image _ path")
elif horse_level >= 11 and horse_level <= 20:
	self.img.LoadImage("image _ path")
elif horse_level > 21:
	self.img.LoadImage("image _ path")
self.img.SetPosition(0,0)
self.img.Show()

I the SetPosition(0,0) just fill it with the position you want,for the square you said you need to create an image of horse and load it from LoadImage

Link to comment
Share on other sites

  • 0
self.img = ui.ExpandedImageBox()
self.img.SetParent(self.Board)
if constInfo.horse_level == 0:
    self.img.LoadImage("image _ path")
elif constInfo.horse_level >= 1 and constInfo.horse_level <= 10:
    self.img.LoadImage("image _ path")
elif constInfo.horse_level >= 11 and constInfo.horse_level <= 20:
    self.img.LoadImage("image _ path")
elif constInfo.horse_level > 21:
    self.img.LoadImage("image _ path")
self.img.SetPosition(0,0)
self.img.Show()

I forgot to add constInfo,now it's working

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


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.