 |
Ardsheal21 Newbie
Joined: 19 Jun 2013 Posts: 4
|
Posted: Wed Jun 19, 2013 3:14 pm
Unexpected Variables being created |
Hello this is my first time posting here. I have an issue with a function in CMUD creating some unexpected variables.
Code: |
#for @arPlanks {
#if (%ismember(%{i},@dbScraps)!=0 and %db(@dbScraps,%{i})>=4) {
#loop 1,23 {
#if (%ismember(%i,bag%j)!=0) {
#send get all~.%i,%j~.alpine;
#var bagNumber %j;
#delitem %i bag%expand(@bagNumber);
#add dbScraps.%i -4;
#var traded 1;
#break}}}
}
#for @arIngots {
#if (%ismember(%{i},@dbScraps)!=0 and %db(@dbScraps,%{i})>=5) {
#loop 1,23 {
#if (%ismember(%i,bag%j)!=0) {
#send get all~.%i,%j~.alpine;
#var bagNumber %j;
#delitem %i bag%expand(@bagNumber);
#add dbScraps.%i -5;
#var traded 1;
#break}}}
}
#for @arLayers {
#if (%ismember(%{i},@dbScraps)!=0 and %db(@dbScraps,%{i})>=3) {
#loop 1,23 {
#if (%ismember(%i,bag%j)!=0) {
#send get all~.%i,%j~.alpine;
#var bagNumber %j;
#delitem %i bag%expand(@bagNumber);
#add dbScraps.%i -3;
#var traded 1;
#break}}}
}
#for @arBolts {
#if (%ismember(%{i},@dbScraps)!=0 and %db(@dbScraps,%{i})>=4) {
#loop 1,23 {
#if (%ismember(%i,bag%j)!=0) {
#send get all~.%i,%j~.alpine;
#var bagNumber %j;
#delitem %i bag%expand(@bagNumber);
#add dbScraps.%i -4;
#var traded 1;
#break}}}
}
#for @arFrags {
#if (%ismember(%{i},@dbScraps)!=0 and %db(@dbScraps,%{i})>=40 and @traded=0) {
#loop 1,23 {
#if (%ismember(%i,bag%j)!=0) {
#send get all~.%i,%j~.alpine;
#var bagNumber %j;
#delitem %i bag%expand(@bagNumber);
#add dbScraps.%i -%db(@dbScraps,%{i});
#var traded 1;
#break}}}
} |
When any of these become true it creates a variable for said item. The script works appropriately where it gets the items and and deletes the correct values from the database variables. Any help will be appreciated. The problem is not CMUD it is my code. I have a feeling I missed a pair of brackets inside one of the loops perhaps the ',' is messing it up. In any case I am not sure why this code is creating a variable, when I only want it to return true and complete the commands.
A little more clarification. If it matches the name 'pinewood', it will create a stinglist with nothing in it. With the name having spaces 'dark hickory' it will create a string list with 'hickory' inside.
Thank you in advance,
Ardsheal21 |
|
|
 |
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Wed Jun 19, 2013 5:24 pm |
The culprit would be this line here, I believe: "#delitem %i bag%expand(@bagNumber);" I'm not sure what you're trying to do there, exactly, but the syntax for the #delitem command is #delitem <variable> <item>. In that case, your variable name is your %i (pinewood, dark hickory, etc), and #delitem will create the variable if it doesn't exist.
|
|
|
 |
Ardsheal21 Newbie
Joined: 19 Jun 2013 Posts: 4
|
Posted: Wed Jun 19, 2013 5:33 pm |
With #delitem %i bag%expand(@bagNumber) I am trying to get it to remove %i(pinewood,etc) from the @bagnumber(bag21,bag22,etc) variable. So in turn I am trying to remove it from the string list I have built.
Thanks for the answer above. |
|
|
 |
Ardsheal21 Newbie
Joined: 19 Jun 2013 Posts: 4
|
Posted: Wed Jun 19, 2013 7:05 pm |
I believe I figured it out. I am not familiar with #delitem, I normally use %delitem. Anyway you were correct, it had been creating a new variable each time because it didn't exist. Thanks again.
|
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|