logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
NWNX Ruby
Goto page Previous  1, 2, 3, 4
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux development
View previous topic :: View next topic  
Author Message
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Tue Jul 06, 2010 1:02    Post subject: Reply with quote

I mentioned it to Virusman earlier but... well, for want of a more permanent and public medium, here it is again. Calling "system" in nwnx_ruby appears to have an odd effect. Sample Ruby code:

Code:
puts ENV['PATH']
puts system "echo sample"


Output when code is run:

Code:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

NWNX2lib: Init
false


Most unusual is the NWNX2lib: Init line. This seems to imply that the NWNX initialization code is being run a second time, but none of the other init lines appear. Very odd.


But while I'm here, that brings up a question. Is there any way currently to execute shell commands via NWNX? I'd imagine it would be possible, but I haven't seen a plugin to that effect yet.
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Sat Jun 30, 2012 16:10    Post subject: Reply with quote

TWIMC:

I've converted nwnx_ruby to version 1.9. The code, as it is very experimental, lives in my integration branch at https://github.com/niv/nwnx2-linux.

There's a CI-built binary as well: http://ci.swordcoast.net/job/nwnx2-linux-n/lastSuccessfulBuild/artifact/plugins/ruby/

And nwn-lib has been upgraded to require ruby 1.9 starting version 0.5.0.

The easiest way to get started with ruby 1.9 is by using rvm. Distro packages are outdated, at least on debian squeeze.
Back to top
View user's profile Send private message
nelak



Joined: 05 Oct 2012
Posts: 7

PostPosted: Wed Mar 27, 2013 22:22    Post subject: Reply with quote

This might seem like a silly question - but how do you use the Ruby plugin? There is no documentation and I've tried reading the source code but it doesn't really clarify much.

The sample nss file shows how to call Ruby butw here exactly should my .rb files be stored?

Are there lines I need to add to my config file?
Back to top
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Thu Mar 28, 2013 0:26    Post subject: Reply with quote

It just evals a piece of code you supply to it. If you have .rb libraries you want to use, just call require/require_relative.
_________________
In Soviet Russia, NWN plays you!
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Thu Aug 07, 2014 13:23    Post subject: Reply with quote

FWIW, the proper way on how to set up a working LOAD_PATH for rubygems is to do this:

Code:

export GEM_HOME=/usr/local/rvm/gems/ruby-2.1.2
export GEM_PATH=/usr/local/rvm/gems/ruby-2.1.2:/usr/local/rvm/gems/ruby-2.1.2@global


You need to export GEM_HOME and GEM_PATH before running nwserver with NWNX. You can get that from your ruby by simply running:

Code:
ruby -e 'puts ENV["GEM_PATH"], ENV["GEM_HOME"]'


Once you've done that, you can just normally do
Code:
require 'rubygems'
require 'nwn/all' # or whatever gem you want to use.

I'm sure you could use bundler too if you wanted to.

------

Aside:

Note that my example points at ruby 2.1.2 installed with rvm. This wont work unless you recompile nwnx_ruby to link against that and add libruby.so to LD_LIBRARY_PATH:

Code:
source /usr/local/rvm/scripts/rvm && rvm use 2.1
export LD_LIBRARY_PATH=/usr/local/rvm/rubies/ruby-2.1.2/lib:$LD_LIBRARY_PATH


If you run your distro ruby, then that's not needed.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux development All times are GMT + 2 Hours
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group