Save-Point

Full Version: How can I use the cmd of "require" in rgss
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to make a game in Internet.I have already done it by win32API. Now I think whether I use the cmd of "require" to import Ruby's lib??
tip: I'm a Chinese and weak in English....... Sad
我從來沒有嘗試過使用它,直到如今。我不認為它喜歡我。甚至當我用的是整個文件路徑,我收到一個錯誤。它說,該文件不存在,甚至與整個路徑。

我只是複製使用它的腳本到腳本庫,而不是。一個.RB文件只是Ruby代碼的文本文件反正。至少,這就是每次我反正看到。

這與谷歌翻譯。我的中國是很好的餐廳,沒有別的訂購。



I never tried to use it until now. I do not think it likes me. Even when I use the entire file path, I receive an error. It says the file does not exist, even with the whole path.

I would just copy the script into the script library instead of using it. A .rb file is just a text file of ruby code anyway. At least, that's what every I've seen anyway.

------------ Anyone else??? ---------------
You could try using load instead of require. Here is a small script to test it.

File contents
Code:
class NewsUpdate
    attr_reader :recent_events
  def initialize
      @recent_events = ['Eh...']
      print 'These are the news!'
    end

    def print_news
        print @recent_events.join("\n")
    end
end

Script call to load the file

load Dir.pwd + '/print text.rbw'

Simple example of how to create a new copy of the class included in the file only

$news = NewsUpdate.new

Simple example of how to call one of its methods by meas of a script call

$news.print_news

The downside of load methods is that it will actually load the file contents every time they are called. At least that's what happens on normal situations.