Jump to content
-JpS-RaptorMan

Resloved: watch vars undocumented & weird variable scenario with _var -> var being same?

Recommended Posts

private _ourScores = ["T.T", "1"];   
aValue = (ourScores select 0);    // Note - no underscore
hint format ["This is ... %1", aValue]; // I still get "T.T" output in hint

It appears that the watch variable option in the debugger only works without the underscore - discovered this by myself - haven't found a good tutorial on how to use watch vars by anyone (likely due to spam of 101 stuff that just says, "Yea there's a watch var thing")

I also then played a bit & found I can declare the '_' symbol and then not use it in the code, but we still work?!  Does this break somewhere later down the line like compiling?

Share this post


Link to post
Share on other sites

You aren't understanding the fundamentals of private and global variables. Suggest more research.

  • Like 2

Share this post


Link to post
Share on other sites

In debug console (3den or in game) , or in an edited trigger (condition set to TRUE) for preview testing, just spawn your code if you want to check some consistency with your local variables:
0 = [] spawn {  your code here  };

 

See also. Don't focus on publicVariable until you'll script for MP.... another big step!

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

In debug console (3den or in game) , or in an edited trigger (condition set to TRUE) for preview testing, just spawn your code if you want to check some consistency with your local variables:
0 = [] spawn {  your code here  };

 

See also. Don't focus on publicVariable until you'll script for MP.... another big step!


I've read it twice before posting - perhaps is a context meaning I'm missing ... I don't see anything in there about how the underscore symbol is or is irrelevant.  The implication being that the arma3 engine isn't handling the '_' as a literal in there & that's why I asked if things break later on as I am using what appears to be two different variable names - but the eden editor doesn't and this might or might not effect the code being ran on the server.

  It doesn't appear to be documented in a way I can find via google with site:forums.bohemia.net either ...

Can you confirm you saw that ...  aValue should be undefined as there is no variable for ourScores, only for _ourScores ?

I'm probably missing where you're going with this - but - none of the steps your'e talking about seem related to what I'm discussing & I'm trying to connect the dots.

(I am doing MP too btw)

Share this post


Link to post
Share on other sites
1 hour ago, Tankbuster said:

You aren't understanding the fundamentals of private and global variables. Suggest more research.


Answers like this are waste of your time - unless you're padding some forum count.

If you delete this, you won't be wasting everyone else reading the thread's time too.

  • Haha 1

Share this post


Link to post
Share on other sites

Sorry, you'd also click at some links...

 

Here the first link from :

https://community.bistudio.com/wiki/Variables

gives access to:

this page. Follow links!

 

So, as you could see on this forum, there are also some pages related to global / local /(public) variables. You just have to do a search with: variables global local.

To sum it up, local variables are valid inside a scope (a code or a part of code), temporary finally, when global variables are valid during an Arma session on a local PC (roughly, because you can delete them).

Sometimes, you'll read an error message like: error: "local variable in global space". That means the engine is not able to read _underscoredLocalVariable , waiting for globalOne  , but I gave you a mean to workaround that.

 

And, definitely, _yourScore has nothing to do with yourScore. There is absolutely no link between these 2 different variables.

You should cool down.

Share this post


Link to post
Share on other sites
17 hours ago, pierremgi said:

And, definitely, _yourScore has nothing to do with yourScore. There is absolutely no link between these 2 different variables.

 

That's why I'm scratching my head man!  You can clearly see the code i posted used the 

aValue = (ourScores

BUT ... that variable doesn't exist ... only

_ourScores

Existed at the time.

 

Quote

You should cool down.


Totes calm bro - just asking the trolls to stay out of it.


The only explanation I can remotely come up with is the arma3 eden editor has a flaw where it doesn't clear the hint & the hint stays up there - then eden has a second flaw where it doesn't return zero / negative / anything when it doesn't work.

That's the only thing that makes remote sense I as I scroll through the eden editor command sequence & ran all 10 commands related to this again.

Share this post


Link to post
Share on other sites

Actually that was it ...

Arma3 eden editor doesn't clear the hints when the next command executes or fails to execute - perhaps it's hanging?

Then to compound that issue - it fails/hangs indefinitely AND silently without even a -1 or such, nothing the RPT either.

So that was that the issue - just oddities in the arma debugger - guess it comes with the territory of working a 2012 game...I really need to get the arma debugger engine outside the game working for vscode.

Thanks pierremgi!  I thought I was going crazy by the 5th time through the script process

Share this post


Link to post
Share on other sites
16 minutes ago, -JpS-RaptorMan said:

Arma3 eden editor doesn't clear the hints when the next command executes or fails to execute

 

hintSilent "";

at the top of your test code when you are using hints for feedback.

  • Like 1

Share this post


Link to post
Share on other sites

ty Harzach...have seen it in scripts but never looked it up!  Probably an essential feature if using hint 🙂

I've seen the equivalent in c families before for clearing console & should have thought about that!!

Share this post


Link to post
Share on other sites
 
 
 
1
58 minutes ago, -JpS-RaptorMan said:

Actually that was it ...

Arma3 eden editor doesn't clear the hints when the next command executes or fails to execute - perhaps it's hanging?
 

The hints fade out after 30 seconds unless you send an empty hint like Harzach says. Also, if you send a hint that has no result, you won't get anything, it just looks like nothing is happening. Sometimes is better to systemchat or diag_log debug data.

Are you still asking about what an underscore means to a variable? The topic seems to have moved on from that while as I said earlier (I was on a phone connection and unable to expand the reply) it's pretty basic to writing code in the game.

  • Like 2

Share this post


Link to post
Share on other sites

Ty tank - I noticed that when they used diag_log they can spit out arrays - so that's a good reason to use.  

Yea - on the other part - you can absolutely say whatever you want - but essentially "study more" doesn't give any direction or tips. 

It's better for me if someone doesn't have time, but can give me a name & media source to study.  I've been on the scripting tutorial master list - but have no idea who is best for beginners versus intermediate/advance programmers, youtube is a problem to find more stuff I can use after the initial 101 stuff - to get into actual details.

Share this post


Link to post
Share on other sites

You need to understand 'scope'. Until you get that bolted down in your head, you're going to struggle.

https://community.bistudio.com/wiki/Variables

This page takes you through much of it. Basically, a local variable always starts with an underscore and only exists within the scope it is first used.

A scope is typically a code block, though it's common to declare a private variable using the private statement right at the top (the bottom scope) of a script. If that's done, the variable exists throughout the script. In other words, the scope encompasses the entire script, but only that script.

There is no connection between, for example _mrvar and myvar. They are totally separate.

If a variable doesn't have an underscore it is known as a global variable and exists everywhere on that computer. If you then public the variable, it exists everywhere - server and all players.

But we're stepping into the MP server/client realm here. I know you said you are scripting for MP, but this is a case of learning to walk before running. I make missions for the dedicated server environment and it can be tricky, but it's also the most rewarding. There's no bigger kick than players telling you "That was really really hard. Let's do it again." 🙂

 

Share this post


Link to post
Share on other sites

Also, have a look at this, it might explain it better. I haven't watched it all the way through, but he does seem to cover the main points.

 

Share this post


Link to post
Share on other sites

I haven't had a scope issue yet - but will keep in mind you said there is some weirdness with scopes from arma3's sqf that aren't in normal programming languages.

Yea - have seen these before, I do recommend him - have watched like 8 of his series in last month to do due diligence on it 

Do you know what happened to him?  He's more current with most of his stuff - but when I started, I noted that he dropped off about 2 years ago.

Share this post


Link to post
Share on other sites
3 hours ago, -JpS-RaptorMan said:

 there is some weirdness with scopes from arma3's sqf that aren't in normal programming languages.

 

Which one? scopes are useful to drain local variables and codes like:

for "_i" from 0 to nbr do { <...>};  

are just fine, not worrying for the stack of such local variable as _i

 

The aspect you must cope with, is the scheduler. This 3ms slot to execute scheduled script/code. That can lead to unexpected returned value. Some tools like params and private are preventing overwriting local variables by parallel scope(s) or even by multiple instances.

 

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×