TeensyMud - 'A ruby mud server.'

Subject: STDOUT switching and finding a mobiles socket
Subject: STDOUT switching and finding a mobiles socket
Author: Konji
Posted: 03/09/2009 06:26PM

I am trying to make a 'rubycode' command where a player can run commands like
'rubycode text_to_mobile findmobilebyname("Bob") 'test test test''

But if they do code like
'rubycode puts 'test''
They will just be returned nil if I try
text_to_mobile(eval(string)) with string being puts 'test'
they will just see 'nil' so I have to redirect stdout.
So I would do
$stdout.reopen(themobilessocket)

so how do I get the mobiles socket? Or is there a better way to do this?

reply
Subject: STDOUT switching and finding a mobiles socket
Author: Tyche
Posted: 03/10/2009 11:10PM

Konji wrote:
> I am trying to make a 'rubycode' command where a player can run commands like
> 'rubycode text_to_mobile findmobilebyname("Bob") 'test test test''
>
> text_to_mobile(eval(string)) with string being puts 'test'
> they will just see 'nil' so I have to redirect stdout.
> So I would do
> $stdout.reopen(themobilessocket)
>
> so how do I get the mobiles socket? Or is there a better way to do this?

I don't believe redirecting $STDOUT will work.
I don't believe puts is what you want to use inside eval.
You want to use text_to_mobile instead inside the eval.





reply