You could use both ways, they're just a bit different logic.
The first method (the one on the previous page) is like:
If the leader is Eric, do this
If the leader is Whoever, do this
The second (Shaz' method) is just like
If Eric is leader, do this
If whoever is leader, do this
Thanks. Okay so I forgot if I asked this before, but how can I extract the values of this hash?
State = { 1 => [1, 2, 3, 4, 5, 6, 7] }since it is an array value, how can I extract those?
Thanks Kaelan. Another quick question, is there a substitute or a better way to print out documents on a file? For example, I uses syswrite:
targa = File.new("input.txt", "r+") if targa targa.syswrite("Marry had a little lamb") else puts "Unable to open file!" endNow of course, it is understandable that you need to have the input.txt on your game folder. So my questions would be:
How can I automatically create the input.txt on my game folder?
How can I append the texts instead of using syswrite that just writes from one line. Because if I want to add :
Mary had a little lamb,little lamb, Marry had a little lamb,little lamb, little lambI don't exactly know how.
Can anyone help me in this?
So, I have the following hash:
BIG_HASH => { 0 => {contents}, 1 => {contents}, 2 => {contents}, 3 => {contents},# and so on...}So, hashes in a big hash.How can I remove an entire hash from the BIG_HASH?
But not permanently, only temporary to make a check without that specific hash I want to remove.
Is it possible to do?
I make something with 'BIG_HASH.each do |x, y|', which in the end will return 'X' hash from that BIG_HASH.
Then after this check, I would like to do the same thing, but now with '(BIG_HASH - X).each do |x, y|' hash.
And I can't figure it out how could I do this. >.>
Sounds like you need a separate hash to store the removed elements in.
But why do you need to remove things, then immediately re-add them? It sounds like what you're might not be the best solution to whatever problem this code is trying to solve. It's hard to say exactly what to do without more context on the problem, but my guess is you're probably not going about it the right way.
Does anyone know what the largest integer value I can store in a variable in Roby is? I know in C it was around 4 billion (back in the 90's), but am wondering if Ruby is under any such restriction?
Thanks Shaz, it worked...
But broke my first check. 😀
Yeah, I guess I will need to find another way of checking for the second item from the hash list.
I just want to eliminate the first selected item from the hash list when checking for the second item, because it will stop the second check at the first match from the big hash, and if it is the same as the first item, it won't do anything, even if there are other matching items below the first selected item. I suppose it is because of the return method I use.
Ohh, well, gonna think for a suitable solution.
No, not randomly.
I am modifying Vlue's Formation Bonus Script to allow multiple formations.
The actors need to be at the right place to activate a formation on the formation scene.
And everything works fine, until the second formation which would be activated is below the first formation on the hash list, in which case it returns no formation at all.
That is my only problem, and gives me a lot of headache.
The checking method is the same for both formations, but the second one only activates if there is an active formation already, and got more checks built in to prevent selecting the same formation as the first one and some other optional checks, which can be enabled/disabled at will (for disabling nested formations, etc).
Tried to eliminate the first formation from the second list with conditional checks, which usually works in '.each do' loops, but for some reason, it does not work here.
I'm not sure that I can explain the checking methods fully in real scripting language.
Basically, I made a copy/paste from the first check, added some extra conditions to it, and that's it.
But just now, I tried with cloning the hash, and when printing out the keys of the new hash after removing the key onto the console, it shows that the key of the first item is indeed removed, yet it will not activate the second formation.
And when printing out the second match (the second formation), it prints out the correct one, yet won't activate it.
Maybe there is another problem I don't see.
Ohh, well, need to go to work now, will try again later.
Thanks for the help!
I suggest you start a new thread, as this is obviously not a simple question with a simple answer, and we are guessing at the solutions based on incomplete information about what you're trying to accomplish.
Provide ALL the details of what you're trying to do. A link to the script, what the hash actually is, and what you're trying to do with it. What are you trying to achieve from the player's point of view?
Please post all of this in a new thread in Script Support.
You have already asked this question. Please don't post the same question in multiple places. Neither place you posted is the correct place - we have a forum specifically for RMXP (RGSS) Script Requests. I have moved your other thread there.
I have learned in a tutorial that this is the right way of using the system read for files in RPG Maker:
aFile = File.new("input.txt", "r")if aFile content = aFile.sysread(20) puts contentelse puts "Unable to open file!"endand the right way for system write:
aFile = File.new("input.txt", "r+")if aFile aFile.syswrite("ABCDEF")else puts "Unable to open file!"endHowever, the syswrite only allows me to write one line in the text method. How can I add more lines to it like line 1, line 2, line 3 etc? Another question, how can I make RPG Maker read it and incorporate it to something such as item descriptions etc?