Login

Fancade Wiki

Updated Fancade Text Code Format.md (markdown)

... ...
@@ -6,209 +6,266 @@ A Pseudo-Coding Language Format Developed by (**@Isaglish** , me **@JP16D** , **
6 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 7
8 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
9 37
## _______________________________________________________________
10 38
### Basics
11 39
## _____________________________
12 40
**Value Types** :
13 41
```
14
• Num varName = 0 ; //NaN ~ Integers ~ Inf
15
• Tru varName = 0 ; //boolean either 0 or 1 only
16
• Vec varName[x , y , z] ;
17
• Rot varName[x , y , z] ;
18
• Obj varName = Obj ;
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]
19 49
```
20 50
## _____________________________
21 51
### Basic Math Operators
22 52
23
- Add - ( + )
24
- Subtract - ( - )
25
- Divide - ( / or ÷ )
26
- Multiply - ( * or × )
27
- Power - ( ^ )
28
- Modulo - ( % )
53
```
54
//Add Numbers
55
2 + 2
29 56
57
//Subtract Numbers
58
2 - 2
30 59
60
//Multiply Numbers
61
2 * 2
31 62
63
//Divide Numbers
64
2 / 2
32 65
66
//Power
67
2 ^ 2
33 68
34
## _______________________________________________________________
35
### Control
69
//Modulo
70
2 % 2
36 71
37
## _____________________________
38
***if***
39
```
40
• If (condition) { function } else { function } ;
41
```
42
**or**
72
//Increase
73
num++
74
75
//Decrease
76
num--
43 77
```
44
• condition ? function : function ; /* This is a secondary method of conditional if in JS language Idk if there are also other languages that is using this method of conditional if */
78
## _____________________________
79
### Basic Boolean Operators
45 80
```
81
//Boolean logic (AND, OR, NOT)
46 82
83
tru smart = ((NOT dumb) AND (has_brain)) OR already_smart;
47 84
85
//Math (Greater, Less, Equal)
48 86
87
tru equal = a == b;
49 88
89
tru greater = a > b;
50 90
51
## _____________________________
52
***Loop***
53
```
54
• Loop[ start , end ]( )
55
{ function ; return ( counter ) ; } ;
56
```
57
**or**
58
```
59
• Num start = 0 ;
60
While (start < end) { start++ , function } ;
61
/*this is loop in a nutshell :D , joke this is the manual loop*/
62
```
63
## _____________________________
64
***Touch Sensor***
91
tru less = a < b;
65 92
```
66
• Touch[ mode , touch ]( )
67
{ function ; return ( x , y ) ; } ;
68
```
69
## _____________________________
70
***Collision***
71
```
72
• Collide[ Obj ]( )
73
{ function ; return ( Impulse , Normal , Hit Obj ) ; } ;
74
```
75
## _____________________________
76
***Swipe***
93
94
## _______________________________________________________________
95
### Game
77 96
```
78
• Swipe( ) { function ; return ( x , y , z ) ; } ;
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
79 113
```
80
## _____________________________
81
***Box Art***
114
115
## _______________________________________________________________
116
### Objects
82 117
```
83
• BoxArt( ) { function } ;
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);
84 142
```
85
## _____________________________
86
***Play Sensor***
143
144
## _______________________________________________________________
145
### Sound
87 146
```
88
• PlaySensor( ) { function } ;
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);
89 153
```
90
## _____________________________
91
***Late Update***
154
155
## _______________________________________________________________
156
### Physics
92 157
```
93
• LateUpdate( ) { function } ;
158
//I regret doing this, sorry
94 159
```
95 160
96
## _____________________________
97
### Basic Boolean Operators
98
- Greater Than - ( > )
99
- Less Than - ( < )
100
- Equal - ( == )
101
- AND - ( && )
102
- OR - ( \|\| )
103
- Not - ( ! )
104 161
105 162
## _______________________________________________________________
106
### Object
107
## _____________________________
108
***Set Position***
109
```
110
• SetPos( Obj , Position[ ] , Rotation[ ] ) ;
111
```
112
## _____________________________
113
***Raycast***
114
```
115
• Raycast( From[ ] , To[ ] )
116
{ return ( Hit , Hit Pos[ ] , Hit Obj ) ; } ;
117
```
118
## _____________________________
119
***Get Position***
120
```
121
• GetPos( ) { return ( Position[ ] , Rotation[ ] ) ; } ;
122
```
123
## _____________________________
124
***Get Size***
125
```
126
• GetSize( ) { return ( max size[ ] , min size[ ] ) ; } ;
127
```
128
## _____________________________
129
***Create Object***
130
```
131
• Object.Create( Obj ) ;
132
```
133
## _____________________________
134
***Destroy Object***
135
```
136
• Object.Destroy( Obj ) ;
137
```
138
## _____________________________
139
***Set Visible***
140
```
141
• Object.Visible( Obj , Visible ) ;
163
### Control
142 164
```
165
//Basic if operator
166
If (condition) {
167
function_true;
168
} else {
169
function_false;
170
}
143 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
144 175
176
Loop(num start = 0, num end = 0) {
177
//Output
178
self.Counter
179
}
145 180
181
Touch_Sensor() {
182
//Outputs
183
self.Screen_X
184
self.Screen_Y
185
}
146 186
187
Collision(obj Physical_Object) {
188
//Outputs
189
self.Second_Object
190
self.Normal
191
self.Impulse
192
}
147 193
148
## _______________________________________________________________
149
### Advanced
150
## _____________________________
151
***List Set Element***
152
```
153
• Num varName[ index ] = 0 ;
154
• Vec varName[ index ] = [ x , y , z ] ;
155
```
156
***List Get Element***
157
```
158
• varName[ index ]
159
• varName[ [ x , y , z [ index ] ]
160
```
161
## _______________________________________________________________
162
### Advanced Math Functions
194
Swipe_Sensor() {
195
//Output
196
self.Direction
197
}
163 198
164
## _____________________________
165
***Scale & Rotate***
166
```
167
• Vec[ ] * Num
168
• Math.Rotate[ Vec[ ] * Rot[ ] ]
169
```
170
## _____________________________
171
***Break and Create Vec/Rot***
172
```
173
• Math.Break[ Vec[ ] ]
174
```
175
**or**
176
```
177
• vec[ x ] , vec[ y ] , vec[ z ]
178
• Math.Create[ NumX , NumY , NumZ ]
179
```
180
## _____________________________
181
***Dot & Cross Product***
182
```
183
• Vec[ ] ° Vec[ ] // Dot Product
184
• Vec[ ] • Vec[ ] // Cross Product
185
```
186
## _____________________________
187
***Min & Max***
188
```
189
• Math.Min[ a , b ]
190
• Math.Max[ a , b ]
191
```
192
## _____________________________
193
***Round , Floor & Ceil***
194
```
195
• Math.Round[ Num ]
196
• Math.Floor[ Num ]
197
• Math.Ceil[ Num ]
198
```
199
## _____________________________
200
***Sin & Cos***
201
```
202
• Math.Sine[ Num ]
203
• Math.Cos[ Num ]
204
```
205
## _____________________________
206
***Distance***
199
BoxArt() {
200
}
201
202
PlaySensor() {
203
}
204
205
LateUpdate() {
206
}
207 207
```
208
• Math.Distance[ A[ ] , B[ ] ]
208
209
## _______________________________________________________________
210
### Math
209 211
```
210
## _____________________________
211
***LERP***
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)
212 271
```
213
• Math.LERP[ From , To , Amount ]
214
```
... ...
\ No newline at end of file
Fancade Wiki