hmaarrfk Posted September 7, 2016 Share Posted September 7, 2016 Hi, I'm trying to get a simple net_event up and running. I'm running a dedicated server, and an instance of DST to act as a client on the same computer. in modmain.lua, I have AddPrefabPostInit("world", function(inst) inst:AddComponent("mymod") end) mymod.lua, I have function MMEvent(parent) print("Whoa, events!") end local MyMod = Class(function(self, inst) print("Hello world") inst.mm_event = net_event(inst.GUID, "mm_event_name") inst:ListenForEvent("mm_event_name", MMEvent) end ) return MyMod I can confirm that mymod gets loaded into both the server and the client. On the server console, I type TheWorld.mm_event:push() But i never see the output "Whoa, events!" on the client console. Am I doing something wrong? Can somebody point me in the right direction? Thank you, your help is appreciated! Link to comment https://forums.kleientertainment.com/forums/topic/70025-help-with-net_events/ Share on other sites More sharing options...
DarkXero Posted September 9, 2016 Share Posted September 9, 2016 On 7/9/2016 at 4:26 AM, hmaarrfk said: Am I doing something wrong? Can somebody point me in the right direction? TheWorld is a non-networked entity. So attaching net variables to it doesn't work. AddPrefabPostInit("world", function(inst) inst:DoTaskInTime(0, function(inst) inst.net:AddComponent("mymod") end) end) However, the networked prefab attached to the world prefab does have a network component. Now you do: TheWorld.net.mm_event:push() 1 Link to comment https://forums.kleientertainment.com/forums/topic/70025-help-with-net_events/#findComment-811802 Share on other sites More sharing options...
Maris Posted September 9, 2016 Share Posted September 9, 2016 6 hours ago, DarkXero said: However, the networked prefab attached to the world prefab does have a network component. Wow! And I was using AddPrefab("world_network", ... (or cave_network or forest_network). Link to comment https://forums.kleientertainment.com/forums/topic/70025-help-with-net_events/#findComment-811850 Share on other sites More sharing options...
hmaarrfk Posted September 9, 2016 Author Share Posted September 9, 2016 Hi, Thank you so much for your help. Just as an FYI, AddPrefabPostInit("world", function(inst) inst:DoTaskInTime(0, function(inst) inst.net:AddComponent("mymod") end) end) did not work for me. NIClock was throwing errors on the client side. But AddPrefabPostInit("forest_network", function(inst) inst:AddComponent("mymod") end) AddPrefabPostInit("cave_network", function(inst) inst:AddComponent("mymod") end) did. Link to comment https://forums.kleientertainment.com/forums/topic/70025-help-with-net_events/#findComment-811879 Share on other sites More sharing options...
Monstah Posted March 3, 2025 Share Posted March 3, 2025 My mod is finally alive thanks to this! Would have saved me so much frustration if I had found this thread a year ago. I had given up on it. So happy now, thank you!!! Link to comment https://forums.kleientertainment.com/forums/topic/70025-help-with-net_events/#findComment-1803685 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now