nanos-world / issues

Issue Tracker for nanos world
9 stars 1 forks source link

Custom Classes not passed properly into events #893

Open vugi99 opened 1 year ago

vugi99 commented 1 year ago

Prerequisites

Your Environment

Description

Custom Classes not passed properly into events

Steps to reproduce the behavior

Grab the vbot package

and do this in another package :

local bot1 = VBotJoin()

print(bot1:GetControlledCharacter())
Events.Subscribe("TestPass", function(bot)
print(bot:GetControlledCharacter())
end)
Events.Call("TestPass", bot1)

Expected behavior

Should keep the class methods

Actual behavior

image

vugi99 commented 1 year ago

Seems like this is a very old issue Should be reconsidered now that we have the new VM thing... (you can clearly pass the functions and it shouldn't be a problem now)

For remote events i'm unsure what you could do there. (I can kinda fix it myself anyway so there's something to do but it's much more complicated in this case)

gtnardy commented 1 year ago

yeah I guess this never worked, because Events is passing the bot table as parameter, and it is being serialized/deserialized in the call, so it loses the metatable and so on

vugi99 commented 1 year ago

Should be looked into as I said If you don't want to implement it I'll use Modularity to do that properly...

gtnardy commented 1 year ago

I would say to you to use the new Inheriting System instead, I don't think I will take a look that soon because it changes a lot of things

vugi99 commented 1 year ago

Inheriting from Player ??? Doesn't sound like a good idea, nanos will probably stop me when trying that.

gtnardy commented 1 year ago

you probably could try making it inheriting from Character

vugi99 commented 1 year ago

It doesn't share any method so that's not the way. I'll just wrap any Events.Subscribe and Events.SubscribeRemote function to set the metatable again if a bot is in the arguments

vugi99 commented 1 year ago

Modularity will allow that in a future update I’ll introduce a self made events system