[RM2K3] HELP WITH VARIABLES.

Posts

Pages: 1
I'm working on a custom status screen for a side project I'm working on. The reason I'm working on a custom status screen is to show how many Ability Points the heroes have as well as other stats (Ability Points being used to strengthen the heroes weapons and purchase skills). What I would like to know is how to separate variables into tens and units
You mean if you had a number like 1234 you want to put 1, 2, 3, and 4 into separate variables? You want to use division and modulus division. So for example if you want to get the tens digit of 1234 first you divide by 10 to get 123 (the remainder of 4 is dropped). Then you use modulus division by 10 to get 3 (modulus division is denoted by the % operator and it performs the division but it returns the remainder, in this case 3, and the 12 is dropped). Adjust how much you divide by to get each digit:

Ones digit:
% 10
Tens digtt:
/ 10 then % 10
Hundreds digit
/ 100 then % 10
and so on

I don't know what you mean about units though.
Units is ones. Sorry I was taught to say units at school. Should I provide a mock up of what I'm trying to accomplish?
Yeah, units is new to me. It was always ones, tens, hundreds, thousands, etc. when/where I was a kid. Couldn't hurt to post the whole thing at least, might be able to get more indepth answers from people more familiar with 2k.
I can post a picture of what I'm trying to accomplish. I've not started any of the coding yet.



I'll try to explain what I'm trying to do as best I can. The variables for HP, SP, AP, and the other stats will check to see what the characters stats are (In this project the max for each stat is 99). And the value will be displayed with pictures. The way I would do it is by having 99 pictures and 99 conditional branches. What I'd prefer to do is separate the variables into tens and ones so I'd only need to use 20 pictures and make the coding a little easier.
Well, if the max value is 99 you could just do:
Tenth: variable / 10
Single: variable % 10

The % is the Mod operation in rm2k3.

It's a tad more complicated if you have bigger numbers but can be done.
First you have to check if the number is bigger than 99. If not you can do the thing shown above else do this:

Hundred:
1) hundred = variable / 100

Tenth:
1) tenth = variable / 10
2) tenth = tenth % 10

Single:
1) single = variable % 10
Yeah, just do

Variable Operation: ATK Tens Digit
Set it to ATK Variable

Variable Operation: ATK Tens Digit
Divide it by 10

Variable Operation: ATK Ones/Units Digit
Set it to ATK Variable

Variable Operation: ATK Ones/Units Digit
Modulus Divide it by 10

Repeat for everything.


If you want to use a common event to help with the tedium:

Common Event: Split Number
It's parameters are two variables I'll call SourceVariableID and DestinationVariableIDStart. Put the variable ID of the character's ATK or other stat into SourceVariableID and the variable ID of the highest digit into DestinationVariableIDStart. It assumes the Tens and Ones digit variables follow each other.

Variable Operation: Variable ID referenced by DestinationVariableIDStart
Set it to the variable with ID referenced by SourceVariableID

Variable Operation: Variable ID referenced by DestinationVariableIDStart
Divide it by 10

Variable Operation: DestinationVariableIDStart
Add 1

Variable Operation: Variable ID referenced by DestinationVariableIDStart
Set it to the variable with ID referenced by SourceVariableID

Variable Operation: Variable ID referenced by DestinationVariableIDStart
Modulus it by 10


Then when you need to break up a number you can just set the SourceVariableID to be the ID of the variable you want to break up and DestinationVariableIDStart to be the ID of the tens digit you'll use when showing pictures. Then just call the common event and have it take care of the busy work.

This assumes you're using variables for character stats. If you're using the actor's stats then I'd suggest another common event that dumps a character's stats into variables. Pass it the actor ID and have a common event responsible for the horrors of dumping a character's stats into a set of variables for use by the menu.

e: If it'll help I can throw together a shitty demo in 2k3 tonight to show the code of what I'm trying to explain.
For any music composers on here, which of the free music composer software would you say is the best for people wanting to make custom tracks for their RPG Maker projects- LLMS or Rosegarden?

Delete this please, I was a little spastic and put this in the wrong place. I'm sorry. Blonde moment, even though I'm a ginger. >.<
I am using the actors stats. If you could make a little demo to help me along that would be greatly appreciated. I'm not very good when it comes to variables.
Sure thing, I'll throw something together tonight then. Do you have the Steam version of 2k3? If not I can use the old maker, I just prefer some of the UI niceties added.
Alright, here's a demo project: Download here.
Talk to Samurai Man and he'll ask what actor to get the stats for and one of a set of stats. He'll call a common event to put the requested stat into a single variable*. Then it'll call a second common event to break up a number into it's various digits, up to the thousands digit.

*After doing this changing the get actor stats to get ALL of their stats into a bunch of variables in a single Common Event might be better. Depends on implementation details.

If you can't open the project here's the various event codes:

Main User Interaction Event:

@> Comment: Get ActorID to show via a command choice for now
@> Text: Whose stat do you want to display?
@> Show Choices: \n[1], \n[2], \n[3], \n[4]
: When [\n[1]]
@> Control Variables: [0003:SourceActorID] = 1
@>
: When [\n[2]]
@> Control Variables: [0003:SourceActorID] = 2
@>
: When [\n[3]]
@> Control Variables: [0003:SourceActorID] = 3
@>
: When [\n[4]]
@> Control Variables: [0003:SourceActorID] = 4
@>
: When Cancel
@> End Event Processing
@>
: Branch End
@> Comment: StatIDs are the order they appear in the control variable
: : 1=LVL,2=EXP,3=HP,etc.
: : 0 is no value
@> Text: What stat do you want to show?
@> Show Choices: CURHP, MAXHP, ATK, DEF
: When [CURHP]
@> Control Variables: [0004:StatToShow] = 3
@>
: When [MAXHP]
@> Control Variables: [0004:StatToShow] = 5
@>
: When [ATK]
@> Control Variables: [0004:StatToShow] = 7
@>
: When [DEF]
@> Control Variables: [0004:StatToShow] = 8
@>
: When Cancel
@> End Event Processing
@>
: Branch End
@> Comment: Now we want to fetch the actor's stats into a temp variable,
: : VariableID#1. Write our parameters for our common event
@> Control Variables: [0006:GetActorStat ActorID] = Variable [0003]
@> Control Variables: [0007:GetActorStat StatID] = Variable [0004]
@> Control Variables: [0008:GetActorStat VarID] = 1
@> Call Event: [GetActorStat]
@> Text: The stat we will break up is: \V[1]
@> Comment: Next we'll break it up into all of it's precious little
: : digits
@> Control Variables: [0010:BreakUp SourceVarID] = 1
@> Control Variables: [0011:BreakUp DestVarID] = 13
@> Call Event: [Break Up Number]
@> Text: \V[13],\V[14],\V[15],\V[16]
: : Thank you and play again!




GetActorStat Common Event

@> Comment: Copy an actor stat to a given variable
: : "GetActorStat ActorID" is the ID of the actor to load
: : "GetActorStat StatID" is the stat to get
: : "GetActorStat VariableID" is the variable ID to write to
@> Comment: StatIDS:
: : 1: LVL, 2: EXP, 3: CurHP, 4: CurMP, 5: MaxHP, 6: MaxMP
: : 7: ATK, 8: DEF, 9: MIND, 10: AGI
@> Comment: We can't streamline this using clever variable usage
: : so we just have to hammer this shit out unfortunately.
@> Comment: ----- ACTOR 1 -----
@> Conditional Branch: Variable [0006:GetActorStat ActorID] == 1
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 1
@> Control Variables: Variable [0008] = [Zack]'s Level
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 2
@> Control Variables: Variable [0008] = [Zack]'s EXP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 3
@> Control Variables: Variable [0008] = [Zack]'s HP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 4
@> Control Variables: Variable [0008] = [Zack]'s MP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 5
@> Control Variables: Variable [0008] = [Zack]'s MHP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 6
@> Control Variables: Variable [0008] = [Zack]'s MMP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 7
@> Control Variables: Variable [0008] = [Zack]'s ATK
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 8
@> Control Variables: Variable [0008] = [Zack]'s DEF
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 9
@> Control Variables: Variable [0008] = [Zack]'s MND
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 10
@> Control Variables: Variable [0008] = [Zack]'s AGI
@> End Event Processing
@>
: Branch End
@>
: Branch End
@> Comment: ----- ACTOR 2 -----
@> Conditional Branch: Variable [0006:GetActorStat ActorID] == 2
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 1
@> Control Variables: Variable [0008] = [Albert]'s Level
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 2
@> Control Variables: Variable [0008] = [Albert]'s EXP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 3
@> Control Variables: Variable [0008] = [Albert]'s HP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 4
@> Control Variables: Variable [0008] = [Albert]'s MP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 5
@> Control Variables: Variable [0008] = [Albert]'s MHP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 6
@> Control Variables: Variable [0008] = [Albert]'s MMP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 7
@> Control Variables: Variable [0008] = [Albert]'s ATK
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 8
@> Control Variables: Variable [0008] = [Albert]'s DEF
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 9
@> Control Variables: Variable [0008] = [Albert]'s MND
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 10
@> Control Variables: Variable [0008] = [Albert]'s AGI
@> End Event Processing
@>
: Branch End
@>
: Branch End
@> Comment: ----- ACTOR 3 -----
@> Conditional Branch: Variable [0006:GetActorStat ActorID] == 3
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 1
@> Control Variables: Variable [0008] = [Vance]'s Level
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 2
@> Control Variables: Variable [0008] = [Vance]'s EXP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 3
@> Control Variables: Variable [0008] = [Vance]'s HP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 4
@> Control Variables: Variable [0008] = [Vance]'s MP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 5
@> Control Variables: Variable [0008] = [Vance]'s MHP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 6
@> Control Variables: Variable [0008] = [Vance]'s MMP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 7
@> Control Variables: Variable [0008] = [Vance]'s ATK
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 8
@> Control Variables: Variable [0008] = [Vance]'s DEF
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 9
@> Control Variables: Variable [0008] = [Vance]'s MND
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 10
@> Control Variables: Variable [0008] = [Vance]'s AGI
@> End Event Processing
@>
: Branch End
@>
: Branch End
@> Comment: ----- ACTOR 4 -----
@> Conditional Branch: Variable [0006:GetActorStat ActorID] == 4
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 1
@> Control Variables: Variable [0008] = [Craise]'s Level
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 2
@> Control Variables: Variable [0008] = [Craise]'s EXP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 3
@> Control Variables: Variable [0008] = [Craise]'s HP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 4
@> Control Variables: Variable [0008] = [Craise]'s MP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 5
@> Control Variables: Variable [0008] = [Craise]'s MHP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 6
@> Control Variables: Variable [0008] = [Craise]'s MMP
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 7
@> Control Variables: Variable [0008] = [Craise]'s ATK
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 8
@> Control Variables: Variable [0008] = [Craise]'s DEF
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 9
@> Control Variables: Variable [0008] = [Craise]'s MND
@> End Event Processing
@>
: Branch End
@> Conditional Branch: Variable [0007:GetActorStat StatID] == 10
@> Control Variables: Variable [0008] = [Craise]'s AGI
@> End Event Processing
@>
: Branch End
@>
: Branch End


Break Up Number Common Event

@> Comment: Take a variable and break it up into its various digits
: : Supports up to the thousands digit (4th digit)
@> Comment: "BreakUp SourceVarID" Variable ID to break up
: : "BreakUp DestID" Variable ID of thousands digit to write
: : digits to. Assumes next four Variables are for hundreds,
: : tens, and ones digits.
@> Comment: ==================
@> Comment: THOUANDS
@> Control Variables: Variable [0011] = Variable ID [V[0010]]
@> Control Variables: Variable [0011] /= 1000
@> Control Variables: Variable [0011] %= 10
@> Control Variables: [0011:BreakUp DestVarID] += 1
@> Comment: HUNDREDS
@> Control Variables: Variable [0011] = Variable ID [V[0010]]
@> Control Variables: Variable [0011] /= 100
@> Control Variables: Variable [0011] %= 10
@> Control Variables: [0011:BreakUp DestVarID] += 1
@> Comment: TENS
@> Control Variables: Variable [0011] = Variable ID [V[0010]]
@> Control Variables: Variable [0011] /= 10
@> Control Variables: Variable [0011] %= 10
@> Control Variables: [0011:BreakUp DestVarID] += 1
@> Comment: ONES
@> Control Variables: Variable [0011] = Variable ID [V[0010]]
@> Control Variables: Variable [0011] %= 10
@> Comment: END

If you have any questions or need more help feel free to ask!
e: lol rmn
Wonderful. thank you very much. I can get to work on this straight away. OH, and sorry for not addressing your question. I do use the steam version of 2K3.
Hopefully it'll help you with your own efforts to make a menu system. Good luck!

e: although looking at the last update for 2k3 it might've not been necessary after all!
Pages: 1