PDA

View Full Version : Error script



stoiczkow
9th January 2019, 02:45
Hey Guys, could you help me see the problem? Thx.



******* script runtime error *******
undefined is not an entity: (file 'scripts/shop.gsc', line 330)
weap hide();
*
called from:
(file 'scripts/shop.gsc', line 107)
for(i=0;i<randomboxes.size;i++) randomboxes[i] thread randombox(randomweaps[i]);
*
called from:
(file 'scripts/ballerina.gsc', line 550)
thread scripts\shop::init();
*
called from:
(file 'maps/mp/gametypes/_callbacksetup.gsc', line 15)
[[level.callbackStartGameType]]();
*
started from:
(file 'maps/mp/gametypes/_callbacksetup.gsc', line 10)
CodeCallback_StartGameType()
*
************************************
Error during initialization:
script runtime error
(see console for details)
(file 'maps/mp/gametypes/_callbacksetup.gsc', line 10)

---------------------------it concerns this below

randombox(weap)
{
weap hide();
o = weap.origin;
cost = 500;

// init set of weapons in this randombox
self.weapons = [];
self.weaponsModel = [];

maxdamage99
9th January 2019, 04:14
randombox(weap)
{
if (!isDefined(weap))
return;

weap hide();
o = weap.origin;
cost = 500;

// init set of weapons in this randombox
self.weapons = [];
self.weaponsModel = [];


but, it's not fix all errors, try


developer 0


or use last libcod version's: developer errors - no stop server

Mitch
9th January 2019, 17:53
Here you call the function 'randombox' on the list and pass the weapon (with the same index as the box) via the first parameter:


for(i=0;i<randomboxes.size;i++) randomboxes[i] thread randombox(randomweaps[i]);

Your loop ran out of weapons therefore the variable 'weap' is now undefined (no entity) which results in a script runtime error.

You can do one of these options:

Make sure both lists are the same size.
Check randomweaps's size before calling the 'randombox' function.

stoiczkow
9th January 2019, 18:19
Here you call the function 'randombox' on the list and pass the weapon (with the same index as the box) via the first parameter:


for(i=0;i<randomboxes.size;i++) randomboxes[i] thread randombox(randomweaps[i]);

Your loop ran out of weapons therefore the variable 'weap' is now undefined (no entity) which results in a script runtime error.

You can do one of these options:

Make sure both lists are the same size.
Check randomweaps's size before calling the 'randombox' function.


if...return fixed this error. thx.
https://i.imgur.com/0a6oNbP.png