MegaKerma / Silent Walk FPS Creator / Silent Walk: RENAISSANCE

Tools for creating 3D games
It is currently Thu Nov 15, 2018 10:33 pm

All times are UTC + 2 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: KermaScript - VARIABLES
PostPosted: Sun Feb 03, 2013 10:52 pm 
Offline
Site Owner
Site Owner
User avatar

Joined: Thu Aug 17, 2006 7:27 pm
Posts: 966
Location: Budapest, Hungary
VARIABLES IN KERMASCRIPT

GLOBAL VARIABLES
To create a global variable use the SET command.
Code:
SET score AS 0

This command creates a global variable, which means you can use the score in every event of all objects.

LOCAL VARIABLES
From version v2.1 it is possible to create and use local variables. Local variables exist and are accesible only for its owner object.

Code:
SET self.health AS 100

This command creates the health variable for the caller object (where the command is executed).

USING VARIABLES
Using global and local variables has the same logic.

Global variables are accesible in every object:
Code:
PRINT score AT 100 100

This command can be executed in every event of all objects.

Local variables are accesible only for its owner object.
Let's say you have a cube object and set a local variable in its Creation event:
Code:
SET self.health AS 100

You can use this variable in the same object (e.g.: Step event).
Code:
PRINT self.health AT 100 100


But YOU CANNOT USE IT IN ANOTHER OBJECT
Other cube's step event:
Code:
PRINT self.health AT 100 100

This will print 0, as health does not exist in this object.

COMMAND SETS
Local variables are useful with the combination of Command Sets. It is possible to create a general command set which uses local variables.
Let's create the following Command Set called "CheckHealth"
Code:
IF self.health < 0
    DESTROY self
ENDIF

This is a general command set (a "function"). When an object calles this function it will use the caller object's variable.

Code:
GOSUB CheckHealth

With this one line of code you can call a general function to check the health of the actual object.
If you need to change it, you change it in one place instead of editing in every object.


Top
 Profile  
 
PostPosted: Tue Feb 05, 2013 2:20 am 
Offline
Registered member
Registered member
User avatar

Joined: Sun May 08, 2011 2:28 am
Posts: 350
Location: Bandon, Oregon
Thanks for your time Zoltan and I appreciate it a lot.

Marv

_________________
Registered SilentWalk2
Registered MegaKerma
Full Retrostica Application


Top
 Profile  
 
PostPosted: Tue Feb 05, 2013 10:06 pm 
Offline
Site Owner
Site Owner
User avatar

Joined: Thu Aug 17, 2006 7:27 pm
Posts: 966
Location: Budapest, Hungary
You are welcome.

I am planning to create more short tutorials.
Tutorial suggestions are also welcome. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group