RPG Maker Forums

Description

Allows access to objects without holding a direct reference. If an object is only referenced by weak references, it may be garbage collected at any time.

Prerequisites

None

How to Use

A weak reference to <object> is created and accessed like this:

weakref = IAVRA::WeakRef.new(<object>)weakref.objectThe object method will return nil if <object> is no longer accessible. Objects keep a list of backreferences to WeakRef objects referencing them.When a WeakRef is garbage collected, it will remove itself from the backreferences of the object it was referencing.

Note: WeakRefs should NOT be stored in savefiles. The finalizers might not be serializable and the list of references is not stored in a persistant way.

Also, finalizers are not threadsafe, so if you are insane enough to attempt any kind of multithreading, you would need to extend the methods with some kind of lock or mutex.

Terms of Use

Free to use for both commercial and non-commercial games. Please give credit.

Credits

Iavra

FAQ

Q: Why should i use this?

A: I came up with the idea of using weak referencing because i wanted to change the way my Animate Everything works. Currently, every object handles its own animations, but needs an update method to do so.

So i wanted to move all the logic inside my module, but directly referencing the animated object means, that they wouldn't get garbage collected as long as an animation is running on them.

This is why i want to keep a weak reference instead.

Changelog

- 1.00: First version.

- 1.01: Added a hash method to ensure equality in hashs.

Download

Script: http://pastebin.com/jAxqnNdh

Latest Threads

Latest Posts

Latest Profile Posts

He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!

Forum statistics

Threads
106,035
Messages
1,018,459
Members
137,821
Latest member
Capterson
Top