Home   Help Search Login Register  

Author Topic: Repairing (physically/visually)  (Read 4001 times)

0 Members and 1 Guest are viewing this topic.

Offline Loyalguard

  • Former Staff
  • ****
Re: Repairing (physically/visually)
« Reply #15 on: 04 Apr 2008, 13:58:48 »
If you change your init.sqs to init.sqf it would/should look like this:

// Initialize revive script
server execVM "revive_init.sqf";

_nul = [] execVM "repair.sqf";

Offline Ironman

  • Former Staff
  • ****
    • {GSF} Home Page
Re: Repairing (physically/visually)
« Reply #16 on: 04 Apr 2008, 20:50:46 »
what is the _nul for?
TS3 IP: tor.zebgames.com:9992

Offline Loyalguard

  • Former Staff
  • ****
Re: Repairing (physically/visually)
« Reply #17 on: 04 Apr 2008, 22:00:37 »
_nul is what is called a "handle" and is used with the execVM or spawn commands.  It's a way of identifying a script and/or storing any return values (the latter being one of the most common uses).  It can be in the form of a global or local variable.  In the example I gave you, I designated it _nul to mark it as something from which I don't expect any return value.  You can call it anything as long as you follow the normal variable rules.  A good example of where a return might be useful using execVM is the addAction command where the handle stores the unique ID of of the action.

Offline Ironman

  • Former Staff
  • ****
    • {GSF} Home Page
Re: Repairing (physically/visually)
« Reply #18 on: 05 Apr 2008, 03:23:44 »
Ok, so the "_nul" will handle and returns that might be sent back. In this case, none will be sent.

So it is like Java's:

public void blahBlah()
{

}

where void is the return type.... right?
TS3 IP: tor.zebgames.com:9992

Offline Loyalguard

  • Former Staff
  • ****
Re: Repairing (physically/visually)
« Reply #19 on: 05 Apr 2008, 09:49:22 »
Whether there is a return or not depends on the code that follows the handle I think.  Using "_nul" doesn't actually destroy or block the return, it is more to informally remind you that you are ignoring this return as you have no use for it.  I could have written "_ignoreThis" or "_noReturn" or anything for the same purpose. I use "_nul" because it is a quick easy fit.  Sorry for any confusion.

Offline Rommel92

  • Members
  • *
Re: Repairing (physically/visually)
« Reply #20 on: 05 Apr 2008, 10:07:18 »
Ok, so the "_nul" will handle and returns that might be sent back. In this case, none will be sent.

So it is like Java's:

public void blahBlah()
{

}

where void is the return type.... right?

Code: (add.sqf) [Select]
private ["_a","_b","_c"];
_a = _this select 0;
_b = _this select 1;
_c = _a + _b;
_c

_m = [1,2] execVM "add.sqf";
_m == 3;

Hope that helps, the fact that he put _nul there has nothing to do with the word, it just means... Null, nothing, if you wished to use the return value, you could still use _nul, but most times you wouldn't for easy reading/debugging.

Variable = Return of Operation.
So if:
"_VAR = 1 + 15" then _VAR = 16, not 1 + 15. And if you do variables inside this, "_VAR = _vA + _vB" then _VAR = whatever _vA and _vB equal at that time, say their both 10, _VAR = 20. If _vA or _vB change to say 2, _VAR will still = 20 unless you do the _VAR = _vA + _vB operation again (which would mean _VAR = 4), as it does not store the variables, it stores the RESULT, or the Return of the Operation.

I think I went a bit off topic...
« Last Edit: 05 Apr 2008, 10:12:41 by rommel92 »