Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Text level editor (https://forums.graalonline.com/forums/showthread.php?t=70966)

excaliber7388 12-23-2006 10:42 PM

Text level editor
 
This is the text level editor Joey made.
I added my levels to the levels array, but it never works.
Any ideas?
PHP Code:

function onActionServerSide(actionargs) {
  switch (
action) {
    case 
"openfile": {
      for (
temp.var: this.listfolders) {
        
temp.folder.loadfolder(temp.var @ "/*"true);
        
        for (
temp.var2temp.folder) {
          if (
temp.var2 == args[0]) {
            
temp.levelinfo = new TStaticVar();
            
temp.levelinfo.loadlines(temp.var @ "/" temp.var2);
            
            for (
temp.var3temp.levelinfotemp.linfo.add(temp.var3);
            
            
triggerclient("gui"this.name"openfile", {"levels/" temp.var @ "/" temp.var2temp.linfo});
            
            return 
true;
          }
        }
      }
      
      
player.addMsg("Server"format("No such file by %s was found!"args[0]), 15);
      
      break;
    }
    
    case 
"savefile": {
      
temp.levelinfo = new TStaticVar();
      
temp.levelinfo args[1];

      
temp.levelinfo.savelines(args[0], 0);
      
      
temp.toks args[0].tokenize("/");
      
      if (
temp.toks[temp.toks.size() - 1].pos(".nw") > 0) {
        
triggerclient("gui"this.name"updatelevel", {temp.toks[temp.toks.size() - 1]});
      }
      
      break;
    }
  }
}

function 
onCreated() {
  
// Add folders here
  
this.listfolders = {"insidelevels","outsidelevels"};
}

//#CLIENTSIDE
// Usage: !openfile FILE
function onCreated() {
  
this.buttons = {{"Save"10"Save File"}, {"Reload"150"Reload File"}, {"Close"290"Close File"}};
}

function 
ChatBar.onAction() {
  if (
ChatBar.text.starts("!openfile")) {
    
triggerserver("gui"this.name"openfile", {ChatBar.text.substring(10)});
  }
}

function 
onActionClientSide(actionargs) {
  switch (
action) {
    case 
"openfile": {
      
onTextWindow(args[0], args[1]);
    
      break;
    }
    
    case 
"updatelevel": {
      
sendtorc(format("/updatelevel %s"args[0]));
      
player.addMsg("Server""Saved and Updated successfully!"15);
     
      break;
    }
  }
}

function 
onActionButton(obj) {
  
temp.objid obj.substring(19);
  
this.sendu temp.objid;
  
  if (
obj.starts("TextEdit_")) {
    
temp.type temp.obj.substring(9);
    
temp.type temp.type.substring(0temp.type.length() - 1);
    
temp.uid  temp.obj.substring(temp.obj.length() - 1);
    
    switch (
temp.type) {
      case 
"Save": {
        
triggerserver("gui"this.name"savefile", {makevar("TextEdit_Window" temp.uid).text.substring(13), makevar("TextEdit_MultiLineEdit" temp.uid).getLines()});
       
        break;
      }
    
      case 
"Reload": {
        
makevar("TextEdit_MultiLineEdit" temp.uid).setLines(makevar("this.tefile_" temp.uid));
      
        break;
      }
      
      case 
"Close": {
        
makevar("TextEdit_Window" temp.uid).destroy();
        
        break;
      }
    }
  }
}

function 
onTextWindow(newFilenewText) {
  
this.teid++;
  
  
makevar("this.tefile_" this.teid) = newText;
  
  if (
makevar("TextEdit_Window" this.teid) != NULLmakevar("TextEdit_Window" this.teid).destroy();
  
  new 
GuiWindowCtrl("TextEdit_Window" thiso.teid) {
    
profile  "GuiBlueWindowProfile";
    
    
extent   = {400390};
    
position = {screenwidth 3screenheight 3};
    
    
text "Text Editor: " newFile;

    new 
GuiScrollCtrl("TextEdit_Scroll" thiso.teid) {
      
profile     "GuiBlueScrollProfile";
    
      
extent      = {388320};
      
position    = {624};
      
      
horizSizing "width";
      
vertsizing  "height";
      
      
hscrollbar  "dynamic";
      
vscrollbar  "dynamic";

      new 
GuiMLTextEditCtrl("TextEdit_MultiLineEdit" thiso.teid) {
        
profile     "GuiBlueMLTextProfile";
        
        
horizSizing "width";
        
vertsizing  "height";
        
        
wordwrap    false;
        
        
setlines(newText);
      }
    }
    
    for (
temp.var: thiso.buttons) {
      new 
GuiButtonCtrl("TextEdit_" temp.var[0] @ thiso.teid) {
        
profile     "GuiBlueButtonProfile";
      
        
extent      = {10030};
        
position    = {temp.var[1], 349};
      
        
vertsizing  "top";
      
        
text        temp.var[2];
        
        
thiso.catchevent(this.name"onAction""onActionButton");
      }
    }
  }



excaliber7388 12-27-2006 11:09 PM

bump
Anyone?
Would there be an easier way of getting text from a level and modifying it?

WanDaMan 12-28-2006 03:56 PM

temp.levelinfo.loadlines("levels/" @ temp.var @ "/" @ temp.var2);

excaliber7388 12-28-2006 06:37 PM

Quote:

Originally Posted by WanDaMan (Post 1258064)
temp.levelinfo.loadlines("levels/" @ temp.var @ "/" @ temp.var2);

:confused:

Chompy 01-03-2007 12:09 AM

try take away the:

PHP Code:

temp.levelinfo = new TStaticVar(); 


excaliber7388 01-03-2007 12:13 AM

Sorry, Joey answered me on the UGCC.
:(
It works now :D
Script's over there.


All times are GMT +2. The time now is 11:33 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.