blob: f02df2d02cc93ae1139dd2c7e8e2f0634f187304 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# Documentation That Needs to be Organized
## Class macro attr_gtk
Use the `attr_gtk` class method to help access the different variables provided via `args`:
```ruby
class Game
attr_gtk
attr_accessor :current_scene, :other_custom_attrs
def tick
end
end
$game = Game.new
def tick args
$game.args = args
$game.tick
end
```
The code above is the similar to:
```ruby
class Game
attr_accessor :args, :grid, :state, :inputs, :outputs, :gtk, :passes,
:current_scene, :other_custom_attrs
def tick
end
end
$game = Game.new
def tick args
$game.args = args
$game.grid = args.grid
$game.state = args.state
$game.outputs = args.outputs
$game.gtk = args.gtk
$game.passes = args.passes
$game.tick
end
```
## Monkey patching the runtime
You're on your own if you do this :grimacing:
```ruby
module GTK
class Runtime
alias_method :__original_tick_core__, :tick_core unless Runtime.instance_methods.include?(:__original_tick_core__)
def tick_core
__original_tick_core__
$top_level.oh @args
$top_level.god @args
$top_level.why @args
end
end
end
def tick args
end
def oh args
end
def god args
end
def why args
end
```
## MP3's to Wav converstion script:
```ruby
`ls .`.each_line.to_a.map do |l|
l = l.strip
if l.end_with? "mp3"
`ffmpeg -i #{l} -acodec pcm_s16le -ar 44100 prep-#{l.split(".")[0]}.wav`
`ffmpeg -y -i prep-#{l.split(".")[0]}.wav -f wav -bitexact -acodec pcm_s16le -ar 44100 -ac 1 #{l.split(".")[0]}.wav`
end
end
```
|