Automatically and repeatedly executing a script

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

Re: Automatically and repeatedly executing a script

Postby Jojon » Thu Mar 14, 2013 12:58 pm

For the fog colour changes, that make up the day/night cycle in Rell-Too, I just stuck the timer in the age's main python file, but I don't know how kosher that is... :7
Jojon
 
Posts: 1116
Joined: Sun Sep 30, 2007 5:49 am

Re: Automatically and repeatedly executing a script

Postby Mystler » Thu Mar 14, 2013 1:10 pm

Yeah, that's most likely the easiest way. Modify the existing Python files instead of trying to create a new Python File Mod.
User avatar
Mystler
 
Posts: 116
Joined: Sun Mar 22, 2009 4:55 am
Location: Germany

Re: Automatically and repeatedly executing a script

Postby Locutus » Fri Mar 15, 2013 3:02 am

Ooh, I can do that just like that? A good idea indeed! And if it works, I don't really care about kosher. :) We're mostly using a private shard for our machinima filming purposes, so no public servers will get harmed. :)

I suppose, since we're using internal clients, every cameraman or player who needs those changes will need the modified file for their local installation then.

The concrete application in this case is: I was trying to use the "spyroom" age (specifically the room that the telescope looks into) as a shooting location. To use greenscreen techniques, since the room has no solid floor and actors can't walk around there, I need a greenscreen (Yon) that's always in the same position, and not same distance from camera. Hence I was going to use a timer that runs every like 1/10th of a second and updates Yon from the player's position.

So I could just stick the required functions and timers in the existing Python script for the spyroom? That'd be cool.

@Jojon: Could you maybe send me your modified Python file for "Rel-too" as a reference/example?

And @Mystler: Speaking about non-solid floor. Would you happen to know if it is possible to take a PRP file, extract the 3d model information from it, load it into 3ds, make the floor solid, and get it back into the PRP? I guess that'd be quite complicated.
Locutus
 
Posts: 29
Joined: Sat Mar 09, 2013 9:41 am

Re: Automatically and repeatedly executing a script

Postby janaba » Fri Mar 15, 2013 4:05 am

Hi, Locutus ... seeing you speaking of and needing a solid floor in the Spyroom I thought you could maybe find something useful or as a reference or inspiration in 'sculp's' successful solidification of the Spyroom for offline Uru ... You can find everything, incl. the needed files and 'how to's' here ... Maybe you'll try that offline and get the idea how to adapt that to your Dirtsand ... :P
Image
User avatar
janaba
 
Posts: 918
Joined: Sun Feb 05, 2012 3:27 pm
Location: Berlin, Germany

Re: Automatically and repeatedly executing a script

Postby Locutus » Fri Mar 15, 2013 4:11 am

Thank you Janaba, I'll definitely try that! Looks like the instructions might apply to MOUL as well, since it's a matter of modifying PRP files.
Locutus
 
Posts: 29
Joined: Sat Mar 09, 2013 9:41 am

Re: Automatically and repeatedly executing a script

Postby Mystler » Fri Mar 15, 2013 12:06 pm

@Locutus: it is possible. You can get an object with prp2obj from libHSPlasma, import it in 3dsMax (or Blender), create a collision and export to a new PRP.
User avatar
Mystler
 
Posts: 116
Joined: Sun Mar 22, 2009 4:55 am
Location: Germany

Re: Automatically and repeatedly executing a script

Postby Jojon » Sat Mar 16, 2013 2:19 pm

Locutus wrote:...Could you maybe send me your modified Python file for "Rel-too" as a reference/example?
...


Here it is.

Not much to it. The timer callback is first set up in the "OnServerInitComplete" function, which is called by the game when you link into the age.
In this case it is set to 0.35 seconds and is given an ID of "1". When the timer runs out, it calls back to the class that set it up, by calling its "OnTimer" function.
Here; this function only checks the timer's ID, to see which one called back (in case you have several), calls a separate function, which performs my/your stuff (you could just as well just put that right into OnTimer, but it feels somehow tidier to separate it), and lastly sets the timer anew, to keep it going for another iteration.
Attachments
relltoo.rar
(1.85 KiB) Downloaded 356 times
Jojon
 
Posts: 1116
Joined: Sun Sep 30, 2007 5:49 am

Previous

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron