Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I don't know whats wrong with this javascript - can anyone help me?: It is supposed to add a 2nd lot of quantity if you collect the same item twice, ie variable waters = 2 but doesn't work......so frustrating...anyone ? var slot = ccbGetCopperCubeVariable("slav"); var item = ccbGetCopperCubeVariable("watersProx"); var qty = ccbGetCopperCubeVariable("waters"); function allocateLoot() { qty=(qty+1); ccbSetCopperCubeVariable("waters",qty); if (qty=1) { print ("new item added"); if (slot=1) {ccbSetCopperCubeVariable("slt1",item)} else {if (slot=2) {ccbSetCopperCubeVariable("slt2",item)} else {if (slot=3) {ccbSetCopperCubeVariable("slt3",item)} else {if (slot=4) {ccbSetCopperCubeVariable("slt4",item)} else {if (slot=5) {ccbSetCopperCubeVariable("slt5",item)} else {if (slot=6) {ccbSetCopperCubeVariable("slt6",item)} else {if (slot=7) {ccbSetCopperCubeVariable("slt7",item)} else {if (slot=8) {ccbSetCopperCubeVariable("slt8",item)} else {if (slot=9) {ccbSetCopperCubeVariable("slt9",item)} else {if (slot=10) {ccbSetCopperCubeVariable("slt10",item)} else {if (slot=11) {ccbSetCopperCubeVariable("slt11",item)} }}}}}}}}}} print("value inside slt1 is "+item); ccbSetCopperCubeVariable("slav",(slot+1)); else {if (qty>1) {print ("extra item picked up")} } }} |
||||
|
var slot = ccbGetCopperCubeVariable("slav"); var item = ccbGetCopperCubeVariable("watersProx"); var qty = ccbGetCopperCubeVariable("waters"); function allocateLoot() { var nn=parseInt(qty); nn ++; ccbSetCopperCubeVariable("waters",nn); if (nn ==1) { // dont use many if then statements.. very slow switch(nn) { case 1: ccbSetCopperCubeVariable("slt1",item); break; case 2: ccbSetCopperCubeVariable("slt2",item); break; case 3: ccbSetCopperCubeVariable("slt3",item); break; default: break; } } else { {if (nn>1) {print ("extra item picked up")} } } ***************** way 2 **************************** var slot = ccbGetCopperCubeVariable("slav"); var item = ccbGetCopperCubeVariable("watersProx"); var qty = ccbGetCopperCubeVariable("waters"); function allocateLoot() { var nn=parseInt(qty); nn ++; ccbSetCopperCubeVariable("waters",nn); if (nn ==1) { var n = nn.toString(); var slotnam = "slt"+n; ccbSetCopperCubeVariable(slotnam,item); } else { {if (nn>1) {print ("extra item picked up")} } } |
||||
|
ps : coppercube variables getting by js are strings, not numbers... |
||||
|
Thanks for your help - will try the changes out and see how that looks... |
||||
|
Thanks again yalazkan: That was awesome - works perfectly ! I used the first example as I can follow that better for any additions later if necessary. I can see I have a long way to go as really just a newb when it comes to any programming language (except maybe Basic from 30 years ago..) Impressive - cheers !! |
||||
|
Thanks… Dont hesitate if you need any help :) |
|