1+ # Import the obspython module
2+ import obspython as obs
3+
4+ def script_description ():
5+ return 'This is a simple but ineffective script\n Author:\t oops\n Version:\t 0.1\n Contact:\t xxx'
6+
7+ def script_properties ():
8+ # Create a Property Set object
9+ props = obs .obs_properties_create ()
10+
11+ # Add a Script Property object that corresponds to the numberbox for indicating hours
12+ obs .obs_properties_add_int (props , 'hours' , '小时:' , 2 , 5 , 1 )
13+ return props
14+
15+ # The data variable represents the Script Settings
16+ data = None
17+
18+ def script_load (settings ):
19+ global data
20+ data = settings
21+
22+ # Read the Script Setting Item closed_time, which is the stop-time of the script
23+ closed_time = obs .obs_data_get_string (data , 'closed_time' )
24+ if closed_time :
25+ obs .script_log (obs .LOG_INFO , f'The last time the script stopped was at { closed_time } ' )
26+
27+ obs .script_log (obs .LOG_INFO , script_path ())
28+
29+ # def script_unload():
30+ # # Write the current time to the Script Setting Item closed_time as the stop-time of the script
31+ # from datetime import datetime
32+ # obs.obs_data_set_string(data, 'closed_time', datetime.now().ctime())
33+
34+ def script_update (settings ):
35+ # Read the Script Setting Item hours and display it
36+ hours = obs .obs_data_get_int (settings , 'hours' )
37+ obs .script_log (obs .LOG_INFO , f'The current hours are { hours } ' )
38+
39+ def script_save (settings ):
40+ # Write the current time to the Script Setting Item closed_time as the stop time of the script
41+ from datetime import datetime
42+ obs .obs_data_set_string (settings , 'closed_time' , datetime .now ().ctime ())
43+
44+ def script_defaults (settings ):
45+ # Set the default value of the Setting Item hours to 3
46+ obs .obs_data_set_default_int (settings , 'hours' , 3 )
47+
48+ # def script_tick(seconds):
49+ # obs.script_log(obs.LOG_INFO, f'{seconds} OBS is about to become unresponsive!!!')
50+
51+ # Script Timer callback function welcome
52+ def welcome ():
53+ obs .script_log (obs .LOG_INFO , f'{ type (obs .timer_add )} ' )
54+ obs .script_log (obs .LOG_INFO , 'This is a callback function that is only called once' )
55+ # Remove the Script Timer corresponding to welcome
56+ obs .remove_current_callback ()
57+
58+ # Add a Script Timer with a 3-second interval
59+ obs .timer_add (welcome , 3000 )
0 commit comments