The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: shintashi on June 17, 2010, 03:34:23 PM

Title: How do I address the "words" for elements?
Post by: shintashi on June 17, 2010, 03:34:23 PM
for example, when I rename the element 001: Fire (in the database/system) to something like Heat,

so in the database it reads 001: Heat

how do I access the word "Heat"?

I've tried a wide variety of script and nothing works.

examples of my past failures...

p $data_system.words.element_ranks[1]

p $data_system.element_ranks[1].name

p $element_ranks[1].name

p $data_elements[1]

p $data_elements[1].name

p $data_system.words.data_elements[1]


I think I've run out ways to screw up a light bulb.
Title: Re: How do I address the "words" for elements?
Post by: cozziekuns on June 17, 2010, 03:42:58 PM
Once you realize that RPG:: can usually be substituted with $data, I'm sure you'll find this out by yourself.


Title: Re: How do I address the "words" for elements?
Post by: shintashi on June 17, 2010, 04:08:31 PM
Quote from: cozziekuns on June 17, 2010, 03:42:58 PM
Once you realize that RPG:: can usually be substituted with $data, I'm sure you'll find this out by yourself.

or not.

p $data.element[1]

p $data.elements[1]

p $element_set[1]

p $data.element_set[1]

...
Title: Re: How do I address the "words" for elements?
Post by: modern algebra on June 17, 2010, 04:09:47 PM
$data_system.elements[element_id]

Seriously shin, Help File ~ do a search for element and you will see RPG::System come up. Click on it and you will see:

Quote
elements

Element list. Text array using element IDs as subscripts, with the element in the 0 position being nil.
Title: Re: How do I address the "words" for elements?
Post by: tSwitch on June 17, 2010, 04:16:20 PM
Using the help file tends to take a little digging to find some things, but searching will get you in the right spot to start.

Also, why do you need to fetch the name from the array?  It's never going to change, and you already know which ID corresponds to which Element Name, as it's in the database.  Why not just use the ID?
Title: Re: How do I address the "words" for elements?
Post by: shintashi on June 17, 2010, 04:29:21 PM
Quote from: modern algebra on June 17, 2010, 04:09:47 PM
$data_system.elements[element_id]

Seriously shin, Help File ~ do a search for element and you will see RPG::System come up. Click on it and you will see:

Quote
elements

Element list. Text array using element IDs as subscripts, with the element in the 0 position being nil.

I got pretty close, with

p $data_system.words.element_ranks[1]
p $data.elements[1]


but I actually don't understand that sentence in the help file, and thought it meant it would display another range of 0-6. I'm an East Asian studies major, not a computer programmer.

>>

I needed the words because I'm constructing a Charisma stat that is exploiting the Element array to make a "likes/dislikes" table for stuff like good/evil, light/darkness, tech/nature, etc. I've got a second Status menu and I needed to know how to pull "words" for stuff like this:

when 5
      parameter_name = $data_system.words.agi
      parameter_value = actor.agi
    when 6
      parameter_name = $data_system.words.int
      parameter_value = actor.int


basically it would compare the numeric total of deviation from C between the actor and the NPC/enemy to determine a reaction score total. Players will get to choose "affinities" or ideas to symbolize, and then pump points in them. Their point pool is going to be based on something like charisma/10.

By spending the points, the elements display in their Status II screen (in theory), like equipment.
Title: Re: How do I address the "words" for elements?
Post by: tSwitch on June 17, 2010, 04:40:07 PM
Yeah but you can use the ID's for that.
You don't need the words.

In fact, you need the ID to get the word, you're just adding another step in there.  You'll always know the ID, and you'll always know which Element corresponds to which ID.  There's no need to dynamically grab the Element Name.  It's never going to change.  The amount of like-dislike might, but the name is never going to change.
Title: Re: How do I address the "words" for elements?
Post by: shintashi on June 17, 2010, 04:56:16 PM
Quote from: NAMKCOR on June 17, 2010, 04:40:07 PM
Yeah but you can use the ID's for that.
You don't need the words.

In fact, you need the ID to get the word, you're just adding another step in there.  You'll always know the ID, and you'll always know which Element corresponds to which ID.  There's no need to dynamically grab the Element Name.  It's never going to change.  The amount of like-dislike might, but the name is never going to change.

I'm programming in the stat for my fiancee's game, they don't do script, but have plans on changing the elements from the database in the future. otherwise I would just put "fire" etc. like when I added Faith

    when 8
      parameter_name = "Faith " #Faith added by Shin
      parameter_value = actor.faith 


my fiancee refuses to do script. So this is oddly less hassle.
Title: Re: How do I address the "words" for elements?
Post by: tSwitch on June 17, 2010, 04:57:48 PM
ok let's put it in pseudocode

> get the ID that they are modifying
> set a variable to the name of the element at ID
> if the variable name is "whatever"
> do blah blah blah

ALTERNATIVELY

> get the ID they are using
> if ID = number
> do stuff blah blah blah

less steps, thus less computing power is necessary to process it, making the script much more efficient.

You can use a simple switch/case to make it easy to configure for the non-scripter.  So much easier to just use the ID.
Title: Re: How do I address the "words" for elements?
Post by: modern algebra on June 17, 2010, 07:16:35 PM
I think he wants to draw out the name of the element, NAM, not use it as a reference. So have a window that says something like:

x resistance: 100%
y resistance: 120%

So have it take the values of x and y from the word set in the database and draw it on a window.
Title: Re: How do I address the "words" for elements?
Post by: tSwitch on June 17, 2010, 07:47:15 PM
Quote from: modern algebra on June 17, 2010, 07:16:35 PM
I think he wants to draw out the name of the element, NAM, not use it as a reference. So have a window that says something like:

x resistance: 100%
y resistance: 120%

So have it take the values of x and y from the word set in the database and draw it on a window.

if that's the case you could still use the ID's, but if you can find a way to use the names for that then it could be easier to configure.

you'd have to be careful that the ID's never changed though.