What is a "Snippet" ?

Live2hit

Active Member
Joined
Feb 7, 2014
Messages
26
Likes
0
Points
1
#1
I want to know what a snippet clearly means. What does it stand for ? Can we use it ?
 

Opcode.eXe

Well-Known Member
Joined
Feb 18, 2013
Messages
1,257
Likes
10
Points
38
Location
( ͡° ͜ʖ ͡°)
Website
www.youtube.com
#2
Re: Snippet

Snippet is a programming term for a small region of re-usable source code, machine code, or text. Ordinarily, these are formally-defined operative units to incorporate into larger programming modules. Snippets are often used to clarify the meaning of an otherwise "cluttered" function, or to minimize the use of repeated code that is common to other functions. The snippets themselves may be either literal text, or written in a simple template language to allow substitutions, such as variable names. Snippets are a small-scale form of copy and paste programming. Snippet management is a feature of some text editors, program source code editors, IDEs, and related software. It allows the user to persist and use snippets in the course of routine edit operations.
http://en.wikipedia.org/wiki/Snippet_(programming)
 

xzytro

Well-Known Member
Joined
Apr 1, 2013
Messages
2,297
Likes
0
Points
36
#3
Re: Snippet

Well... While i was explaining this, opcode just replied with copy&paste. Still, i will post this just in case you want an explanation in an easier english with a lower level.

A snippet is, a group of codes which can be inserted inside a script to get additional functions running. A snippet is not a script, and it can not work on it's own. It needs to be implemented inside a coded project in order to complete the script faster.

Although snippets are useful for the coders to complete their scripts, they are not helpful on their own for the users themselves, as they exist only in purpose of defining some needed elements for the coders. Here's an example of a snippet for cleo scripts :

Code:
{$CLEO .cs}
THREAD "AIM_EXPLOSION"
0662: NOP "www.youtube.com/OpcodeXe" 
0662: NOP "www.ugbase.eu" 

:START
wait 10
if
0AB0: KEY_PRESSING: 2 // RIGHT MOUSE BUTTON - AIMING
jf @START
GOSUB @GET_AIMING_POS // RETURNS AIMING AT POSITION TO: [email protected] [email protected] [email protected]
020C: create_explosion_with_radius 3 at [email protected] [email protected] [email protected] 
Jump @START




:GET_AIMING_POS // PASTE THIS AT THE END OF THE SCRIPT
Actor.StorePos($PLAYER_ACTOR, [email protected], [email protected], [email protected])
0A9F: [email protected] = current_thread_pointer 
[email protected] += 80 
0A8E: [email protected] = [email protected] + 12 // int 
0AA6: call_method 5327216 11989032 num_params 6 pop 0 [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]  
if 
86BD:   not no_obstacles_between [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] solid 1 car 1 actor 0 object 1 particle 0 
else_jump @ADD 
jump @END_POS 

:ADD
[email protected] += 1.0 
if
  [email protected] > 250.0 
else_jump @GET_AIMING_POS 

:END_POS
[email protected] = 0.0
[email protected] = 0.0
[email protected] = 0.0
005B: [email protected] += [email protected] // (float) 
005B: [email protected] += [email protected] // (float) 
005B: [email protected] += [email protected] // (float)
[email protected] = 0.0 // RESET THE AIM RADIUS  
return
This snippet defines the position of aiming point. Without this snippet, you might lose your time on trying to make something that will define the positions of aiming point. But with existence of it's snippet, you can gain time & complete your script much faster and with less doubts.
 
Top