Anteworld - Outerra Game > JavaScript development

Methods

(1/13) > >>

SteelRat:
Hi Cameni!


--- Code: ---/*
file: hero.js
*/

"use strict";

$include("scripts/config.js");
$include("scripts/functions.js");

function initialize(reload)
{
this.set_character_model("outerra/mercenary/mercenary");

addWeapon(this, "AK_74M");
}

...

--- End code ---


--- Code: ---/*
file: functions.js
*/

function addWeapon(unit, weapon) {

var cfgWpn = cfgWeapons[weapon];

if (cfgWpn.scope) {
var cfgWpnBase = cfgWeapons[cfgWpn.base];

unit.set_weapon_model(cfgWpnBase.pack); // model is created
var wpn = unit.get_geomob(1);

for (var meshIdx in cfgWpnBase.meshes) {
if (cfgWpn.meshes.indexOf(cfgWpnBase.meshes[meshIdx]) < 0) {
// operations on arrays are correct
try {
wpn.set_mesh_visible(cfgWpnBase.meshes[meshIdx], false); // Error
} catch(e) {
unit.log_err("PTM: set_mesh_visible: " + e);
}
}
}
}
}

--- End code ---


--- Code: ---ERROR: PTM: set_mesh_visible: TypeError: Cannot call method 'set_mesh_visible' of null
ERROR: PTM: set_mesh_visible: TypeError: Cannot call method 'set_mesh_visible' of null
ERROR: PTM: set_mesh_visible: TypeError: Cannot call method 'set_mesh_visible' of null
...

--- End code ---

What am I doing wrong?

And yet, it's correctly?

--- Code: ---var wpn = unit.set_weapon_model(cfgWpnBase.pack);

--- End code ---

PytonPago:
Now when i look at the functions.js ... if ya want to hide a mesh, you have to define its id´s -- (  this.illumfp002_id = this.geom.get_mesh_id('002'); ) ... not sure, but id say you just try to hide them based on the meshes names itself, but it probably needs the "_id" (all the meshes ID´s defined) part on the end and then --- ( this.geom.set_mesh_visible_id(this.illumfp002_id, false); ) ...

SteelRat:

--- Quote from: PytonPago on May 12, 2015, 03:13:29 pm ---Now when i look at the functions.js ... if ya want to hide a mesh, you have to define its id´s -- (  this.illumfp002_id = this.geom.get_mesh_id('002'); ) ... not sure, but id say you just try to hide them based on the meshes names itself, but it probably needs the "_id" (all the meshes ID´s defined) part on the end and then --- ( this.geom.set_mesh_visible_id(this.illumfp002_id, false); ) ...

--- End quote ---

Тут проблема другого характера, в созданном объекте "wpn" отсутствует метод "set_mesh_visible()".

SteelRat:
The problem is solved.
And the result of me not impressed (
The result has killed my idea!

PytonPago:

--- Quote from: SteelRat on May 13, 2015, 04:36:48 pm ---The problem is solved.
And the result of me not impressed (
The result has killed my idea!

--- End quote ---

 ... why ? ( could you share the files ? )

Navigation

[0] Message Index

[#] Next page

Go to full version