16 May, 2009, JohnnyStarr wrote in the 1st comment:
Votes: 0
Ok, so does this make sense? I've been thinking about writing scripts for rooms
by creating individual files for rooms. the rooms vnum would match the script file
so that if you wanted to make changes, you could do it on the fly.

likewise, you would have a .yml file to design the room, which would be loaded
during each reset. please consider that i have an OLC, but i cant access it at work
to build my mud, so i am limited to web and notepad, otherwise i would do it differently.

YAML:

!ruby/object:Room
vnum: 1333
name: pizza town
desc: You are standing in Pizza Town, its great here!


1333.rb:

Module Roomscript

def Rscript_1333(player)

r = self
r.name = "Changed." # just to show we did something.

end

end


Ok, so now we have two files per room, a script file and a yml file.

so wouldn't it work whenever we need to call the script to do this?

rscript = "Rscript_#{room.vnum}" # 'Rscript_1333'
room.send(rscript, player)
16 May, 2009, Stormy wrote in the 2nd comment:
Votes: 0
staryavsky said:
Module Roomscript

def Rscript_1333(player)

r = self
r.name = "Changed." # just to show we did something.

end

end


Why assigning self to r rather than using self.name?

Quote
so wouldn't it work whenever we need to call the script to do this?

rscript = "Rscript_#{room.vnum}" # 'Rscript_1333'
room.send(rscript, player)


The first argument of #send needs to be a symbol for the method. So, rscript = "Rscript_#{room.vnum}".to_sym

With that change, it should work as intended.
16 May, 2009, ghasatta wrote in the 3rd comment:
Votes: 0
Doesn't seem very scalable to have one file (or two files?) for each 'thing' in your game. If you wanted to apply the same behavior to multiple rooms, for example, wouldn't you have to replicate the same script file N number of times?
16 May, 2009, JohnnyStarr wrote in the 4th comment:
Votes: 0
Stormy said:
Why assigning self to r rather than using self.name?

eh, it was just a mockup, of course you could do self.whatever :biggrin:
16 May, 2009, JohnnyStarr wrote in the 5th comment:
Votes: 0
ghasatta said:
Doesn't seem very scalable to have one file (or two files?) for each 'thing' in your game. If you wanted to apply the same behavior to multiple rooms, for example, wouldn't you have to replicate the same script file N number of times?

Great observation, i was thinking of making a Script class for that very purpose, this way you would have something to the effect of script template methods that you could call within the room.

Module Roomscript
def Rscript_1333

Script.room_is_dark()
Script.kill_all_mobs()
Script.whatever_else_you_would_want_to_do()

end
end
0.0/5