What's up, RMers? - Printable Version +- Save-Point (https://www.save-point.org) +-- Forum: Games Development (https://www.save-point.org/forum-4.html) +--- Forum: Development Discussion (https://www.save-point.org/forum-17.html) +--- Thread: What's up, RMers? (/thread-395.html) Pages:
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
RE: What's up, RMers? - kyonides - 05-01-2018 Well, I have been busy with the compilation of several custom Ruby classes into a single source file written in C. It already includes scripts like the BaseObject, BasicSprite, KChest, and Door classes, plus the Klear, Map, Load and KUnits modules. I discovered there aren't as many shortcuts as in plain Ruby code, not that they don't exist at all, but some macros and functions are quite cryptic... RE: What's up, RMers? - kyonides - 05-12-2018 I have continued developing my KUnits Ruby C extension, I added more methods, iterators and other stuff, plus one or two new classes, it's going pretty fine, but I can only compile it n Linux (specifically Kubuntu Bionic 18.04 LTS) because I have no free C compiler for Windows (8.1). I also went through some serious headaches while trying to define a block in Ruby C, but I got an iterator to do the job in a couple of methods, but I still wonder how I can do it in C without depending on the function call for Ruby methods... RE: What's up, RMers? - Steel Beast 6Beets - 05-17-2018 I admit I'm illiterate when it comes to programing languages so may I ask how does Ruby compare to other languages such a C++ and PHP? RE: What's up, RMers? - DerVVulfman - 05-18-2018 I picked up an idiot's guide to C++. Funny read, though I strayed away from studying it because of other issues. Still, I see parallels between it and Ruby, particularly in structure. Methods holding classes holding methods (defs)... and other thingies. I cannot say the same for php. Totally different in an html sorta way. RE: What's up, RMers? - kyonides - 05-18-2018 C is not modular but you don't necessarily need to type every single thing whenever you're using Ruby C, I mean, some default functions that resemble Ruby methods can just be referenced by calling them provided you entered all required arguments... I suspect Ruby'$s mkmf and make fill it up by replacing calls with actual code. At least that's why I think that happens if you call the Ruby C initialize class instance function, a hidden initialize method intermediate step taken care of by Ruby whenever you call the YourClass.new method... RE: What's up, RMers? - DerVVulfman - 05-18-2018 C++ is modular, just as Ruby. Though not many code using the 'module' structure in Ruby (which is the largest of the structures in C++ and Ruby), we do use the Class structure (the second largest) and fill them with methods (or functions... your choice of names ). Modules hold Classes. Classes hold methods (defs). Methods hold your individual routines... can also be called functions. Some key method names are mirrored between C++ and Ruby. Both require the 'main' method which acts as the actual engine, running your code. And the initialize method is used for housekeeping, setting up values that are processed by your code. Insofar as the initialize method within Ruby, it does exist for every class. Yep, even if you see one of the default classes like 'Scene_Battle' not having an initialize method, it does exist. And you can use the 'alias' method to prove it. The Alias method in Ruby allows you to rename a method (aka 'alias') to some other name allowing you to create a new method of the same name. This allows you to add code to a method. A cool little trick added into Ruby. Code: #============================================================================== If the Scene_Battle class did not have an initialize method, this would not function. Just as C++ has initialize methods, Ruby does by default. RE: What's up, RMers? - kyonides - 05-18-2018 Well, wulfo, that's because the new and initialize methods are included in Ruby C by default! Yeah, if you don't supply one for your class, Ruby will do that for you by making an empty initialize method call automatically. Whenever you define your initialize method, it stops calling its default method and executes yours instead, mainly because it's the last initialize method created for that specific class; it would call the third one in case you ever decided to overwrite it and skip the others by default. (Ruby 1.9 included in VX Ace lets you even include a hash parameter via syntatic sugar by defining its key value pairs like this: key: value, mykey: myvalue . It will later one convert it to the typical :key => value syntax anyway, but it lets you smoothly define your hash in no time.) RE: What's up, RMers? - Steel Beast 6Beets - 05-19-2018 Thanks for the answers. Really interesting stuff. Maybe I ought to learn Ruby so I can work on my own scripts or just edit existent ones. On an unrelated note, what's the easiest way to program events that have one in a determinate number of chances of taking place? Like for example I want a event to have a 1 in a 10 chances of appearing when entering a map? RE: What's up, RMers? - DerVVulfman - 05-19-2018 No problem. Given the similarities between the two, you could jump from Ruby to C++ after some practice. Oh, and I should point out that default initialize methods do exist within C++ programming as well, likely what Ruby's default initialize is based upon. The creation of automatic, static, or thread-local variables is thus made possible without such a method being added into the code, sloppy though that may be. Oh, I've done some studying of constructors and destructors in C++. Destructors are akin to the 'dispose' method we make, and there are default dispose and destructor methods. RE: What's up, RMers? - DerVVulfman - 06-03-2018 Okay......... if Ruby has a 'Time' class that allows you to run tests down to the millisecond, and the Time class is accurate and based on your own system rather than an arbitrary counter..... .... Why hasn't anyone though about replacing the WAIT system in any RPGMaker system which relies on the counter-system frame with an accurate Millisecond Time system? |