New to Ruby, Need Help with Simple Script

ajilejay

Veteran
Veteran
Joined
Jul 17, 2013
Messages
64
Reaction score
0
First Language
English
Primarily Uses
Hello all I just picked up some ruby tutorials a few days ago and I thought of a way I could apply it to RPG Maker but I need a bit of help.

A lot of the things in the tutorial deal with virtual dogs and cats however I would like to apply these things to a in game virtual sheep.

I'm not really sure how to do it though. I felt like if I were shown how to do it once I could apply all the other things I learned to my sheep.

Basically what I would like to do is create a common script where all my sheep are declared a variable. And create a method to force my sheep to move randomly. I'm not 100% sure I phrased that right but I think you get what I mean. I want to be able to apply attributes both to individual sheep as well as all sheep.

Class Sheep
    def initialize
    

sheep = $game_map.events[sheep1, sheep2, sheep3, sheep4, sheep5, sheep6, sheep7]
 

Zetu

Level 99 Stabomancer
Veteran
Joined
Apr 28, 2012
Messages
247
Reaction score
99
First Language
English
Primarily Uses
N/A
I wouldn't make a Sheep class, nor is that a proper way to reference an array.  I am not even entirely sure what your trying to do.  Are you trying to get them to move randomly with a single method?
 

SlaveOfThaMind

Game Developer / Musician
Veteran
Joined
Jul 10, 2013
Messages
239
Reaction score
23
First Language
English
Primarily Uses
If you open the database, go to the second tab " Classes" 

In the bottom left is "change maximum" , allot yourself one extra space

Name it "Sheep"

Save

-----------------------------------------------------------

Agreeing with Zetu.. I'm not sure what you are trying to get out of a script. It isn't needed at all.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
If you open the database, go to the second tab " Classes" 

In the bottom left is "change maximum" , allot yourself one extra space

Name it "Sheep"

Save
 A ruby class (or any class in a programming language) has absolutely nothing to do with actor classes from an RPG ;)

@ajilejay: different types of variables require different forms of declarations.

I think you're trying to create an array where the elements can have additional values assigned to them?

In that case (as one way, there are probably better ways) you need to define an array as an instance of that class first, and it should not be initialised by the entire event data structure, but just given the ID of the events to each element of the array.

However I think it would be best if you temporarely stop trying to script it and tell us what you want to do first. There are several existing scripts that might be used instead if we know what you're trying to do (PKK8' self data suite for example)
 

ajilejay

Veteran
Veteran
Joined
Jul 17, 2013
Messages
64
Reaction score
0
First Language
English
Primarily Uses
I'm not actually trying to produce something in game for gameplay purposes. This is strictly to help me learn ruby better via RPG Maker. I want to apply my lessons to a sheep in game because I feel like it is more visual and clear to see the results in game than in command prompt.

 I would like to apply my lessons to things in the game. I feel like I could do this with a script and a event with a graphic of a sheep. What I wanted demonstrated for me was being able to manipulate a group of sheep both as a group and individually. Specifically I would like to know how to make them move randomly as a group as well as individually with a script. I feel like if I had an example to reference I could take it from there. I could apply my future and past ruby lessons to in game applications. I would greatly appreciate it!
 
 
Last edited by a moderator:

ajilejay

Veteran
Veteran
Joined
Jul 17, 2013
Messages
64
Reaction score
0
First Language
English
Primarily Uses
All I want to do is apply this to a actual sheep in game. I just want a example to draw reference from... PLEASE SOMEONE HELP

class Dog
def set_name( aName )
@myname = aName
end
def get_name
return @myname
end
def talk
return 'woof!'
end
end

mydog = Dog.new
mydog.set_name( 'Fido' )
p(mydog.get_name)
p(mydog.talk)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,574
Latest member
nikisknight
Top