Jump to content

Recommended Posts

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

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()

 

  • Thanks 1

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...