Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-23-2006, 10:42 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
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");
      }
    }
  }

Reply With Quote
  #2  
Old 12-27-2006, 11:09 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
bump
Anyone?
Would there be an easier way of getting text from a level and modifying it?
Reply With Quote
  #3  
Old 12-28-2006, 03:56 PM
WanDaMan WanDaMan is offline
Master Tux
WanDaMan's Avatar
Join Date: Aug 2002
Location: England, United Kingdom
Posts: 5,571
WanDaMan is a jewel in the roughWanDaMan is a jewel in the rough
Send a message via MSN to WanDaMan
temp.levelinfo.loadlines("levels/" @ temp.var @ "/" @ temp.var2);
__________________
V$:CONFL16T
Reply With Quote
  #4  
Old 12-28-2006, 06:37 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Quote:
Originally Posted by WanDaMan View Post
temp.levelinfo.loadlines("levels/" @ temp.var @ "/" @ temp.var2);
Reply With Quote
  #5  
Old 01-03-2007, 12:09 AM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
try take away the:

PHP Code:
temp.levelinfo = new TStaticVar(); 
__________________
Reply With Quote
  #6  
Old 01-03-2007, 12:13 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Sorry, Joey answered me on the UGCC.

It works now
Script's over there.
Reply With Quote
Reply


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:29 AM.


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