Jump to content
  • 0

Help me understand variables


GreenMagic793

Question


  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  157
  • Reputation:   18
  • Joined:  08/18/15
  • Last Seen:  

Hey guys,

 

I'm pretty familiar with variables (I use them in almost every script I make), but quite honestly, my knowledge of variables is somewhat of a piecemeal of seeing them used in other scripts and simply copying what I see. I know where and when to use certain variables, but I don't know why I'm using them.

 

I understand the basic jist of how variables work, but what I'm not understanding is the difference between, say, "$var$" and $@var$. Is this basically a combining of variables, such that the variable applies to more than one thing? At this point, all I really understand about variables is that they allow you to store values very easily, and depending on which variable you use, the value will be linked to a different function like an account ID, player ID, etc. But I'm not understanding the underlying complexities of variables and how multiple variables can be combined to achieve different effects. Any help would be greatly appreciated.

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  


$var$

  • stored value globally

can be access by any NPCs any time.

value persistent even after you reboot or reloaded server.


$@var$

  • stored value globally

can be access by any NPCs any time.

value ISN'T persistent if you reboot or reloaded server.

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   337
  • Joined:  10/17/12
  • Last Seen:  

https://github.com/rathena/rathena/blob/master/doc/script_commands.txt

Search variables

Best thing to do is read up on that, then do some testing with things, I k ow your using a very old .txt based server (for whatever reason) so there are a few more limits to variables for you; max array size of 128, permanent account and character variables cannot be arrays.

If you have questions about a certain script your making just ask here via post or pm, or post on the rAthena discord chat for more instant advice.

Also https://rathena.org/wiki/Basic_Scriptingcheck this out as well under Conditions and Variables

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  157
  • Reputation:   18
  • Joined:  08/18/15
  • Last Seen:  

So the addition of the '@' symbol is what differentiates between persistent and temporary values? Interesting... I'm assuming that applies to every other variable as well?

 

Let me see if I can explain what I understand so far and maybe you can tell me if I'm on the right track.

 

So each symbol like '@', '#', '.' etc, are all used to store values, and each one stores data on a different basis, like account-wide, globally, etc. correct? So by simply adding a @ symbol after the first symbol, it makes the variable non-persistent?

 

So, I understand, then #bankpoints# would be an account-wide, persistent value, and #@bankpoints# would be a temporary value? If I'm on the right track, then I totally get this now, woo hoo!

 

One last question... What is the difference between, say, #bankpoints and #bankpoints#? Are they just two separate variables, or does adding the extra # on the end have some purpose? Thanks.

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   337
  • Joined:  10/17/12
  • Last Seen:  

To my knowledge # after does nothing but honestly I'm no positive

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

you gonna read here for further explore.

https://github.com/rathena/rathena/blob/master/doc/script_commands.txt#L449

 

and variables doesnt end with "#".

 

but if variables ended with "$" it's for string value, else it's integer value.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...