Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

jrpolidario

3
Posts
2
Topics
2
Following
A member registered Jul 08, 2019

Recent community posts

(2 edits)

Hi, not a DragonRuby developer here, but I think it should be `self.bar += 1` and not `bar += 1` because you are assigning a value to `bar` , otherwise if not prepending `self.`, `bar` is then treated as a local variable:

I tested below, and it works:

```ruby
class Foo
  attr_accessor :bar

  def initialize
    @bar = 0
  end

  def baz
    self.bar += 1
  end
end

def tick(args)
  args.state.f ||= Foo.new
  args.state.f.baz
  puts args.state.f.instance_variable_get(:@bar)
end
```

```
1
2
3
4
5
6
7
8
9
...
```

If I changed above into:

```
  def baz
    bar += 1
  end
```

... I get the same errors as yours:

> ERROR. The following hash reached a nil thrashing limit.

However, copying the code into my local mri ruby installation, I get the more familiar error:

NoMethodError (undefined method `+' for nil:NilClass)

Because `bar += 1 , translates to `bar = bar + 1`, and `bar`  at that point is not defined yet, so `bar (undefined) + 1` throws that `nil:NilClass` error.
Having said this though, I think the `mri` error message better described what the error was, though maybe because I'm just not used to DragonRuby errors yet.

Thank you! :)

(1 edit)

I searched for all instances of `require` keyword across all samples/* files, and none seem to have examples or documentation on how to require gems; in particular I want to require [mruby's `ostruct`] (https://github.com/ksss/mruby-ostruct). I read from a post here that `bundler` is planned to be supported in the future, but at the moment how do I install gems? I'm coming from "mri-ruby" background of either using `gem install ...` or including in `Gemfile`, to install gems. Any help would be appreciated. Thanks :)