GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2011-07-19 09:15:43

NicharCZ
Member
Registered: 2011-07-19
Posts: 4

instance_variable_controll

Hi there smile
I've created some script during making on my game. This scripts controll the existence any instance in room dependence on some variable: it means, the instance can exist, only, if selected variable has current value. If not, the instance will be destroyed. Look at code and than understand. smile

Expand//instance_variable_controll(object,x,y,variable,value)
// Create by NicharCZ
// Copyright 2011
//
//

var obj, variable, value, xx, yy;
obj=argument0
xx=argument1
yy=argument2
variable=argument3
value=argument4

if variable==value && !instance_exists(obj) {
    instance_create(xx,yy,obj)
    }
if variable!=value {
    if (instance_exists(obj)) { 
       with (obj) 
       instance_destroy()
       }
    }

I'm sorry for my english, that's really tragic smile
Edits: Correction

Last edited by NicharCZ (2011-07-19 09:18:05)

Offline

#2 2011-07-19 12:41:03

xot
Administrator
Registered: 2007-08-18
Posts: 1,240

Re: instance_variable_controll

OK, I can see what this does, but I do not understand how it should be used. How was this used for your game?


Abusing forum power since 1986.

Offline

#3 2011-07-20 06:57:30

NicharCZ
Member
Registered: 2011-07-19
Posts: 4

Re: instance_variable_controll

Well, i show you some example:

I have swiching with buttons. If I click the first button, variable global.mode=1, if I click the second button, variable global.mode=2 etc.. And other object can exists only if global.mode=1.. With my script, you can select position of instance, object, variable and value itself.

Offline

Board footer

Powered by FluxBB