dockfries / infernus

Node.js library for scripting Open Multiplayer.
https://dockfries.github.io/infernus/
MIT License
21 stars 2 forks source link

Error creating an object #23

Closed Andonrai closed 1 year ago

Andonrai commented 1 year ago

I am creating an object but it returns undefined and I want to texture.

Code:

exampleObj return undefined

dockfries commented 1 year ago

Perhaps readme.md is not detailed enough and misleads the wrong usage.

You don't need to use @infernus/streamer separately, as objects/pickups inside @infernus/core are already using streamer.

Only when you separate from the @infernus/core library, you'll need to use @infernus/streamer separately.

The methods of the @infernus/streamer library are directly created and returned, so it's the same issue as with your previous pickup - it should be created within events instead of outside of them.

import { GameMode, DynamicObject } from "@infernus/core";

const obj = new DynamicObject({
  // your object params
});

const gm = new GameMode();
// Everything about game should be in events, such as OnGameModeInit or OnPlayerCommandText
gm.onInit = () => {
  obj.create();
  obj.setMaterial(/* material params */);
};

life-circle

dockfries commented 1 year ago

If there is still a problem, open the issue again