RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
script: addressing a numbered list?

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 82
We learn by living...
if I have several variables or items ending in numbers in a sequence

like

sword1
sword2
sword3
sword4...

and I want to ask the computer something like  "if swordX == sword2"

is there a syntax I can use so I don't have to ask the same question a dozen times or more?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
It's probably be more helpful if you were more specific. Is sword2 a variable too? Depending on what you want it to be it could be as simple as an include? check or a case branch, or it could require an eval check (not a very efficient option) but I don't know unless you say what you actually want to do. It'd be better if you wrote out the way you know it could be done, and then I could tell you what would be a more efficient way from that.

***
Rep:
Level 82
We learn by living...
here's an example chunk...

Code: [Select]
a = $data_system.party_members[0]

if $game_variables[13] == 7
$game_actors[a].element7 += 1
end
if $game_variables[13] == 8
$game_actors[a].element8 += 1
end
if $game_variables[13] == 9
$game_actors[a].element9 += 1
end

considering I've got element1-18,

and each one is about to be revised to look like this

Code: [Select]
a = $data_system.party_members[0]

if $game_variables[13] == 1
$game_actors[a].element1 += 1
end
$game_actors[a].mod_aff -=
$game_actors[a].element1

I really need a way of cutting it down. What's really bothering me is I don't want characters spending points they don't have, but I can't figure out how to put in a conditional branch that asks if player 1's aff attribute

Code: [Select]
$game_actors[a].aff

is equal to or higher than than player1's element attribute

if i could stick this

Code: [Select]
a = $data_system.party_members[0]

inside the conditional script box along with the statement

$game_actors[a].aff >= $game_actors[a].element1

it would simplify the code. But I think I'm babbling at this point, as that's unrelated to your question and I apologize. Usually by the time I get a reply to a question i've already run into another problem.

***
Rep:
Level 82
We learn by living...
well i fixed the conditional:

a = $data_system.party_members[0]; $game_actors[a].aff >= $game_actors[a].element1

I didn't know you could use semicolons in ruby until today.

********
Hungry
Rep:
Level 96
Mawbeast
2013 Best ArtistParticipant - GIAW 11Secret Santa 2013 ParticipantFor the great victory in the Breakfast War.2012 Best Game Creator (Non-RM Programs)~Bronze - GIAW 9Project of the Month winner for December 2009Project of the Month winner for August 20082011 Best Game Creator (Non RM)Gold - GIAW Halloween
just use an array.

nvm, misunderstood your question.

what you -can- do is just store $game_party.actors[0].whatever in a variable if you want, so that it doesn't have to fetch the data every time.

I'm still not quite sure what you're asking.

FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Is there some reason why, instead of element1, element2, etc..., you can't just make a single variable called elements or something which is just an array.

elements = [nil, 1, 2, 3, etc..., n]

Then you could just access it by elements[n]?


Then all you'd have to do is:

Code: [Select]
$game_actors[a].elements[$game_variables[13]]

***
Rep:
Level 82
We learn by living...
Is there some reason why, instead of element1, element2, etc..., you can't just make a single variable called elements or something which is just an array.

elements = [nil, 1, 2, 3, etc..., n]

Then you could just access it by elements[n]?


Then all you'd have to do is:

Code: [Select]
$game_actors[a].elements[$game_variables[13]]

Because I don't know how. So instead I programmed them like attributes with a stat range of 1-6. Here's a screen shot.

Spoiler for: