Created Text Script (markdown)
commited
commit
e04ddb70279c301b116534182f230c3941524521
... | ... | @@ -0,0 +1,388 @@ |
1 | A Pseudo-Coding Language Format Developed by (**@Isaglish** , me **@JP16D** , **@Qma** and **@Vex Ave**) base from Fancade's Coding. |
|
2 | ||
3 | (*Note: this is not a real or existent coding language as the word "Pseudo" declares this is just a code format that can be used in scripting discussions) |
|
4 | ||
5 | ||
6 | This Format will be a basis when sharing or suggesting some codes and code solutions during script discussions. Take this as an easier way to share or suggest a code program instead doing it in fancade and go back to fancade server #scripting channel. Well in case of people that couldn't understand this just do the thing in fancade , screenshot it and share it to them. |
|
7 | ||
8 | Here is the documentation of what we have done so far ... |
|
9 | ||
10 | ## Introduction |
|
11 | This format is based on C# syntax. Most of things are simplified for the better understanding. |
|
12 | ||
13 | As you know, Fancade's script blocks are located in different folders. To make it easier to understand, what do you mean, use their names as in the example below. It's not necessary and takes such a time to write, but please pay attention to it when you're explaining script to the new user or there are namesake custom blocks. |
|
14 | ||
15 | Following the C# syntax, let's imagine that each folder is a separate class with its own fields and functions. So, to represent Get Frame block, you need to type `Game.Current_Frame`. Again, it's not necessary, just `Current_Frame` is fine too. |
|
16 | ||
17 | All the cases: |
|
18 | ``` |
|
19 | //If block has yellow wires, add () at the end of the name |
|
20 | Game.Win(); |
|
21 | Sound.Play_Sound(); |
|
22 | ||
23 | //If block has inputs, count them and their type in the brackets |
|
24 | Objects.Set_Position(obj object, vec position, rot rotation); |
|
25 | ||
26 | //If block has more than one output. Get position as example |
|
27 | Objects.Get_Position(target_object).position; |
|
28 | ||
29 | //Math block counts like this, except the basic ones listed below |
|
30 | vec result = Math.Line_vs_Plane(L_from, L_to, P_normal, P_point); |
|
31 | ||
32 | //If block has only outputs, don't do anything |
|
33 | num frame = Game.Get_Frame; |
|
34 | } |
|
35 | ``` |
|
36 | ||
37 | ## _______________________________________________________________ |
|
38 | ### Basics |
|
39 | ## _____________________________ |
|
40 | **Value Types** : |
|
41 | ``` |
|
42 | Num varName = 0; |
|
43 | Tru varName = true/false; |
|
44 | Vec varName(x , y , z); |
|
45 | Rot varName(x , y , z); |
|
46 | Obj varName = Object; |
|
47 | ||
48 | //Any variable can be used as list. Format: varName[index] |
|
49 | ``` |
|
50 | ## _____________________________ |
|
51 | ### Basic Math Operators |
|
52 | ||
53 | ``` |
|
54 | //Add Numbers |
|
55 | 2 + 2 |
|
56 | ||
57 | //Subtract Numbers |
|
58 | 2 - 2 |
|
59 | ||
60 | //Multiply Numbers |
|
61 | 2 * 2 |
|
62 | ||
63 | //Divide Numbers |
|
64 | 2 / 2 |
|
65 | ||
66 | //Power |
|
67 | 2 ^ 2 |
|
68 | ||
69 | //Modulo |
|
70 | 2 % 2 |
|
71 | ||
72 | //Increase |
|
73 | num++ |
|
74 | ||
75 | //Decrease |
|
76 | num-- |
|
77 | ``` |
|
78 | ## _____________________________ |
|
79 | ### Basic Boolean Operators |
|
80 | ``` |
|
81 | //Boolean logic (AND, OR, NOT) |
|
82 | ||
83 | tru smart = ((NOT dumb) AND (has_brain)) OR already_smart; |
|
84 | ||
85 | //Math (Greater, Less, Equal) |
|
86 | ||
87 | tru equal = a == b; |
|
88 | ||
89 | tru greater = a > b; |
|
90 | ||
91 | tru less = a < b; |
|
92 | ``` |
|
93 | ||
94 | ## _______________________________________________________________ |
|
95 | ### Game |
|
96 | ``` |
|
97 | Game.Win(); |
|
98 | ||
99 | Game.Lose(); |
|
100 | ||
101 | Game.Set_Score(num Score); |
|
102 | ||
103 | Game.Set_Camera(vec Position, rot Rotation, num Distance); |
|
104 | ||
105 | Game.Set_Light(vec Position, rot Rotation); |
|
106 | ||
107 | Game.Screen_Size.x |
|
108 | Game.Screen_Size.y |
|
109 | ||
110 | Game.Accelerometer |
|
111 | ||
112 | Game.Current_Frame |
|
113 | ``` |
|
114 | ||
115 | ## _______________________________________________________________ |
|
116 | ### Objects |
|
117 | ``` |
|
118 | Objects.Get_Position(obj).Position |
|
119 | Objects.Get_Position(obj).Rotation |
|
120 | ||
121 | Objects.Set_Position(obj Object, vec position, rot Rotation); |
|
122 | ||
123 | //alternative |
|
124 | //get |
|
125 | vec = obj.position; |
|
126 | //set |
|
127 | obj.position = vec; |
|
128 | ||
129 | Objects.Raycast(vec, vec).Hit? |
|
130 | Objects.Raycast(vec, vec).Hit_Pos |
|
131 | Objects.Raycast(vec, vec).Hit_Obj |
|
132 | ||
133 | Objects.Get_Size(obj Object).Min |
|
134 | Objects.Get_Size(obj Object).Max |
|
135 | ||
136 | //alternative |
|
137 | vec = obj.size.min; |
|
138 | ||
139 | Objects.Create_Object(obj Object); |
|
140 | ||
141 | Objects.Destroy_Object(obj Object); |
|
142 | ``` |
|
143 | ||
144 | ## _______________________________________________________________ |
|
145 | ### Sound |
|
146 | ``` |
|
147 | Sound.Play_Sound(num Volume, num Pitch); |
|
148 | Sound.Play_Sound.Channel |
|
149 | ||
150 | Sound.Stop_Channel(num Channel); |
|
151 | ||
152 | Sound.Volume_Pitch(num Channel, num Volume, num Pitch); |
|
153 | ``` |
|
154 | ||
155 | ## _______________________________________________________________ |
|
156 | ### Physics |
|
157 | ``` |
|
158 | //I regret doing this, sorry |
|
159 | ``` |
|
160 | ||
161 | ||
162 | ## _______________________________________________________________ |
|
163 | ### Control |
|
164 | ``` |
|
165 | //Basic if operator |
|
166 | If (condition) { |
|
167 | function_true; |
|
168 | } else { |
|
169 | function_false; |
|
170 | } |
|
171 | ||
172 | //Or ternary |
|
173 | condition ? true : false; |
|
174 | //Note: Fancade doesn't have ternary operator at the moment of writing. This is just a shortcut for scripting discussions |
|
175 | ||
176 | Loop(num start = 0, num end = 0) { |
|
177 | //Output |
|
178 | self.Counter |
|
179 | } |
|
180 | ||
181 | Touch_Sensor() { |
|
182 | //Outputs |
|
183 | self.Screen_X |
|
184 | self.Screen_Y |
|
185 | } |
|
186 | ||
187 | Collision(obj Physical_Object) { |
|
188 | //Outputs |
|
189 | self.Second_Object |
|
190 | self.Normal |
|
191 | self.Impulse |
|
192 | } |
|
193 | ||
194 | Swipe_Sensor() { |
|
195 | //Output |
|
196 | self.Direction |
|
197 | } |
|
198 | ||
199 | BoxArt() { |
|
200 | } |
|
201 | ||
202 | PlaySensor() { |
|
203 | } |
|
204 | ||
205 | LateUpdate() { |
|
206 | } |
|
207 | ``` |
|
208 | ||
209 | ## _______________________________________________________________ |
|
210 | ### Math |
|
211 | ``` |
|
212 | Math.Negate(num Num) |
|
213 | ||
214 | Math.Inverse(rot Rot) |
|
215 | ||
216 | vec.Scale(num Num) |
|
217 | ||
218 | vec.Rotate(rot Rot) |
|
219 | ||
220 | rot.Combine(rot Rot2) |
|
221 | ||
222 | Math.Random(num Min = 0, num Max = 1) |
|
223 | ||
224 | Math.Random_Seed(num Seed); |
|
225 | ||
226 | Math.Min(num Num1, num Num2) |
|
227 | ||
228 | Math.Max(num Num1, num Num2) |
|
229 | ||
230 | Math.Sin(num Num) |
|
231 | ||
232 | Math.Cos(num Num) |
|
233 | ||
234 | Math.Round(num Num) |
|
235 | ||
236 | Math.Floor(num Num) |
|
237 | ||
238 | Math.Ceiling(num Num) |
|
239 | ||
240 | Math.Absolute(num Num) |
|
241 | ||
242 | Math.Logarithm(num Number, num Base) |
|
243 | ||
244 | num vec.x |
|
245 | num vec.y |
|
246 | num vec.z |
|
247 | ||
248 | vec.Normalize() |
|
249 | ||
250 | vec.Dot(vec Vector) |
|
251 | ||
252 | vec.Cross(vec Vector) |
|
253 | ||
254 | num rot.x |
|
255 | num rot.y |
|
256 | num rot.z |
|
257 | ||
258 | Math.Distance(vec Vec1, vec Vec2) |
|
259 | ||
260 | LERP(rot From, rot To, num Amount) |
|
261 | ||
262 | Math.Axis_Angle(vec Axis, num Angle) |
|
263 | ||
264 | Math.Screen_To_World(num Screen_X, num Screen_Y) |
|
265 | ||
266 | Math.World_To_Screen(vec World_Pos) |
|
267 | ||
268 | Math.Line_vs_Plane(vec Line_From, vec Line_To, vec Plane_Point, vec Plane_Normal) |
|
269 | ||
270 | Math.Look_Rotation(vec Direction, vec Up) |
|
271 | ``` |
|
272 | ||
273 | ## Syntax |
|
274 | ||
275 | Ever wondered how Fanscript would look in text format? Well, you can see all references in this directory! |
|
276 | ||
277 | Keep in mind that this is a Work-In-Progress project and that all codes you see will not work if you try to write it in say Unity's C#. |
|
278 | ||
279 | ## Examples |
|
280 | Values consist of: |
|
281 | ||
282 | ```coffeescript |
|
283 | Number Age = 10 |
|
284 | Vector Position = (10, 1.51, 5) |
|
285 | Rotation Angle = {0, 90, 0} |
|
286 | Truth Hit = True |
|
287 | Object Player = MyBlocks.Player |
|
288 | ``` |
|
289 | ||
290 | For the constraints, it'll be the same inside Fancade: |
|
291 | ||
292 | ```coffeescript |
|
293 | PlaySensor() { |
|
294 | Constraint const = Physics.AddConstraint(base, part, pivot) |
|
295 | Physics.AngularLimits(const, (0, 0, 1), (0, 0, 0)) |
|
296 | Physics.AngularMotor(const, (0, 0, 90), (0, 0, 100)) |
|
297 | } |
|
298 | ``` |
|
299 | ||
300 | In total we have 7 datatypes that includes lists. |
|
301 | ||
302 | Talking about lists here is how you do them in text format: |
|
303 | ||
304 | ```coffeescript |
|
305 | # set a list variable |
|
306 | List<Vector>[0] Positions = (32.1, 5.51, -23.72) |
|
307 | ||
308 | # to access a list |
|
309 | Number.Inspect(List<Number>[2]) |
|
310 | ``` |
|
311 | ||
312 | ## Datatypes |
|
313 | ||
314 | In Fancade we have a total of 7 datatypes. These datatypes are Number, Vector, Rotation, Truth, Object, Constraint, and List. |
|
315 | ||
316 | The number type can be either a whole number or in decimals, in the programming world we call these "int" and "float/double". |
|
317 | ||
318 | Here are some examples: |
|
319 | ```coffeescript |
|
320 | Number jumpSpeed = 0.2 |
|
321 | Vector level = (1, 1, -10) |
|
322 | Rotation fan = {0.1, 0, 0} |
|
323 | Truth blocked = False |
|
324 | Object me = MyBlocks.Me |
|
325 | ``` |
|
326 | ||
327 | For the constraint, here is how you do it: |
|
328 | ```coffeescript |
|
329 | PlaySensor() { |
|
330 | Constraint const = Physics.AddConstraint(base, part, pivot) |
|
331 | Physics.AngularLimits(const, (0, 0, 1), (0, 0, 0)) |
|
332 | Physics.AngularMotor(const, (0, 0, 90), (0, 0, 100)) |
|
333 | } |
|
334 | ``` |
|
335 | To create variables simply type: |
|
336 | `Datatype variableName` |
|
337 | ||
338 | And to initialize: |
|
339 | `Datatype variableName = value` |
|
340 | ||
341 | For the lists here is an example: |
|
342 | ```coffeescript |
|
343 | PlaySensor() { |
|
344 | Object landmine = MyBlocks.LM |
|
345 | List<Object>[Number $LM] $LM = landmine |
|
346 | List<Vector>[Number $LM] $LM = Objects.GetPosition(landmine) |
|
347 | Number $LM++ |
|
348 | } |
|
349 | ``` |
|
350 | ||
351 | To access values inside a list: |
|
352 | ```coffeescript |
|
353 | Loop(0, $landmines) { |
|
354 | Number I = this.currentIndex |
|
355 | Vector landminePositions = List<Vector>[Number I] $LM |
|
356 | } |
|
357 | ``` |
|
358 | ||
359 | ## Example |
|
360 | ||
361 | Here is [[Martin Magni]]'s Shepherd game in text format. |
|
362 | ||
363 | ```coffeescript |
|
364 | # Init |
|
365 | Object $Herder = MyBlocks.Herder |
|
366 | Object Sheep = MyBlocks.Sheep |
|
367 | ||
368 | # Sheep script |
|
369 | TouchSensor("First").touching { |
|
370 | Physics.AddForce(Sheep, Math.LineVsPlane(Math.ScreenToWorld(this.screenX, this.screenY), (0, 2, 0), (0, 2, 0)) - Objects.GetPosition(Sheep)) |
|
371 | } |
|
372 | ||
373 | Number $Dist = Math.Max(Math.Distance(Objects.GetPosition(Sheep), Objects.GetPosition($Herder)), $Dist) |
|
374 | ||
375 | Collision(Sheep) { |
|
376 | If (this.secondObject == None) { |
|
377 | Game.Lose(False) |
|
378 | } |
|
379 | } |
|
380 | ||
381 | # Herder script |
|
382 | If (Number $Dist < 2) { |
|
383 | Game.Win(False) |
|
384 | } |
|
385 | Number $Dist = 0 |
|
386 | ||
387 | ||
388 | ``` |
|
... | ... | \ No newline at end of file |