Using Variables: Difference between revisions

From COD Modding & Mapping Wiki
Jump to navigation Jump to search
(New page: == Using Variables == Image:Nutshell.png Variables can be used in several ways, but in all cases they are used to store some data for the duration of the round. Variables come in ...)
 
mNo edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== [[Using Variables]] ==
== [[Using Variables]] ==


[[Image:Nutshell.png]] Variables can be used in several ways, but in all cases they are used to store some data for the duration of the round. Variables come in different style, integer, floats, strings and booleans, there are also several different ways variables can be stored.
{{Note|Variables can be used in several ways, but in all cases they are used to store some data for the duration of the game. Variables come in different forms: integers, floats, entities, strings, arrays and booleans, there are also several different ways variables can be stored.}}


A simple variable is simply declared using
A simple variable is simply declared using


  <variable> = <data>;
  variable = data;
 
This variable can be used in the current function and any function that passes it as an argument, or is called on it (so it'd be used as 'self').


This variable can be used in the current function and any function that it is called to (using arguements, explained in section 1)


Variables can be global (which can be used in all threads without needing to be called) by using the
Variables can be global (which can be used in all threads without needing to be called) by using the


  level.<variable> = <data>
  level.variable = data;


or they can be assigned to entities individually
or they can be assigned to entities individually


  <entity>.<variable> = <data>
  entity.variable = data;
 
for things like player.health (integer, already built-in, but can be modified) and level.teamBased (boolean).
 
[[Category:Call of Duty]]
[[Category:Scripting]]

Latest revision as of 23:23, 15 April 2009

Using Variables

Variables can be used in several ways, but in all cases they are used to store some data for the duration of the game. Variables come in different forms: integers, floats, entities, strings, arrays and booleans, there are also several different ways variables can be stored.

A simple variable is simply declared using

variable = data;

This variable can be used in the current function and any function that passes it as an argument, or is called on it (so it'd be used as 'self').


Variables can be global (which can be used in all threads without needing to be called) by using the

level.variable = data;

or they can be assigned to entities individually

entity.variable = data;

for things like player.health (integer, already built-in, but can be modified) and level.teamBased (boolean).