CREATING NEW ACTOR CONSTANTS
Posts
Pages:
1
Gentlemen! (Also ladies!) Countrymen (also country-ladies...lasses...w/e)! Scripters and the like! I am...in need!
My question is simple. How.....do I give the actors a brand new constant? You know how @level is a constant? And @hp, etc. And how you can reference these numbers in script formulas?
How do I create a new one and assign it to all actors? Let's say, for example, I want to create a variable called karma. So that later on I could make a script that references actor.karma, so it would also get the number for that particular actor.
Or in battle I could script an healing item that references "target.karma", or something like that.
How would I do create such a constant? I've tried and tried and can't seem to figure it out. It should be so simple, but it's not. Apparently... :/
My question is simple. How.....do I give the actors a brand new constant? You know how @level is a constant? And @hp, etc. And how you can reference these numbers in script formulas?
How do I create a new one and assign it to all actors? Let's say, for example, I want to create a variable called karma. So that later on I could make a script that references actor.karma, so it would also get the number for that particular actor.
Or in battle I could script an healing item that references "target.karma", or something like that.
How would I do create such a constant? I've tried and tried and can't seem to figure it out. It should be so simple, but it's not. Apparently... :/
...Someone else wanna explain this, or should I? I don't even know much of the non-2k3, and I'm pretty sure this is a bad idea.
Generally, you can't. Well, maybe you can, but... These things are constants, because they're pre-built into the system. Also, in C code (I know script uses Ruby, but this stuff is similar) we use the . to separate members in a class.
In other words, let's say I build a class saying target, and give it subsets like hp, mp, str, whatever. It's part of the internal coding definitions. Oh yea, because script is not like plugins, and you can actually see the internal code (by this, I mean stuff above the point where you normally edit below), you could possibly go to where they definite these members, and add in "karma" after the others. And add it in again, and again, and again, and again... every single time it's needed. They you need to know how to edit the database displays to make a slot for it. And how to make input, so you can change various aspects of it, even if all you want to do is make a checkbox. (Not to mention coding for behavior) Most of the people doing scripts do not appear to know how to edit the database (or won't tell you, because it's very complicated). So much of the scripts are more like plugins, adding stuff on, that run at startup time, rather than change the database.
Better solution? Learn to fake it by making a variable that stores it, and a few custom menus, possibly one set to constant display Karma.
Generally, you can't. Well, maybe you can, but... These things are constants, because they're pre-built into the system. Also, in C code (I know script uses Ruby, but this stuff is similar) we use the . to separate members in a class.
In other words, let's say I build a class saying target, and give it subsets like hp, mp, str, whatever. It's part of the internal coding definitions. Oh yea, because script is not like plugins, and you can actually see the internal code (by this, I mean stuff above the point where you normally edit below), you could possibly go to where they definite these members, and add in "karma" after the others. And add it in again, and again, and again, and again... every single time it's needed. They you need to know how to edit the database displays to make a slot for it. And how to make input, so you can change various aspects of it, even if all you want to do is make a checkbox. (Not to mention coding for behavior) Most of the people doing scripts do not appear to know how to edit the database (or won't tell you, because it's very complicated). So much of the scripts are more like plugins, adding stuff on, that run at startup time, rather than change the database.
Better solution? Learn to fake it by making a variable that stores it, and a few custom menus, possibly one set to constant display Karma.
Well let me first say this is being coded on VX Ace. And that's basically what I'm saying I want to do. I want to use a variable to store a value each actor has, then reference it elsewhere. My question is how can I do that?
Could I do:
Or something like that?
Could I do:
class Game_Actor
def karma
@karma = {}
end
end
Or something like that?
Maybe. But if I'm thinking about this right, it's not something you can just add in with a simple five line code.
It's more like this:
Also, if you have an editable Karma stat (I only have 2k3 since I'm poor, so deal with it) you have to create an editbox in the db. Like this:

Karma is probably going to influence other things, hence the need for switches/variables.
It's more like this:
class Game_Actor //or whatever it's called, you have to FIND it, not make it.
def hp, mp, str, def, etc
//or however it is, in ruby. each of these is defined out
//and already there, you have to actually add it in. It may fail.
//Also, you have to find various places in the code where you'd need to
//also add it, such as the battle scripts or skill casting.
end
end
Also, if you have an editable Karma stat (I only have 2k3 since I'm poor, so deal with it) you have to create an editbox in the db. Like this:

Karma is probably going to influence other things, hence the need for switches/variables.
actually it's just the opposite of a constant, it's a variable, but I understoof what Proteus meant.
You can't add a new field in the database, though, but Proteus probably doesn't need to, because he said he wanted to access it through scripts anyway ("Call script")
You can't add a new field in the database, though, but Proteus probably doesn't need to, because he said he wanted to access it through scripts anyway ("Call script")
Okay, thank you both! I asked someone else about this too, and they said the same thing, to use the attr_accessor function. So I guess that corroborates it! I've added it to my code (trying to make an item run pure code) and it hasn't given me an error for the "karma" stat yet. So it must be working. :)
Pages:
1















