RSS

Learn basic unreal script – Variables part 1

08 Feb

so im gonna start a series where i explain the basics in unrealscript so that unreal noobs and people who are interested in making mods can learn or branch out and try something new mabye.I am not a expert ,and  this is no alterative to reading a full fledged tutorial or a proper book. i don’t like reading things TBH , I dont easily absorb the information , and my attention span is shorter then  the passage level on unreal.

I dont care what you have to say that I dont know what I am talking about , if you know better then read and be entertained by somone else’s view , I know what i need to to make what I want.

This guide wont help you make a weapon or a monster or any thing even remotly usfull but it will introduce you to concepts that will help you on your way

———–

Part 1 : Variables 

They are used to store all you data in unreal .

you may think that variables are so simple ,

but each scripting launguge  defines them a diffent way , I came from tinkering a bit in vb and lua and the usage is completly differnt in tho laugages , some time you dont even need to define varable in some envioments atall.

In unreal you need to declare you varable at the start of your scripts.Either as vars or locals depending on the usage and scope.locals are just that-  local , Limited To the current function , These vars are not publicly shares outside of the function they are used in.

There are many types of variables in unreal  and what even more confusing is that any var could also  be a table, or  even a object !!!FFFFUUUUU its most confusing,

Addressing tables and objects and strings  seperately was one thing that didnt understand at first and although i understand it up to a point now its still confusing;

common variables types include string , integer , vertex , struct , actor,float, and byte.

common arable modifiers include , user editable ,config , arrays,private , and global.

TYPES

integers

Intergers are for numbers that dont have or need a floating point or decimal value, like say the number 5  they are delcared as “INT”

example

VAR INT numbervalue;

numbervalue = 5;

Floating point values

Floating point values are numbers with a decmil point , These are slightly more common then normal values and are used for alot of thing like damage percentages.

Example

VAR FLOAT floatnumbervalue;

floatnumbervalue  =  6.5;

  • Strings

strings are  a type of value that is multiuse, You can store any string of character in them like a number, a word , phares , classname , or text.  String values need to be set  in quotation marks when set.

example

VAR STRING stringnamevlaue;

stringnamevalue = ” This is a string vlaue 12345″;

  • Byte values

a byte value  is a numeric value non float , with a maximun value of 0 – 255 .

VAR BYTE byteme;

byteme = 255;

  • Bools

a bool is a simple true false or binary value  like  yes or no. the only thing they can do is  be false or true.

example

VAR BOOL Isistrue;

Isittrue = true;

  • Vectors

a vector is a value of three floating point numbers as a XYZ axes location. vectors are extremely important in unreal since everthing in unreal has a physical location assigned to it.

VAR vector theplace;

theplace = vect(7507.117676,3545.962891,-372.099548);

  • names

names are…  i not talking about names i hate them !!!

  • emum’s

emun are  a defined text label that defines a type . say there 4 options  for phyics

phyics_none , phyic_air  this would allow the varable to either have none or air selected as the content of that variable , they are defined similar to structs..

  • Structs

Structs are like a table  or array, or a value full of values. to use a struct . you need to define the structre before  declareing the value , a struct can be any combination of any values, they may be  vector , objects , bools , string etc , IIRC you are not allowed multi-dimensional arrays, you cannot put a struct in a struct. i cant recall if you can have arrays in a struct either.

example

struct lolteststruct {
var string pawntospawn;
var bool isenabled;
var int howmany;
var vector spawnlocation;

};

var   lolteststruct   structtable;

Using sructs  as as simple as

struct . subvalue

structtable.pawntospawn = “testpawnname”;

  • actors as vars

this is where things start to get weird and super confusing.

actors are objects or data.They are phyical objects. Like a flare, its a  object , But also a object can be just data , If you instance a flare , you can set the instance of  that flare’s  properties in a way similar to a struct.But Intill you call spawn it not a physical object and just the framwork ghost of a object.

The flare is a actor , and every actor in the game has varables assigned to it like location , drawscale and abeint sounds and skins or lightging.

basically a actor instants is a temporary instance of the originals actor defaults that you can modify the properties of said actor with or creat new actors.

but…

a instance can be used to illiterate tho all instances of a actor in the map as a temporary value.

var flare flartest;   var light lightile; var pickup p;  etc

ok you got all that ?

now that you know basic variable type , there are advanced ways to use them.

MODIFIERS

user editable vars

To have your value you defined be available in the defualt propertis as a editable value and not just a script value you need to add () the the var instance.

var() string thingclassstring;

this will make the variable user editable

config values

if you would like your variables to be configurable  in a external ini file you need to specify 2 things

You class need to  be setup to use  config

say your class it crappyclass extends actor;

add this to your class name at the top of the script page

crappyclass extends actor config (youcrappyini);

this will tell the game we want to use the file yourcrappyini.ini to write the data to ,  you can tell it unreal if you would like it to save the data into the default ini file the game is running on.

also any values you want to have saved to the file need to be defined as such by adding config to them. make sure to ass () to any config values you define so they are user – editable.

var()  config string mydatasosave;

Your data will be saved in a section based on the name you choose for your package and class , so the section would be [PACKAGENAME.crappyclass]

Arrays

arrays are a good way of dealing with mass amounts of sequncel variables. almost any variable can be in  a array except bools.

arrays are basicly numbered tables , you have a varable , and you add [5] onto the end and now you have 5 instances you can work with.

example

var string theclassnames[50];

this would store 50 strings in theclassnames each in a numbers instance  you access and edit them using

theclassnames[2] = “mynamehere”;

Private vars

private vars are values that are limited to the current scope of the current script. you may ask why  do i need that when all my values are stuck in my script?

Well any script that  references your scriptfile  can access  any of your values useing a  instance (yourcrappyclass.valuename). so if you have a mod with a password value or  other dats like that , Other mods  that were built referencing or extending your mod it  will be denied access to access your variable if they are private ,

But  it easily defeatable , By using  consolecommands in script you can read and write the values anyway.You can make this more diffuculy by using varable arrays , and  a console command wouldn’t easily be able to return the correct values.

you can combine any of these modifies with any type of variable mentioned above to create  complex configuration option or store you data in you mods.

heres more examples.

var string mytext;  // script only modifiable string

var()  string mytest2; // user editable string value

var() config mytest3; a user editable value that is saved in a external file

var() flare flarechoice; //user specifiable object seletion that limited to flares

var() vertex mylocation; //  a user editable location zyx axis

var() private config modpassword;// a user editable private config.

var() config string all yournames[15];

knowing and understanding this is key to doing anything in unreal-script.

Advertisements
 
Leave a comment

Posted by on February 8, 2012 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s