Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Online Level NPC Editor (OLNE) (https://forums.graalonline.com/forums/showthread.php?t=134264280)

fowlplay4 08-21-2011 11:55 PM

Online Level NPC Editor (OLNE)
 
2 Attachment(s)
Purpose
To allow quick and painless updating of hard-coded level NPCs while in-game.

On Zodiac for me, it was to finally change those yellow lights outside of OSL to orange.

Video


How-to Install
Add the script as a weapon on your server. Also update the levelfolders array on the server-side to match your server's folder setup. I set a default one that covers a fairly common/generic set though so it may not be required.

Also upload npc_placeholder.png in your server's images folder for blank NPCs to display properly. You can re-configure it to an image of your liking as well.

You will also need to give the (npcserver) write access to the level. I.e: rw levels/*.nw

In order to make changes to the levels you will also need write access to the levels as well.

OLNE Usage is automatically logged to logs/olne_log.txt

How-to Use
Press F9 to toggle the editor on and off.

It works pretty much exactly like it does in the offline level editor. Most showcharacter, and showimgpart NPCs (even the ones that use math in them) are displayed correctly as well. The editor windows are also unique to each NPC so you can open multiple NPCs at once.

Left-click to select an NPC.

Left-click and drag to move an NPC. NPCs will be made transparent while you're dragging them to make them easier to place in groups. I.e: Placing a light image over a lamp.

Double-click to open the NPC Script Editor.

Right-clicking an NPC will duplicate it.

Except when it comes to creating new NPCs. In my editor it's a mouse gesture.
  1. Hold down the right mouse button after 0.3 seconds the menu will appear. (You can re-configure this time easily)
  2. While holding down the right mouse, hover your mouse over the NPC you want to create.
  3. It will be created upon hovering over it and you can continue holding down the right mouse button to drag it into position.

If you make a change and don't want to save it, you can simply leave the level (or: reconnect, update level) to discard your changes as well. A level will only be updated if you make a change though.

Press F9 to save your changes and exit the editor.

Drawbacks
It does support GMAPs but only for editing the level you are currently in so be cautious of that. It will display the boundaries of the level when on a GMAP while dragging the NPC, as long as you keep it in the boundaries it will save in the correct spot.

Due to the way NPCs are stored in the level I also have it so levels get locked to prevent other users from making changes while you are. You will get a message stating who is currently editing the level if a locking conflict occurs.

Doesn't support default baddies, or chests nor do I plan on supporting them.

Editor doesn't support testing or styling. Use http://fp4.ca/gs2beautifier if you really need your code styled for you.

Detection of showimgpart, and showcharacter is lazy. It picks up the first occurrence and doesn't care if the line is commented out or not. Personally I kind of like it this way, lets me assign an editor-only image to an otherwise blank editor NPC.

The Script

Latest version at http://forums.graalonline.com/forums...1&postcount=69.

ff7chocoboknight 08-22-2011 12:04 AM

Neato. :O

0PiX0 08-22-2011 12:08 AM

Seems like a very useful tool. :)

Quote:

Originally Posted by fowlplay4 (Post 1664714)
It does support GMAPs but only for editing the level you are currently in so be cautious of that.

Maybe, if the player is in a gmap, outline the player's current level with a polygon.

fowlplay4 08-22-2011 12:26 AM

Quote:

Originally Posted by 0PiX0 (Post 1664716)
Maybe, if the player is in a gmap, outline the player's current level with a polygon.

I will be updating my script to do that shortly, it will also display a message when you do so.

Edit: Updated.

callimuc 08-22-2011 01:46 AM

Thats part of the best and most useful things for scripters I think ;) but do you need to change anything in the serveroptions? I mean like for the online level editor the serveroptions also have some stuff to be setted. What about this?

Well anyway rep++ after I can rep again ;)

0PiX0 08-22-2011 02:10 AM

Quote:

Originally Posted by fowlplay4 (Post 1664714)
as long as you keep it in the boundaries it will save in the correct spot.

The image displayed should be forced to stay within the boundaries.

e.
Also, while dragging, I think that the player's position should not be able to change, so player.level cannot change while dragging. Not sure if that is an issue or not though since I'm just reading through the code. :)

fowlplay4 08-22-2011 06:00 AM

Quote:

Originally Posted by 0PiX0 (Post 1664737)
The image displayed should be forced to stay within the boundaries.

e.
Also, while dragging, I think that the player's position should not be able to change, so player.level cannot change while dragging. Not sure if that is an issue or not though since I'm just reading through the code. :)

Yeah you're right about that so it forces them inside the boundaries now.

As for the dragging thing, it isn't onPlayerEnters gets called and deactivates the editor.

Quote:

Originally Posted by callimuc (Post 1664736)
Thats part of the best and most useful things for scripters I think ;) but do you need to change anything in the serveroptions? I mean like for the online level editor the serveroptions also have some stuff to be setted. What about this?

Well anyway rep++ after I can rep again ;)

Nope, all the level security is based around your's and the (npcserver)'s folder rights.

callimuc 08-22-2011 03:36 PM

Ah ok thats good

callimuc 08-22-2011 03:51 PM

Well I just tested it and it seems buggy. NPC images got suddenly changed, scripts like
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
blockagain();
  
drawunderplayer();
  
setimgpart("callimuc_extra-sprites.png",32,0,32,32);


suddenly changed to
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
blockagain();
  
drawunderplayer();
  
setimgpart("callimuc_extra-sprites.png,32,0,32,32);


or image names got completely removed. Would be nice if it could be fixed ;)

xAndrewx 08-22-2011 03:57 PM

I really like it- I'd use it if there was a tile preference too. [So I can edit the tiles in the level]

I'd rep too, but can't. Very well done, nice :)

fowlplay4 08-22-2011 04:14 PM

Quote:

Originally Posted by xAndrewx (Post 1664807)
I really like it- I'd use it if there was a tile preference too. [So I can edit the tiles in the level]

It was designed to be used in conjunction with an online tile editor (why I used F9 instead of F4 to toggle it) and there's a few of those in the Code Gallery already.

Quote:

Originally Posted by callimuc (Post 1664806)
Well I just tested it and it seems buggy. NPC images got suddenly changed, scripts like

or image names got completely removed. Would be nice if it could be fixed ;)

Attach the level for me if you could. My editor checks if the images exist on the server when it goes to save them, which is probably what happened there. I will have to change that behavior. Edit: I fixed this behavior and now image is tracked with a different variable than image.

Are you using V5 or V6? There are some issues with getlines, and setlines in V5. I also was able to open, edit, and save your script without it messing up. I uploaded an updated version that prevents V5 from using it.

0PiX0 08-22-2011 05:13 PM

Quote:

Originally Posted by fowlplay4 (Post 1664762)
As for the dragging thing, it isn't onPlayerEnters gets called and deactivates the editor.

Ah, alright. I'll definitely try out the OLNE as soon I can. I'm just waiting for a replacement hdd to arrive. I'm betting this tool will make editing level npcs much more convenient, so I can't wait to try it out. ^^

xAndrewx 08-22-2011 05:48 PM

You should make a level editor- I'd love it if it had the same features as this! *take the hint lol*

Crow 08-22-2011 06:02 PM

Quote:

Originally Posted by xAndrewx (Post 1664820)
You should make a level editor- I'd love it if it had the same features as this! *take the hint lol*

Personally, I'm still waiting for Tig to release his level editor :cool:

DustyPorViva 08-22-2011 06:38 PM

Quote:

Originally Posted by Crow (Post 1664823)
Personally, I'm still waiting for Tig to release his level editor :cool:

"We're not going to update the Graal Editor because we're moving in direction of scripted tools."

WHERE ARE THEY!?

Emera 08-22-2011 07:03 PM

Quote:

Originally Posted by callimuc (Post 1664806)
Well I just tested it and it seems buggy. NPC images got suddenly changed, scripts like
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
blockagain();
  
drawunderplayer();
  
setimgpart("callimuc_extra-sprites.png",32,0,32,32);


suddenly changed to
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
blockagain();
  
drawunderplayer();
  
setimgpart("callimuc_extra-sprites.png,32,0,32,32);


or image names got completely removed. Would be nice if it could be fixed ;)

Was really funny, red and yellow squares everywhere. Nice code though fowlplay. Rep+

callimuc 08-22-2011 08:55 PM

Quote:

Originally Posted by fowlplay4 (Post 1664808)
Are you using V5 or V6?

Used v6
Quote:

Originally Posted by Emera (Post 1664829)
Was really funny, red and yellow squares everywhere

Those where from the image as template xD

0PiX0 08-24-2011 07:17 AM

I tried this out. It is quite nice. Great work.

There is a bug when you change the npc's image to be nothing.

Please fix double-click detection. Sometimes if you click GraalControl then click a npc too soon, the script editor opens.

Astram 08-24-2011 07:42 PM

How do I delete NPCs & it says that it cant find "levels/houses/*nw" in my folders, I have in a folder levels, houses!

fowlplay4 08-24-2011 07:50 PM

put

"levels/houses/%s"

in your level folders array at the top.

Astram 08-24-2011 08:16 PM

Quote:

Originally Posted by fowlplay4 (Post 1665151)
put

"levels/houses/%s"

in your level folders array at the top.

That didnt work

fowlplay4 08-24-2011 08:30 PM

Quote:

Originally Posted by Astram (Post 1665152)
That didnt work

and (npcserver) and yourself have rw levels/houses/* in your folder rights?

Quote:

Originally Posted by 0PiX0 (Post 1665095)
There is a bug when you change the npc's image to be nothing.

Please fix double-click detection. Sometimes if you click GraalControl then click a npc too soon, the script editor opens.

I need instructions to reproduce the error with images.

I don't think onMouseDown reports double clicks properly because it registers the mouse down three times (which makes it very annoying to check if the double-click happened in the same area as the single click) in situations where I only clicked twice within 0.3 of a second.

Two clicks in two different spots that are more than 16 pixels shouldn't register as a double-click either but it does. :(

PHP Code:

//#CLIENTSIDE
function onMouseDown(click) {
  echo(
click SPC timevar2);



callimuc 08-24-2011 08:45 PM

Quote:

Originally Posted by Astram (Post 1665150)
How do I delete NPCs

Like in OE with the "del" (delete) key

0PiX0 08-24-2011 08:50 PM

Quote:

Originally Posted by fowlplay4 (Post 1665157)
I need instructions to reproduce the error with images.

  1. Open the script editor on any npc.
  2. Set this (or similar) as the script:
    PHP Code:

    //#CLIENTSIDE
    function onCreated() {
      
    showimg(300"block.png"this.xthis.y);


  3. Change the npc's default image from "*.png" to ""
  4. Apply, then f9 save
It results with this line in the level file:
"NPC (2 spaces) 34 45"
when it should be "NPC 0 34 45", or something like that.

---
PHP Code:

//#CLIENTSIDE 
function GraalControl.onMouseDown(temp.click) { 
  echo(
click SPC timevar2); 


One echo per click for me.

fowlplay4 08-24-2011 09:05 PM

Quote:

Originally Posted by 0PiX0 (Post 1665163)
Image bug.

---
PHP Code:

//#CLIENTSIDE 
function GraalControl.onMouseDown(temp.click) { 
  echo(
click SPC timevar2); 


One echo per click for me.

Fixed the bug in my latest version.

GraalControl.onMouseDown isn't the same as onMouseDown. I was hoping to just use it's double-click functionality but it looks like I'll have to write my own.

Fixed the annoying double-click thing too. See attached for the latest version.

Edit: Fixed a bug that resulted in new NPCs being set to the placeholder image. Also changed editor's text profile to match external RC (bigger text, pink strings, and blue highlighting) a bit more.

Edit by Skyld: Latest version available at http://forums.graalonline.com/forums...5&postcount=39.

Switch 08-24-2011 11:30 PM

Quote:

Originally Posted by xAndrewx (Post 1664820)
You should make a level editor- I'd love it if it had the same features as this! *take the hint lol*

http://forums.graalonline.com/forums...hp?t=134258087

Not exactly the same but you get the point. Anyone that wants to can make updates to it.

MattKan 08-24-2011 11:58 PM

I don't actually care about new Graal Developer tools anymore...Fantastic job!

fowlplay4 08-25-2011 02:04 AM

Updated again just a minor bug and an aesthetic change with the editor. See my post above for the script.

I found this tool insanely useful yesterday when I updated around 9 Flag NPCs on Zodiac. While it's not hard to get the level name, go through the file browser, wait for the file to actually download, open in an editor, make the changes needed, and re-upload. It can end up taking long enough to turn a simple task into a tedious one.

callimuc 08-25-2011 08:27 PM

Quote:

Originally Posted by fowlplay4 (Post 1665194)
I found this tool insanely useful yesterday when I updated around 9 Flag NPCs on Zodiac. While it's not hard to get the level name, go through the file browser, wait for the file to actually download, open in an editor, make the changes needed, and re-upload. It can end up taking long enough to turn a simple task into a tedious one.

Agreed. On small servers it might not be a problem but its still time you can save and actually you dont have to give NATīs folder rights to thta levels.

fowlplay4 09-06-2011 02:14 AM

Could a mod please replace the txt file in my first post with the one in this post:
http://forums.graalonline.com/forums...7&postcount=25

Emera 09-06-2011 11:52 AM

OK, if I try to edit an NPC that is to one of the far sides of the level, I have to walk in the opposite direction so I can JUST see the NPC and only then will it let me edit. If you need more information I can make a video to show you?

fowlplay4 09-06-2011 03:35 PM

Yeah you're going have to make a video because I don't know what you're experiencing.

Emera 09-06-2011 04:19 PM


That's what I am getting at.

Emera 10-09-2011 01:48 PM

1 Attachment(s)
I am having some issues with the editor. I can edit the NPC's in levels like usual, but for some reason, they don't save. This has just started happening, and I haven't had any issues with it before. I haven't changed anything either. Any idea what it is?

scriptless 10-09-2011 07:40 PM

very helpfull tool... wish i could rep you .. :(

fowlplay4 10-09-2011 08:57 PM

Quote:

Originally Posted by Emera (Post 1670402)
I am having some issues with the editor. I can edit the NPC's in levels like usual, but for some reason, they don't save. This has just started happening, and I haven't had any issues with it before. I haven't changed anything either. Any idea what it is?

Does the (npcserver) have write rights to the levels you're trying to edit?

Emera 10-09-2011 09:04 PM

Quote:

Originally Posted by fowlplay4 (Post 1670440)
Does the (npcserver) have write rights to the levels you're trying to edit?

Suddenly started working again...
I had to restart the server.

MattKan 01-17-2012 04:53 AM

I've been using this weapon quite frequently on Stroseria and I've encountered a few bugs.

First off, usually when I try to copy something in game, then close the editor without editing the copied NPC, the NPC moves to (0,0) on the level and is then impossible to select. I'm forced to open the level with a text editor to remove the NPC.

Second off, it's still possible to edit a level someone else is editing. Somebody was editing the level's NPCs, and I pressed F9. It gave me the error message that he was editing the level, but then I was still able to hold right click and create a new NPC. When I pressed F9 again, all of the npcs in the level were wiped.

fowlplay4 01-17-2012 05:35 AM

1. I wasn't able to reproduce this bug.
2. Fixed.

Could a mod please delete the attachment in this post:
http://forums.graalonline.com/forums...7&postcount=25

And replace the one in the OP with my latest version in this post.

MattKan 01-19-2012 12:34 AM

Quote:

Originally Posted by fowlplay4 (Post 1681895)
1. I wasn't able to reproduce this bug.
2. Fixed.

Could a mod please delete the attachment in this post:
http://forums.graalonline.com/forums...7&postcount=25

And replace the one in the OP with my latest version in this post.

Thank you so much!


All times are GMT +2. The time now is 09:07 AM.

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