LOGIN
SEARCH
PROFILE
keys: ↑ ↓
LOGOUT
INDEX
MEMBERS
keys: ↑ ↓
HOME
PORTAL
PLAY ALONG
PLAY with WORDS
PLAY with GRAPHICS
PLAY with SOUNDS
PLAY with CODES
PLAY with PROJECTS
keys: ← →
Guest Access
Register:
Members:



View previous topic View next topic Go down Message [Page 1 of 1]

WORDSMITH
WORDSMITH
#1 [solved]Variable pointers in XP? Empty [solved]Variable pointers in XP?
Loading

Cardboard Square

Cardboard Square
WORDSMITH
WORDSMITH
profile
Hi there.

So RM2K has the wonderful option built in to the variable commands page to use variables as pointers to other variables, which I use liberally. XP doesn't... Is there a script or add-on that can set that up for XP? Guess I'd have to script it into whatever all functions otherwise.

Thanks in advance!

-CS

(Bah, I can't host a picture because it crashes my browser. If anyone has insight on THAT as well that would reeeaally help!)

WORDSMITH
Show Signature
WORDSMITH
EVENTALIST
EVENTALIST
#2 [solved]Variable pointers in XP? Empty Re: [solved]Variable pointers in XP?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
what do you mean... like if this variable is set to say "x", then it points to variable "x", but if its "a" then it points to "a" ?


how would this be useful i have never needed something like this.
EVENTALIST
Show Signature
EVENTALIST
WORDSMITH
WORDSMITH
#3 [solved]Variable pointers in XP? Empty Re: [solved]Variable pointers in XP?
Loading

Cardboard Square

Cardboard Square
WORDSMITH
WORDSMITH
profile
Yeah, its confusing. I use it for certain event loops as a substantial shortcut. I'm bad at explaining things like this, but bear with me...

In my project for RM2K, for example, I have spell slots for each character that you assign the spells you want to. And each spell has one variable that it corresponds too. These variables change depending on who knows the spell (ex, if var y=1, then Hero1 knows that spell; if y=2 then Hero2 knows that spell).

Now imagine that there are 50 spells. Well, when I want to check which character knows which spell, I don't want to have to program Conditional Branches for every single spell. Lets say the first spell is variable number 80. What I do is set a variable, x, to 80. For simple variable functions, we just have conditionals like "if x=80 then..." But I don't care about the number 80. I want to know what number (or value) resides with variable number 80. The variable pointer function allows me to ask the game, "What is the value of the variable that variable x points to?" Lets say it returns a value of 1. This means that Hero1 knows that spell. Does that makes sense?

So while I'm rambling, some people might feel like, "Okay, I get it, but what's the freaking point?" Well, after the game checks for the value of the variable that x points to, you just add 1 to x. In this example, x becomes 81. Put this in a loop and now you can check who knows the spell associated with variable 81, then 82, 83 etc, without having to have a separate conditional branch for all 50 spells.

If this makes sense, I'll go ahead and post it in a tutorial section.

-CS
WORDSMITH
Show Signature
WORDSMITH
EVENTALIST
EVENTALIST
#4 [solved]Variable pointers in XP? Empty Re: [solved]Variable pointers in XP?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile


Paste this below everything just above main in our script's database.
Code:

# variable used as a pointer
POINTER_ID = 1

class Interpreter
    def return_value(var_id)
      $game_variables[POINTER_ID] = $game_variables[var_id]
    end
end

what ever variable you set in the "return_value(var_id)" in the script command in the event, it will set your variable pointer id to that value of the variable.

this sorta what you wanted?
EVENTALIST
Show Signature
EVENTALIST
WORDSMITH
WORDSMITH
#5 [solved]Variable pointers in XP? Empty Re: [solved]Variable pointers in XP?
Loading

Cardboard Square

Cardboard Square
WORDSMITH
WORDSMITH
profile
Yeah, I think this is what I want. Let me make sure I understand the code. It basically accomplishes...

Yep, this is it. But how do I alter what POINTER_ID points to? I tried a lot of things like POINTER_ID + 1 and return_value(+1) etc etc. How do I index POINTER_ID??

Thank you Wiggles; this is really helpful.

-CS
WORDSMITH
Show Signature
WORDSMITH
EVENTALIST
EVENTALIST
#6 [solved]Variable pointers in XP? Empty Re: [solved]Variable pointers in XP?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
wait you wanna have it to where another variables is the pointer id as well? so like var "a" is the set value, and var "b" is the variable used for pointing?

... or you just wondering how to change the variable for the one that's used to retrieve the value?

cause for that in the script just go to "POINTER_ID = " line and set that number to what ever variable number you wanna use.
EVENTALIST
Show Signature
EVENTALIST
WORDSMITH
WORDSMITH
#7 [solved]Variable pointers in XP? Empty Re: [solved]Variable pointers in XP?
Loading

Cardboard Square

Cardboard Square
WORDSMITH
WORDSMITH
profile
wait you wanna have it to where another variables is the pointer id as well? so like var "a" is the set value, and var "b" is the variable used for pointing?

Yes, I think that is what I am looking for. I basically want it to do
"POINTER_ID +1" instead of "POINTER_ID = x"

I want POINTER_ID to increase the variable it points to by 1 without setting it as a constant. (I mean that if POINTER_ID had pointed to variable #3, I want to add 1 so that it now points to variable #4)

Thanks again.

-CS
WORDSMITH
Show Signature
WORDSMITH
EVENTALIST
EVENTALIST
#8 [solved]Variable pointers in XP? Empty Re: [solved]Variable pointers in XP?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
like this then?

Code:

class Interpreter
    def return_value(var_id)
      $game_variables[var_id] = $game_variables[var_id + 1]
    end
end
EVENTALIST
Show Signature
EVENTALIST
WORDSMITH
WORDSMITH
#9 [solved]Variable pointers in XP? Empty Re: [solved]Variable pointers in XP?
Loading

Cardboard Square

Cardboard Square
WORDSMITH
WORDSMITH
profile
Hey, that should be just what I was looking for! Thanks a bunch Wiggles!

-CS
WORDSMITH
Show Signature
WORDSMITH

Sponsored content

profile

View previous topic View next topic Back to top Message [Page 1 of 1]

 

Chatbox system disabled
Personal messaging disabled