Jump to content

Trouble adding a simulation component


Recommended Posts

So, I want to add a new simulation component. There is no documentation about it, so I tried replicating the existing components' setups. Here is what I did:

I put my script in simulation/components/. It calls Engine.RegisterComponentType() at the end. Additionally, I created a script of the same name inside simulation/components/interfaces/ running Engine.RegisterInterface().

From searching the codebase I found most components only do exactly that. For mine, however, Engine.QueryInterface(SYSTEM_ENTITY, <Name>) still returns undefined...

Does anyone know why? What am I missing?

Link to comment
Share on other sites

3 hours ago, Stan&#x60; said:

See

https://docs.wildfiregames.com/pyrogenesis/writing-components.html

https://gitea.wildfiregames.com/0ad/0ad/wiki/TDD_Simulation

Did you add a component file and an interface file? Unless you reused one. Also your component should be in the template xml you're querying

Hmm, I still can't get it to work. I already added both the component and interface files. And I'm not querying a specific template, but the system entity (I want the code to be run globally).

I believe I've correctly registered the component type and interface. Does the component maybe need to be instantiated somehow?

(I've never worked with the simulation code before...)

Link to comment
Share on other sites

The last line in Stan's link is pretty important and different from a "normal" component type aswell so be sure to get that right.

If that doesn't solve it, could you share your code on pastebin or something?

Edited by Grapjas
  • Like 1
Link to comment
Share on other sites

1 hour ago, Grapjas said:

The last line in Stan's link is pretty important and different from a "normal" component type aswell so be sure to get that right.

Yes, that fixed it! I didn't notice there was a different function specifically for registering system component types.

Thanks for your help.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...