@Darren said in Learning Ruby for Ares:
Basically she means that Ares doesn't have anything like MUSH attributes which allow you to store random data on any object. Persistent data needs to be stored in a database model and the model will have to be designed specifically to hold the data that you want to store.
In case anyone's curious... here's a couple quick examples of how this works.
Say you want to just add a simple field to all characters for their favorite color.
Penn/Tiny Version:
&favcolor *Bob=Blue # Sets Bob's favorite color
get(*Bob,favcolor) # Returns "Blue"
Ares Version:
class Character
attribute :favcolor
end
Character.named("Bob").update(favcolor: "Blue") # sets Bob's favorite color
Character.named("Bob").favcolor # returns 'Blue'
The main difference is that we need to define the attribute ahead of time via code before we can use it. As Darren said, we can't just wing it and and set any random attribute from within the client.
ETA: Oh, and the other big difference being that Ares code is generally edited server-side and not typed raw into the client.
Now let's say you wanted to have weapon objects so Bob can have a gun:
Penn/Tiny Version:
@create Weapon Parent
(some other code on the weapon parent to control what the weapon does)
@create Bob's Gun
@parent Bob's Gun=Weapon Parent
&ammo Bob's Gun=10
&type Bob's Gun=Blaster
give Bob's Gun=*Bob
Ares Version:
class Weapon
attribute :name
attribute :type
attribute :ammo
reference :character, "AresMUSH::Character"
(some other code on the weapon parent to control what the weapon does)
end
gun = Weapon.new(
name: "Bob's Gun",
type: "Blaster",
ammo: 10,
character: Character.named("Bob"))
The main difference here is that in Ares the 'shoot' command would live in a separate command class. It would utilize properties of the weapon class; the commands are just not tied to individual database objects.
The syntax is different obviously, but the core ideas are still the same.