How to initiate Python files in AlcScript?

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

Re: How to initiate Python files in AlcScript?

Postby Egon » Tue Nov 23, 2010 5:07 am

D'Lanor wrote:You have commented out the ptAttribResponder line. I highly doubt Python could accept a notification from a responder it does not know about.

????
As I understand
Code: Select all
respSound = ptAttribResponder(1, 'Resp: Play sound')

Is nothing more than retriving first parameter given to pymod in AlcScript and assignin it to global variable.
As You can see: I don't use respSound, and wrtie notyfication whenether OnNotify is being lanched, so commenting this line should not change anything, becouse it's only initiate variable which is not used (or am I wrong?).

Anyway, just to be sure: I uncomented it, redone pak file and got the same result.
Egon #2052375
Who You gonna call? Guild of Doorcallers! #5356672
Eder Tsogal/Delin Marathon
Image
User avatar
Egon
 
Posts: 284
Joined: Fri Nov 16, 2007 9:45 pm

Re: How to initiate Python files in AlcScript?

Postby D'Lanor » Tue Nov 23, 2010 5:37 am

As a general rule I just do what Cyan does and try not to deviate too much from that. I don't know why it does not work for you. It does for me.

You could try the export log file and see if everything "boiled down" (as it is called there) correctly.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: How to initiate Python files in AlcScript?

Postby D'Lanor » Fri Nov 26, 2010 2:10 pm

I suddenly realize why your notification fails. In order for this to work the responder should be started through Python! *slaps head*
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: How to initiate Python files in AlcScript?

Postby Egon » Sat Nov 27, 2010 12:11 am

D'Lanor wrote:I suddenly realize why your notification fails. In order for this to work the responder should be started through Python! *slaps head*


Image
Egon #2052375
Who You gonna call? Guild of Doorcallers! #5356672
Eder Tsogal/Delin Marathon
Image
User avatar
Egon
 
Posts: 284
Joined: Fri Nov 16, 2007 9:45 pm

Re: How to initiate Python files in AlcScript?

Postby D'Lanor » Sat Nov 27, 2010 2:23 am

Sorry, I thought that was obvious. Based on the previous scripts it means:

AlcScript Show Spoiler


Python Show Spoiler


Edit: multiplayer compatible Python code
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: How to initiate Python files in AlcScript?

Postby Egon » Sat Nov 27, 2010 4:12 am

D'Lanor wrote:Sorry, I thought that was obvious.

Actually I did undesrtood it. Just didn't know how to write that in AlcScript/Python ;)

Anyway, I try to test it ASAP.
Egon #2052375
Who You gonna call? Guild of Doorcallers! #5356672
Eder Tsogal/Delin Marathon
Image
User avatar
Egon
 
Posts: 284
Joined: Fri Nov 16, 2007 9:45 pm

Re: How to initiate Python files in AlcScript?

Postby Egon » Sat Nov 27, 2010 1:13 pm

After testing:
Good news: OnNotify started to live ;)
Bad news: i'ts styll not working.

When I click my button in game "id" passed to "OnNotify" is "-1", but the "actKI.id" is equal to "1".
I tryed to launch:
Code: Select all
avatar = PtFindAvatar(events)
            respKI.run(self.key, events=events)

anyway (despite "id != actKI.id"), but nothing happends (after "respKI.run" script just moving on).

P.S.
Control question: since avatar is declared inside OnNotify as "global avatar" shouldn't actKI and respKI be also?
Egon #2052375
Who You gonna call? Guild of Doorcallers! #5356672
Eder Tsogal/Delin Marathon
Image
User avatar
Egon
 
Posts: 284
Joined: Fri Nov 16, 2007 9:45 pm

Re: How to initiate Python files in AlcScript?

Postby D'Lanor » Sun Nov 28, 2010 5:30 pm

Egon wrote:When I click my button in game "id" passed to "OnNotify" is "-1", but the "actKI.id" is equal to "1".

I don't know where that -1 id is coming from but it cannot be a parameter from the pythonfile mod. PyPRP enumerates pythonfile mod parameters in the order they appear in the Alcscript. For the script I posted the activator is written to the prp file with id 1 and the responder with id 2. In Python you must capture the activator and the responder with the same ids. These numbers are not arbitrary. They should always match the corresponding ids within the prp file.

Somehow I don't think you used my actual script (again) so I won't try to troubleshoot this.

Egon wrote:P.S.
Control question: since avatar is declared inside OnNotify as "global avatar" shouldn't actKI and respKI be also?

No. The global statement should be declared when a function changes a global variable. actKI and respKI never change since they are not variables but constants.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: How to initiate Python files in AlcScript?

Postby Egon » Wed Dec 01, 2010 10:14 am

D'Lanor wrote:Somehow I don't think you used my actual script (again) so I won't try to troubleshoot this.


Well yes, and no ;)
Of course that every time, at first, I tried Your code exactly as You have written it.
But like I sad: something always was wrong.
So I was tweeking, and testing (tweekeing, and testing, tweekeing, and testing etc.) Your code to:
a) learn priciples behind it
b) find out what I was doing wrong.

Anyway I find out what was wrong. In this code:

AlcScript Show Spoiler


In this
section Show Spoiler

It should be "parameters:" insetad of "params:"
Egon #2052375
Who You gonna call? Guild of Doorcallers! #5356672
Eder Tsogal/Delin Marathon
Image
User avatar
Egon
 
Posts: 284
Joined: Fri Nov 16, 2007 9:45 pm

Re: How to initiate Python files in AlcScript?

Postby D'Lanor » Wed Dec 01, 2010 10:33 am

Oops, I copied that from your post #5 and never noticed the error. :oops: No wonder everything after that was broken. Anyway, glad it is solved now.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron