• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Help with js.

Newbie Spellweaver
Joined
Nov 26, 2008
Messages
7
Reaction score
0
Hi guys, i have the next problem.
Im trying to make a cube npc, there's no error on the console, but still not working.

Code:
var status = -1;
var equip;
var selected;
var state;
function start() { 
        cm.sendNext("Hello! I can cube your items, please go ahead.");
	}
 function action(mode, type, selection) { 
   if (mode < 1)
        cm.dispose();
    else {
        if (mode == 1 && status != 3)
            status++;
        if (status == 0)
		cm.sendSimple("Wich item would you like to cube?\r\n" + cm.EquipList(cm.getC()));
        else if (status == 1) {
		selected = selection;
		state = equip.getState();
		equip = cm.getEquip(selection);
		cm.sendOk("What would you like to edit on your #b#t"+equip+"#? #k:)");
		} else if (status == 2){
		cm.sendOk("Hello!");
		}


	 }	
	cm.dispose();
 }

The problem is, that when i choose the item i want to cube the chat window closes immediately.

Code:
		cm.sendSimple("Wich item would you like to cube?\r\n" + cm.EquipList(cm.getC()));

Thats the last line that the npc reads.
Thanks in adv.
 
Custom Title Activated
Loyal Member
Joined
Jan 18, 2010
Messages
3,109
Reaction score
1,139
Code:
state = equip.getState();
equip = cm.getEquip(selection);
For starters, you haven't even declared equip yet, yet you define "state" which uses a reference to "equip" of null.

Code:
#b#t"+equip+"#?
Next off, you do + equip + in your message, but are you sure cm.getEquip is an integer, or an actual object of type Item? You likely need to do + equip.getItemId() + instead.
 
Upvote 0
Back
Top