Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Custom variables?

Recommended Posts


I was wondering, can one add customly named true/false variables to their scripts when using Zdoom?

I'm only learning how to script, and I thought that it would be neat to be able to script picking up an object (an ID card) turn a customly named variable (for example securitylevel4) true. Later you could find doors, switches and such that require the variable securitylevel4 to be true to open.

This could also be used with more purposes. For example, a starbases generator is not working, making many switches unoperateable. Trying to click the switch, player gets a message saying "power must be restored to operate electric switches", but after turning the variable Starbaseelectricity true by flicking a switch or collecting cartain items.

I would use this trick in an upcoming wad of mine. Help a newbie out :)

Share this post

Link to post

This is probably the place where you'd wanna be looking That's the way I learned...
Look in the "Variables and data types" subpage.

Anyways, doing this is so easy, I'll give a away a quick demonstration:

- step 1, declare your variable:

int var1;
It can be done inside or outside any script, only if you define it inside a script, it cannot be acsessed by any other script. You can give the variable any name instead of "var1"
you can also give your variable a value on the spot...
int var1 = <any decimal value>;

if you want a variable that can only have 2 values (0 or 1)...
bool booleanflag1;

- step 2, giving it a value:
at any given moment, you can alter your variable's value simply by doing this:

var1 = <any decimal value>;

or by doing math operations:

var1 = 10 + (5 * 8)
or using the value of another variable...
var1 = var2 * 3

and with the boolean flags:
booleanflag1 = TRUE;

There's a lot of possibilites, I can't explain them all. Just use the wiki for reference and practice.

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now