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

Call a python function with binary


Yiv

Question

Dear community,

 

I have done a small gui (for testing) and I have a function inside:

def UpdateRK(self, val):
	self.rklable.SetText(val)

I also added a packet which is sent from server and received by binary and I want to add inside the receive function a call of this python function with one argument (string).

 

How can I mange it?

 

Regards

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0
  • Premium

1. Open PythonPlayerModule.cpp and add this to the static PyMethodDef s_methods[]:

{ "GetRK",						playerGetRK,						METH_VARARGS },

2. Now still in PythonPlayerModule.cpp add this:

PyObject * playerGetRK(PyObject* poSelf, PyObject* poArgs)
{
	return Py_BuildValue("i", 15);
}

Add this to your py:

		def GetRKValue(self):
			return player.GetRK()
  • Love 3
Link to comment
Share on other sites

  • 0
  • Premium

You can easily call a function from binary:

PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "UpdateRK", Py_BuildValue("(i)", 15));

UpdateRK - Name of your event
(i)The Py_BuildValue() Function
15 - Value what you want to push (Sure you can use variables too)
 
Example with a variable:

int pushThis = 15;
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "UpdateRK", Py_BuildValue("(i)", pushThis));
  • Love 1
Link to comment
Share on other sites

  • 0
  • Premium

You can pass the value to that py or just use constInfo. Example:

 

1. Make a new variable in constInfo and name it to RKvalue

2. Paste this to your py:

	def OnUpdate(self):
		if not self.rklable.GetText() == str(constInfo.RKvalue):
			self.rklable.SetText(constInfo.RKvalue)
Add this function to game.py:

def UpdateRK(self, val):
    constInfo.RKvalue = val
  • Love 1
Link to comment
Share on other sites

  • 0

No, I mean that this function takes the value of a variable in Source. I saw something like "player.GetAlignmentData()" in uicharacter.py but I don't know how I should return the variable.

 

Regards

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.