View Single Post
  #13  
Old 03-03-2010, 01:12 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
A couple of amendments:

PHP Code:
//#CLIENTSIDE 
function showInterface() { 
  if (
CreateChar_Window != null) { 
    
CreateChar_Window.destroy(); 
  } 
   
  new 
GuiWindowCtrl("CreateChar_Window") { 
    
profile "GuiBlueWindowProfile"
     
    
width 212
    
height 356
     
    
GraalControl.width - (width 2); 
    
GraalControl.height - (height 2); 
     
    
canClose visible true
    
canMaximize canMinimize canResize false
     
    
text "Character Creation"
     
    new 
GuiShowImgCtrl("CreateChar_Doll") { 
      
ani "idle"
       
      
CreateChar_Window.width 25
      
32
       
      
hint "Click to change direction."
    } 
     
    
temp.fields = { 
                    {
"bodyimg""Body"}, 
                    {
"headimg""Head"}, 
                    {
"shield""Shield"}, 
                    {
"attr[1]""Hat"}, 
                    {
"ani""Ani"
                  }; 
     
    
temp.parts getParts(); 
     
    
temp.colors getColors(); 
     
    for (
temp.field fields) { 
      new 
GuiTextCtrl("CreateChar_FieldLabel_" field[1]) { 
        
profile "GuiBlueTextProfile"
         
        
13
        
90 23 fields.index(@ field); 
         
        
text field[1] @ ":"
      } 
      new 
GuiTextEditCtrl("CreateChar_Field_" field[1]) { 
        
profile "GuiBlueTextEditProfile"
         
        
width 150
        
height 20
         
        
50
        
90 + (height 3) * fields.index(@ field); 
         
        if (
field[0] == "attr[1]") { 
          
text CreateChar_Doll.actor.attr[1]; 
        } else { 
          
text CreateChar_Doll.actor.(@ field[0]); 
        } 
         
        if (
text == null) { 
          
text ""
        } 
         
        
thiso.catchevent(name"onAction""onTextChanges"); 
         
        
this.part field[0]; 
      } 
    } 
    for (
temp.part parts) { 
      new 
GuiTextCtrl("CreateChar_PartLabel_" part) { 
        
profile "GuiBlueTextProfile"
         
        
13
        
206 23 parts.index(@ part); 
         
        
text part ":"
      } 
      new 
GuiPopUpMenuCtrl("CreateChar_Part_" part) { 
        
profile "GuiBluePopUpMenuProfile"
        
scrollprofile "GuiBlueScrollProfile"
        
textprofile "GuiBlueTextListProfile"
         
        
width 150
        
height 20
         
        
50
        
206 + (height 3) * parts.index(@ part); 
         
        
clearRows(); 
         
        for (
temp.colors) { 
          
addRow(0c); 
        } 
         
        
setSelectedRow(CreateChar_Doll.actor.colors[parts.index(@ part)]); 
         
        
thiso.catchevent(name"onSelect""onColorSelected"); 
         
        
this.part
      } 
    } 
     
    new 
GuiButtonCtrl("CreateChar_Generate") { 
      
profile "GuiBlueButtonProfile"
       
      
width 60
      
height 22
       
      
CreateChar_Window.width - (width 2); 
      
323
       
      
text "Generate"
    }     
  } 

function 
CreateChar_Generate.onAction() { 
  
temp.char CreateChar_Doll
  
// {dir, body, head, shield, hat, ani, colors} 
  
temp.generateFrom = {char.actor.dirchar.actor.bodyimgchar.actor.headimgchar.actor.shieldchar.actor.attr[1], char.anichar.actor.colors}; 
   
  
generateCode(generateFrom); 
   
  
CreateChar_Window.destroy(); 

function 
CreateChar_Doll.onMouseDown() { 
  
CreateChar_Doll.actor.dir ++; 

function 
onTextChanges(controlnewtext) { 
  
temp.part control.part
   
  if (
part == "attr[1]") { 
    
CreateChar_Doll.actor.attr[1] = newtext
    return; 
  } 
  if (
part == "ani") { 
    
CreateChar_Doll.ani newtext
  } 
   
  
CreateChar_Doll.actor.(@ part) = newtext

function 
onColorSelected(control) { 
  
temp.colors getColors(); 
  
temp.parts getParts(); 
   
  
temp.part parts.index(@ (@control).p); 
  
temp.colors.index(@ (@ control).getSelectedText()); 
   
  
CreateChar_Doll.actor.colors[part] = c

function 
getParts() { 
  return { 
           
"Skin"
           
"Coat"
           
"Sleeves"
           
"Shoes"
           
"Belt" 
         
}; 

function 
getColors() { 
  return { 
           
"White"
           
"Yellow"
           
"Orange"
           
"Pink"
           
"Red"
           
"Dark Red"
           
"Light Green"
           
"Green"
           
"Dark Green"
           
"Light Blue"
           
"Blue"
           
"Dark Blue"
           
"Brown"
           
"Cynober"
           
"Purple"
           
"Dark Purple"
           
"Light Gray"
           
"Gray"
           
"Black"
           
"Transparent" 
         
}; 

function 
generateCode(from) { 
  
// {dir, body, head, shield, hat, ani, colors} 
   
  
temp.lines = {"/" "/ Made by" SPC player.nick"/" "/#CLIENTSIDE""function onCreated() {""  showcharacter();"}; 
   
  
temp.vars = { 
                
"bodyimg"
                
"headimg"
                
"shield"
                
"attr[1]"
                
"ani" 
              
}; 
   
  
lines.add("  this.dir = " from[0] @ ";"); 
   
  
temp.inc 1
   
  for (
temp.vars) { 
    if (
from[inc] != null) { 
      
lines.add("  this." v SPC "= \"" from[inc] @ "\";"); 
    } 
    
inc ++; 
  } 
   
  for (
temp.05++) { 
    
lines.add("  this.colors[" "] =" SPC from[6][c] @ ";"); 
  } 
   
  
lines.add("}"); 
  
lines.add("function onPlayerEnters() {"); 
  
lines.add("  onCreated();"); 
  
lines.add("}"); 
   
  if (
CreateCharOutput_Window != null) { 
    
CreateCharOutput_Window.destroy(); 
  } 
  new 
GuiWindowCtrl("CreateCharOutput_Window") { 
    
profile "GuiBlueWindowProfile"
     
    
width 212
    
height 356
     
    
GraalControl.width - (width 2); 
    
GraalControl.height - (height 2); 
     
    
canClose visible true
    
canMinimize canMaximize canResize false
     
    
text "Create Character: Output"
     
    new 
GuiScrollCtrl("CreateCharOutput_Scroll") { 
      
profile "GuiBlueScrollProfile"
       
      
10
      
28
       
      
width 192
      
height 319
       
      
vScrollBar "alwaysOn"
      
hScrollBar "alwaysOff"
       
      new 
GuiMLTextCtrl("CreateCharOutput_Text") { 
        
profile "GuiBlueTextProfile"
         
        
width 202
         
        
0
        
1
         
        
text null
         
        for (
temp.line lines) { 
          if (
text == null) { 
            
text line
          } else { 
            
text @= "\n" line
          } 
        } 
      } 
    } 
  } 

function 
onPlayerChats() { 
  if (
player.chat == "/create char") { 
    
showInterface(); 
  } 

- fixed if (player.chat = "/create char")
- fixed some imaginary variable I invented called "this.hat" to "this.attr[1]"...
__________________
Reply With Quote