View previous topic :: View next topic |
Author |
Message |
Fireboar
Joined: 17 Feb 2008 Posts: 323
|
Posted: Tue Jul 06, 2010 1:02 Post subject: |
|
|
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 |
|
|
elven
Joined: 28 Jul 2006 Posts: 259 Location: Germany
|
|
Back to top |
|
|
nelak
Joined: 05 Oct 2012 Posts: 7
|
Posted: Wed Mar 27, 2013 22:22 Post subject: |
|
|
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 |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Thu Mar 28, 2013 0:26 Post subject: |
|
|
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 |
|
|
elven
Joined: 28 Jul 2006 Posts: 259 Location: Germany
|
Posted: Thu Aug 07, 2014 13:23 Post subject: |
|
|
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 |
|
|
|