ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Mon Dec 11, 2017 6:56 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Subclassing Projectile
PostPosted: Thu Jul 25, 2013 2:12 am 
Offline
Thalore

Joined: Mon Mar 25, 2013 10:09 pm
Posts: 153
Subclassing Projectile doesn't seem to work as intended.

If I do the following:

  • In Actor.lua, set _M.projectile_class = "mod.class.Projectile"
  • Create a Projectile.lua file in the class directory that inherits from engine.Projectile
  • Define a makeProjectile method that invoke engine.projectile.makeProjectile and then does a bit of its own processing.
  • Define an act method

Then my makeProjectile is called as expected, but act is not.

From what I can tell, this is because engine.Projectile:makeProject calls _M.new, which creates an instance of engine.Projectile instead of my mod.class.Projectile.

It seems to me that makeProject and makeHoming should instead call self.new to make it possible to properly subclass Projectile.

Am I understanding this correctly?

As a side question, is there an easy way to test engine modifications of this sort, short of building the entire ToME project from scratch?

_________________
Qi Daozei (QDZ) - an Oriental-themed fantasy game for T-Engine. ToME Tips - auto-generated spoilers for ToME.


Top
 Profile  
 
PostPosted: Thu Jul 25, 2013 8:46 pm 
Offline
Uruivellas

Joined: Fri May 24, 2013 4:27 pm
Posts: 712
Yeah, just unpack engine into an appropriate dir and do whatever changes you need. You will disable your online profile, but it'll work.


Top
 Profile  
 
PostPosted: Fri Jul 26, 2013 1:26 am 
Offline
Thalore

Joined: Mon Mar 25, 2013 10:09 pm
Posts: 153
Thanks. I had tried unpacking the engine and was simply using the wrong directory name.

In case anyone else is interested, here are step-by-step instructions:

  1. Unpack game/engines/te4-1.0.4.teae to the directory game/engines/te4-1.0.4. (For example, if using 7-zip, you can just right-click on te4-1.0.4.teae in Windows Explorer and choose 7-zip -> Extract to "te4-1.0.4\")
  2. Unpack game/modules/tome-1.0.4.team to the directory game/modules/tome-1.0.4. (Again, if using 7-zip, you can right-click on tome-1.0.4.team in Windows Explorer and choose 7-zip -> Extract to "tome-1.0.4\").
  3. The directory layout of tome-1.0.4 won't match what ToME is expecting. Go under tome-1.0.4\mod and move all files and directories from there to tome-1.0.4.

After I did this, I was able to confirm that changing engine.Projectile:makeProject and engine.Projectile:makeHoming to call self.new instead of _M.new fixes this problem.

I also discovered that ToME itself is affected by this bug. ToME's Projectile.lua includes code to animate projectiles and to show internal information in the tooltip if a projectile is hovered over and cheating is enabled, and that code doesn't work. To demonstrate, create a new archmage, go to the Abashed Expanse (which will have lots of projectiles flying around), turn on cheating, and set "smooth creatures movement" all the way up to 60. Projectile movement will animate much, much faster than character movement (because it's ignoring ToME's customization of animation speed), and the projectile tooltip contains no additional information. (ToME's Projectile:tooltip contains a different, unrelated bug: tstring() should be tstring{}.)

_________________
Qi Daozei (QDZ) - an Oriental-themed fantasy game for T-Engine. ToME Tips - auto-generated spoilers for ToME.


Top
 Profile  
 
PostPosted: Fri Jul 26, 2013 8:18 am 
Offline
Master of Eyal

Joined: Wed Jul 24, 2002 9:26 pm
Posts: 10144
Location: Angolwen
Ohoh yes indeed!

Fixed thanks :)

_________________
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group