Thread: how would i make this code cleaner?

Results 1 to 7 of 7
  1. #1 how would i make this code cleaner? 
    Registered Member
    Join Date
    Feb 2010
    Posts
    349
    Thanks given
    10
    Thanks received
    5
    Rep Power
    1
    yeah i want to learn to make codes more cleaner and smaller so basicly make an array i think so for example

    Code:
    if (itemUsed == 1755 && useWith == 1623 || itemUsed == 1623
    					&& useWith == 1755) {
    				if (playerLevel[12] >= 20) {
    					if (System.currentTimeMillis() - lastAction > actionInterval) {
    						actionInterval = 2800;
    						lastAction = System.currentTimeMillis();
    						setAnimation(888);
    						deleteItem(1623, 1);
    						addItem(1607, 1);
    						addSkillXP(1000, 12);
    						sM("You cut the Sapphire");
    					}
    				} else {
    				}
    			}
    how would i make that shorter?
     

  2. #2  
    Registered Member
    Join Date
    May 2010
    Posts
    54
    Thanks given
    0
    Thanks received
    2
    Rep Power
    3
    does it matter?
     

  3. #3  
    Registered Member
    Join Date
    Feb 2010
    Posts
    349
    Thanks given
    10
    Thanks received
    5
    Rep Power
    1
    takes up more space and hurts my eyes >.>
     

  4. #4  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    Wtf is with the;

    Code:
    					}
    				} else {
    				}
    			}
     

  5. #5  
    Registered Member

    Join Date
    Feb 2009
    Age
    27
    Posts
    2,861
    Thanks given
    127
    Thanks received
    226
    Rep Power
    700
    Code:
    if (itemUsed == 1755 && useWith == 1623 || itemUsed == 1623 && useWith == 1755 && playerLevel[12] >= 20) {
    					if (System.currentTimeMillis() - lastAction > actionInterval) {
    						actionInterval = 2800;
    						lastAction = System.currentTimeMillis();
    						setAnimation(888);
    						deleteItem(1623, 1);
    						addItem(1607, 1);
    						addSkillXP(1000, 12);
    						sM("You cut the Sapphire");
    					}
    			}
     

  6. #6  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    Quote Originally Posted by Jarba View Post
    Code:
    if (itemUsed == 1755 && useWith == 1623 || itemUsed == 1623 && useWith == 1755 && playerLevel[12] >= 20) {
    					if (System.currentTimeMillis() - lastAction > actionInterval) {
    						actionInterval = 2800;
    						lastAction = System.currentTimeMillis();
    						setAnimation(888);
    						deleteItem(1623, 1);
    						addItem(1607, 1);
    						addSkillXP(1000, 12);
    						sM("You cut the Sapphire");
    					}
    			}
    Exactly, no point for the '} else {' statement, good job Jarba
     

  7. #7  
    Registered Member

    Join Date
    Feb 2009
    Age
    27
    Posts
    2,861
    Thanks given
    127
    Thanks received
    226
    Rep Power
    700
    Code:
    if (itemUsed == 1755 && useWith == 1623 || itemUsed == 1623 && useWith == 1755 && playerLevel[12] >= 20 && System.currentTimeMillis() - lastAction > actionInterval) {
    						actionInterval = 2800;
    						lastAction = System.currentTimeMillis();
    						setAnimation(888);
    						deleteItem(1623, 1);
    						addItem(1607, 1);
    						addSkillXP(1000, 12);
    						sM("You cut the Sapphire");
    					}
    That would work too.
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •