Author Topic: Script Structure  (Read 13102 times)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Script Structure
« on: December 03, 2011, 02:47:42 AM »
So currently the scripts are structured as such, the ID of the script, with leading zeros up to 4 digits.

Code: [Select]
0001-Game_Temp.rb
Now this works fine, and when I load it into the script editor, I drop the beginning ID and the file extension, but I ran into a bit of a snag using this implementation. Aside from not allowing different characters that aren't permitted in file names (which I don't think is a big deal and can care less about), how exactly should we handle changing the script title in the editor? Now obviously I could delete/rename the old file to the name of the new, but I don't like the idea of the constant IO access just to rename a script. Although it would work, it seems a bit messy to be constantly changing the file name and updating the path to match to change a simple string value. Problem is, I can't think of a simple alternative that will still allow us to keep the scripts in  external and separate .rb files...
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline zenvirzan

  • Trained Member
  • *
  • Posts: 19
  • LV: 0
  • The Ruby Addict
    • View Profile
Re: Script Structure
« Reply #1 on: December 03, 2011, 09:48:28 AM »
If worst comes to worst, rather than a name box at the bottom of the script list (if you're doing that):
Make a new dialogue box appear after hitting a rename button (rather than typing in a text box).
That way, when it first opens, it saves the original filename and when closed, if the 2 names are different, it handles it from there :)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #2 on: December 03, 2011, 10:14:45 AM »
Yes, I already have contingencies thought up where it won't be doing it with each key stroke and will only do it once when the renaming is complete, but I was hoping for a little cleaner way to do it without the renaming of files and altering paths. It isn't a huge ordeal luckily, I was just hoping for a simple alternative I may have been overlooking.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19898
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Script Structure
« Reply #3 on: December 03, 2011, 11:25:00 AM »
They only way how to have them renamed without altering the path is to have an additional file with a file index. I'd like to avoid that additional file. As for renamed, are you able to catch the the textbox losing focus or the ENTER character? I suggest that you put the renaming call there. Until you actually rename the script, the script name should also stay the same in the listbox on the left side. So unlike RMXP, it would not apply every change when a character was added or removed but only when it was really renamed. Keep in mind that closing the editor should also apply the new name (in case somebody changes the name and then hits the OK button while the textbox is still active).
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline SBR*

  • Chaos User
  • ******
  • Posts: 1195
  • LV: -7
  • Gender: Male
    • View Profile
Re: Script Structure
« Reply #4 on: December 04, 2011, 01:03:52 AM »
Perhaps you can put the name in the first line of the .rb file? That way only the content will be changed and the name will stay the same as the ID.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5128
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: Script Structure
« Reply #5 on: December 04, 2011, 01:33:13 AM »
!!!
Code: [Select]
#Script-Name: Mainor something similar first line in the file. injected and removed by the script editor on load
then we could just name the files by their script ID
the engine wouldn't have to do anything special only load the scripts though It could use the name for trackback help.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #6 on: December 04, 2011, 02:14:27 AM »
I like it. Pretty much the same way you can define encodings etc in the script header, we can simply insert our little tag.  I can just pop the first line on load, and insert again on save. This should work out pretty well.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19898
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Script Structure
« Reply #7 on: December 04, 2011, 02:29:47 AM »
And how are you supposed to change the script order then? This would solve the renaming problem only to a degree. If people manually go about editing the .rb file, everything would break down. I'm against the idea, because it's a half-assed solution for a non-existent problem. Either we do it this way or we have an additional file with a file index. Obviously an index will cause many other problems, especially if people add/delete/rename script files manually.
« Last Edit: December 04, 2011, 02:31:23 AM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5128
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: Script Structure
« Reply #8 on: December 04, 2011, 03:05:56 AM »
they still change the script order with file names. the file name would be the order ID. and if they edited the script themselves that just need to keep the comment line at the top of the file if they wanted the script to have a name the system would not be any easier to break.
and it would allow names to have characters that are not allowed in file-names.

also F0, you should edit the Project frame work to have the saving of script files done there instead of by the editor panel itself if you haven't already.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #9 on: December 04, 2011, 03:44:17 AM »
This IS an existing problem, and for the exact same reasons as the alternative you are suggesting, and we are going to have to account for the possibility of a missing file either way we choose to go this, so that makes no difference. A simple insertion/deletion of a script is going to require the renaming of every script under it, which is not cool.

This problem could be solved by deleting the directory's contents and remaking it all with each save, which would solve all these problems, but I am not crazy about the idea, but it would be the least prone to bugs and user sabotage.

@Ryex: I have a static manager class for the script editor, it handles saving. The script objects are stored in Kernel.GlobalObjects under the key "Scripts".
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5128
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: Script Structure
« Reply #10 on: December 04, 2011, 04:12:11 AM »
but the scripts should not be saved until the project it self is. so simply have the project system tap into the manager you created to save the scripts when it saves.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19898
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Script Structure
« Reply #11 on: December 04, 2011, 10:21:05 AM »
Then we would still have all the problems that F0 described, except that we would have script names that allow any kind of characters. When you insert a new script, the file order would have to be saved as F0 already explained renaming lots of scripts. Why is it so important to be able to use any kind of character in a script name? That's why I called it a non-existent problem, because it's not. If we really, REALLY need users to be able to use any kind of ASCII character in their script name, we can always use escape characters for that. e.g. # could be the escape character. If you need #, it would write #23 and it you need anything else, it would write down another hex code (like #FF). Obviously this could result in long file names if we actually allowed unicode characters as we would need an 8 digit hex in form of #FFFFFFFF.

The alternative, a script index, is very risky. If you delete that script index file, all your script names and script order would be messed up. Remember script corruption in RMXP when the saving was aborted where you would lose a big deal of your scripts? This can't happen if we have file names and no script index. The worst case scenario is that you lose a few scripts in between instead all scripts after, e.g. the 10th script or something like that.

As for the saving, didn't we use tabs? You could edit stuff separately and then save just what is in the tab, am I right? The same should apply to scripts. Yes, obviously inserting a script would require renaming a lot of files. But this small complication is nothing compared to risking losing all script names and the script order when losing a script index.

BTW, have you made sure that UTF8 files are properly loaded and saved?
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #12 on: December 04, 2011, 04:44:10 PM »
Yeah, I'm using UTF8, I found out real quick when it threw an error trying to display a script and it said there were illegal characters. The Scintilla library has get and set text methods specifically for UTF8, so it made that easy luckily.

As for the index, I thought we could write the data inside the main project file. We would need an alternative for after encryption and the project file no longer exists, but it should prevent tampering.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5128
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: Script Structure
« Reply #13 on: December 04, 2011, 05:47:16 PM »
Ok how about this.

we want the system that the user can edit and change from outside the editor with minimal hassle right? well no matter what we do with file names the system is far to easy to break and a big hassle when you want to add a script or change the order.

and while a index might cause problem it could be done in such a way that it is really easy for the user to edit and easy to repair should something go wrong. here is my proposal.

Code: (scripts.index) [Select]
Game_Temp.rb|Game Temp
Game_System.rb|Game System
Game_Switches.rb|Game Switches
...
...
Scene_Gameover.rb|Scene Gameover
Scene_Debug.rb|Scene Debug
Main.rb|Main

The index works like so.
the load order would be the order in which the scripts are in the file this way inserting a script is as simple as inserting a line where you want it to go
the index maps filenames to script names. one script per line and separated by a '|' character
the loader would read each line up to the first '|' and take that as the file name and then read the rest of the line as the script name
with this method if the index gets corrupted or removed it is easy to repair and files never have to be renamed
« Last Edit: December 04, 2011, 06:43:51 PM by Ryex »
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #14 on: December 04, 2011, 06:18:53 PM »
I have no problem with that. I can have an alert when a script is not found in the case that it is misspelled or missing, as well as compare the list to the directory, and offer to import scripts that are not found on the list. That way the user can simply copy-paste .rb files into the folder, and have them be imported easily when the script editor is opened.

@Blizz: Will that pose any problems loading the scripts in the engine, or do you foresee any other problems with that before I implement it?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19898
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Script Structure
« Reply #15 on: December 04, 2011, 08:33:36 PM »
we want the system that the user can edit and change from outside the editor with minimal hassle right?

No. We want a system that is least likely to break if he tries to change it from outside the editor.



Alright. After a bit of thoughtful thinking and taking everything into account, this is how we will do it.

1. There will be a file called "index" without extension. This file includes script filenames and script names in the format that Ryex has proposed. This file is GENERATED by the editor each time a script has been saved, added or deleted.
2. File names will be NUMBERS. We can't use actual names, because obviously two scripts can have the same filename and we should spare the user of having to think about filenames.
3. When a new script is being added, all file names have to be checked. Basically start counting from 0 and check whether "%d.rb" exists. As soon as it does not exist, create that file and add in "index" the newest entry. The "index" file should not be used to check which files there are, there should always be an actual file exist test, because people can mess with the files without "index" being updated.
4. Each time "index" is generated and saved, it should check whether all files exist and if everything is alright. If there are problems (e.g. referencing a missing file), the user should be notified and "index" should NOT be saved.

Number 3 and 4 are mostly the reason why I am against index files, but if you want it so badly, have fun coding this mess.

@F0: I saw the script a script editor screenshot the other day. IDK if that's really old or something, but it looked like RMXP. I thought we were going to allow users to open single scripts in tabs. And no, loading this is no problem. I can make the edits work in 5 minutes.

In any case, the biggest problem is with the editor, because you can manually mess with the files. Maybe all script files should be loaded into memory when the editor starts just like in RMXP.
« Last Edit: December 04, 2011, 08:35:11 PM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #16 on: December 04, 2011, 09:14:16 PM »
You really seem to be against an index file. Its not that we are so "for" it, its just that no one has come up with a better alternative.

Here's another alternative:

  • I have already created a "Script" Python class, which has methods for getting/setting text, tracking cursor position, getting the name, path, etc. It also assigns the ID of the script using the load order with the numbering system
  • We can load all the scripts, and create a list of these "Script" objects when the Script Editor opens
  • If a script is inserted/deleted, it would be simple to do a slice and increment/decrement the ID of all scripts under it
  • On save, regenerate the script name and path something like this:
Code: [Select]
def GetPath( self ):
    prefix = str(self.Id).zfill(4)
    filename = str.join([prefix, self.name, '.rb'])
    path = os.path.join(dir, filename)
  • The only problem here that I foresee is that we would need to remove any .rb file in the directory that was not found in the scripts

I can easily create a tabbed interface for the editor, I need only to turn a few variables to arrays and update the templates file.
« Last Edit: December 04, 2011, 09:15:31 PM by ForeverZer0 »
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19898
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Script Structure
« Reply #17 on: December 04, 2011, 09:29:33 PM »
My main reason against a script index is that if that file is lost, your scripts are basically useless or you have to put them back in order. A file naming convention from 0001 and so one would avoid that possibility. If one file is lost, no big deal, just update the order and the user can add that script back in (if it was an external one that can be downloaded from somewhere obviously). That's my main concern. While working on CP over the course of 4 years, my Scripts.rxdata has become corrupted several times. Luckily every time I had an older backup and I hadn't updated the scripts in a while. Only once I lost a few bugs fixes over the course of a few days and had to use a backup without those fixes. Luckily I was able to get it done within a few hours. God, was I pissed that day.

Actually I don't think we'd have to do much if we kept the numbering. Basically every file that doesn't follow the convention of %04d-NAME.rb is ignored. They don't have to be deleted. If a user would add a file that followed the convention, it would obviously be updated on the next startup. e.g. Somebody adds 0011-LOL_SCRIPT.rb and we have already 0011-Game_Actor.rb, we would obviously load first everything before 0011-Game_Actor.rb, then 0011-Game_Actor.rb, then 0011-LOL_SCRIPT.rb, then everything after 0011-LOL_SCRIPT.rb and finally rename all scripts because 0011-LOL_SCRIPT.rb disrupted the order.
« Last Edit: December 04, 2011, 09:35:04 PM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #18 on: December 04, 2011, 09:57:13 PM »
Come to think of it, lets just keep the original naming convention of "%04d-NAME.rb", and forget the index. I think I came up with a way to make this relatively pain-free. All it really requires is an extra check on the names like you mentioned on a save, and to track a list of scripts marked for deletion, since we don't want to actually remove the file until it is saved, but that shouldn't be too messy.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19898
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Script Structure
« Reply #19 on: December 04, 2011, 09:59:16 PM »
Ryex, what do you say on this? I think that this is an important enough matter that we should all agree on this.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5128
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: Script Structure
« Reply #20 on: December 04, 2011, 10:14:26 PM »
well If Zer0 has come up with a way to make the saving easy then we're all good. we just have to make sure to delete files with the same ID prefix but different names appropriately to avoid conflicts.

EDIT:

Also Zer0, about the tabbed interface thing. it's not that you should create a tab inside the script editor. it more that you should make it so we could have multiple script editors in their own tab.

to do this you should move the script list into a drop down list box in the tool bar.
« Last Edit: December 04, 2011, 10:36:48 PM by Ryex »
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #21 on: December 04, 2011, 10:48:56 PM »
Although I haven't coded or tested just yet, here's the rough idea.

  • All scripts are loaded into memory when the script editor is opened and placed into "Script" objects, which provides some methods for easily handling them
  • I make some sort of list for scripts that are marked for deletion. When a script is deleted in the editor, the script object is moved from the mains scripts list, and into the deletion list, which will allow for easy "undo" type actions
  • Any script added into the editor will be simply held in memory
  • All script IDs will be ignored totally until the time comes for saving, but each script will be assigned one, though they will be simple unique identifiers mainly, not really be used for ordering
  • When the time comes to save, we first iterate over the list of scripts marked for deletion, and delete them, using the path attribute that was set when it was loaded
  • Then we iterate the script list, using the index to generate the name using the INDEX-NAME.rb convention. This name is checked against the name it had when it was loaded, if different, the file with the original name is deleted, and it is saved with the new name

Now this should be pretty much pretty simple to implement, and full-proof against errors related to inserting/deleting/renaming scripts. It doesn't solve the unusual character's in a filename "problem", but I could care less about that, and am fully voting that we simply disallow it. If someone seriously wants to bitch about not being able to put an asterisk or a pipe character in their script name, they can go fuck themselves to put it bluntly.

I may have a kink or two that I can work out when I get there, but what are you two's thoughts about this?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5128
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: Script Structure
« Reply #22 on: December 04, 2011, 11:05:03 PM »
works fine by me. you should tab into the project interface to know when to have your script object load and save the scripts if your not already
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #23 on: December 04, 2011, 11:11:07 PM »
I can once I get it altogether, still testing and what not at the moment. It really only is a matter of what class makes the call, so it will be simple to switch it. I implemented the tabbed interface, I need to make an edit to make the find/replace window a child of the main editor now, so that it doesn't create a new window for each tab, but the transition went smooth. Now instead of a single click on the list to change scripts, you double-click and it opens a new tab. I already made it so that if a script is already open in a tab when double-clicked, it simply switches to that tab instead of opening a new page.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5128
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: Script Structure
« Reply #24 on: December 04, 2011, 11:27:58 PM »
No that not what we want for a tabbed interface. we want to be able to create a new panel in the AUI interface and drag it around anywhere we want to not just a set of tabs in their own panel.
move the script list into a drop down in the tool bar and it will work fine.
as for the find and replace window. have the script editor panel use an On_Activate event (or what ever it is called, can't remember) and set a global object that the find replace window could interact with to do what it needs too. that way we can dispatch the find replace window as a floating panel in the AUI interface and use it with the last active script window.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19898
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Script Structure
« Reply #25 on: December 04, 2011, 11:35:09 PM »
If someone seriously wants to bitch about not being able to put an asterisk or a pipe character in their script name, they can go fuck themselves to put it bluntly.

<3

Quote
A user: BUT I WAAAAAAAAAAAAAAAAAAAAANT TO USE A STUPID CHARACTER TO NAME MY SCRIPT!!! This should be simple to make!
F0:
(click to show/hide)

Now this should be pretty much pretty simple to implement, and full-proof against errors related to inserting/deleting/renaming scripts. It doesn't solve the unusual character's in a filename "problem", but I could care less about that, and am fully voting that we simply disallow it.

Seriously, though. We can still allow all ASCII characters and escape the invalid filename characters with #XX. You can implement that quickly enough with a few replace calls upon saving and upon loading.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #26 on: December 04, 2011, 11:45:00 PM »
 :rofl:


Can do. On another note, I replaced the wxNotebook with the wxFlatNotebook for the tab interface. It is puuurty. :)
I'll might make another topic with a few screenies here in a bit.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5128
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: Script Structure
« Reply #27 on: December 05, 2011, 12:17:57 AM »
your not listening are you...
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #28 on: December 05, 2011, 12:23:52 AM »
your not listening are you...

I don't know what this means.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5128
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: Script Structure
« Reply #29 on: December 05, 2011, 12:24:59 AM »
No thats not what we want for a tabbed interface. we want to be able to create a new panel in the AUI interface and drag it around anywhere we want to not just a set of tabs in their own panel.
move the script list into a drop down in the tool bar and it will work fine.
as for the find and replace window. have the script editor panel use an On_Activate event (or what ever it is called, can't remember) and set a global object that the find replace window could interact with to do what it needs too. that way we can dispatch the find replace window as a floating panel in the AUI interface and use it with the last active script window.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #30 on: December 05, 2011, 12:47:46 AM »
Meh, missed that post. Just clicked the "Last Unread Post", and only saw Blizz's post...


EDIT:
Alright, well I modified the script panel so that it could be managed by the AUI manager, etc. The list and buttons at the bottom have been removed, and a combo box added to the toolbar. Additionally I have implemented saving/reading the files in UTF8 encoding.

@Ryex: One things I noticed while testing that was that the converter doesn't seem to save the files in UTF8, and all the existing scripts are in ANSI, so you may want to fix that.
« Last Edit: December 05, 2011, 04:59:38 AM by ForeverZer0 »
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19898
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Script Structure
« Reply #31 on: December 05, 2011, 09:14:18 AM »
I am sure that I converted all scripts in "RMXP/Chronicles of Sir Lag-A-Lot" to UTF8. Maybe you want to copy them from there first before you continue working. It's possible that your copy fo the scripts got saved as ANSI at one point.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5128
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: Script Structure
« Reply #32 on: December 05, 2011, 09:33:13 AM »
that's interesting I never do any conversion all I do is deflate from the scripts.rxdata and write the string directly to a file.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #33 on: December 05, 2011, 09:41:14 AM »
I can confirm that none of them are in UTF8, and I can also confirm that I have never modified them by using the SVN log. Game_Temp and Game_System are the exceptions, they are in UTF8 because I was testing the save function.

EDIT:

@Ryex: All you should need to do is when you go to write the file are creating the file object use something like this:

Code: [Select]
file = File.open('scriptname.rb', 'wb:utf-8')
Or simple write the UTF8 header yourself, either way.
« Last Edit: December 05, 2011, 09:47:15 AM by ForeverZer0 »
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19898
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Script Structure
« Reply #34 on: December 05, 2011, 09:48:31 AM »
He needs that code for Python, not Ruby. xD
Either way, F0 is right and you most probably need to write the UTF8 header. Try opening CoSLAL's base script files in a hex editor and see if the 2-3 first characters are >= 0x7F.
« Last Edit: December 05, 2011, 09:49:51 AM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #35 on: December 05, 2011, 09:51:19 AM »
I thought the converter was written in Ruby.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5128
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: Script Structure
« Reply #36 on: December 05, 2011, 10:14:05 AM »
ya the converter is in ruby.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19898
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Script Structure
« Reply #37 on: December 05, 2011, 11:17:13 AM »
Yeah, but you also have to read/save the files in Python when working on the scripts in the editor, right?
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Fantasist

  • Lexima Warrior
  • *******
  • Posts: 2222
  • LV: 146
  • Gender: Male
    • View Profile
    • Blog
Re: Script Structure
« Reply #38 on: December 05, 2011, 05:16:23 PM »
Although I haven't coded or tested just yet, here's the rough idea.

  • All scripts are loaded into memory when the script editor is opened and placed into "Script"
    objects, which provides some methods for easily handling them
  • I make some sort of list for scripts that are marked for deletion. When a script is deleted in the editor, the script object is moved from the mains scripts list, and into the deletion list, which will allow for easy "undo" type actions
  • Any script added into the editor will be simply held in memory
  • All script IDs will be ignored totally until the time comes for saving, but each script will be assigned one, though they will be simple unique identifiers mainly, not really be used for ordering
  • When the time comes to save, we first iterate over the list of scripts marked for deletion, and delete them, using the path attribute that was set when it was loaded
  • Then we iterate the script list, using the index to generate the name using the INDEX-NAME.rb convention. This name is checked against the name it had when it was loaded, if different, the file with the original name is deleted, and it is saved with the new name

So, if I delete script no.10 and save, all the .rb files after no.11 have to be re-saved? If yes: Isn't that a lot of disk IO? Many of the scripts may not even have changed, just their position, but they still get recreated. In the Script object you created, you could use a "modified?" flag to see if a loaded script is modified. If not, instead of deleting and re-saving the script, rename it. I'm sure this was among the kinks you wanted to work out, but I'm just saying.


I have an idea on how to deal with script order. Spoilered because it's long with a few examples.
(I have a reputation for making things unnecessarily complicated. If you feel this is one such case, then feel free ignore this post from here on)

(click to show/hide)
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)

The best of freeware reviews: Gizmo's Freeware Reviews



Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #39 on: December 05, 2011, 07:29:00 PM »
Simply renaming scripts is very possible. I had already thought of implementing something similar, though I haven't yet. I already have a flag set if there were modifications for each script.  I need only to reorder the save method and act appropriately.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Fantasist

  • Lexima Warrior
  • *******
  • Posts: 2222
  • LV: 146
  • Gender: Male
    • View Profile
    • Blog
Re: Script Structure
« Reply #40 on: December 05, 2011, 07:51:36 PM »
Ah, so you've covered this already. All the best, then! :)
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)

The best of freeware reviews: Gizmo's Freeware Reviews



Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19898
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Script Structure
« Reply #41 on: December 05, 2011, 10:32:41 PM »
If you have edited 20 maps and hit the save button, you will still get a lot of disk IO.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Fantasist

  • Lexima Warrior
  • *******
  • Posts: 2222
  • LV: 146
  • Gender: Male
    • View Profile
    • Blog
Re: Script Structure
« Reply #42 on: December 05, 2011, 10:51:56 PM »
Of course >_< :facepalm:
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)

The best of freeware reviews: Gizmo's Freeware Reviews



Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: Script Structure
« Reply #43 on: December 06, 2011, 05:45:04 AM »
I tweaked the save function a little bit. It now behaves like this:

  • Gets the ID of the script by its index in the Script array
  • Creates a filename using the ID and the scripts name
  • Checks if the script has had text modified
  • If not, it compares this filename to the filename the script had when it was loaded
  • If they are the same, nothing is done and it moves to the next script in the enumeration
  • If so, a simple renaming of the files is performed
  • If the script DOES have modifications, the filenames are once more compared
  • If the they are not the same, a new path is generated for the script, and the original path is deleted
  • The script is saved using its internal "path" variable as the location

This should maintain the least amount of IO access, pose no problems with indexing, and pose no problems with moving/inserting/deleting scripts. Does anyone see a problem with this?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19898
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Script Structure
« Reply #44 on: December 06, 2011, 09:14:48 AM »
I knew you could handle it. <3
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5128
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: Script Structure
« Reply #45 on: March 09, 2013, 08:48:24 AM »
I'm trying to implantation a way to simply organize scripts in the editor that doesn't involve making blank scripts to act as separators.  a sort of "Region" or "section" like set up where the scripts are still arranged linearly in a list but a inclusive range of indexes could be mapped to a region. I was kind of wanting to make a ScriptIndex file that could store a folder like structure for scripts that the engine could use to determine load order


but if that not a good Idea I guess I can store a list of regions in the project file and map script indexes to them. consecutive indexes with the same tag would be displayed in the list under a folder
« Last Edit: March 09, 2013, 08:49:47 AM by Ryex »
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19898
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Script Structure
« Reply #46 on: March 09, 2013, 03:59:01 PM »
I think that's ok as long as we don't violate the script order determine by alphabetic order and our prefix numbers in filenames.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.