Author Topic: Script Structure  (Read 13246 times)

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5131
  • 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: 5131
  • 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: 5131
  • 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: 19905
  • 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: 5131
  • 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: 5131
  • 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: 19905
  • 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: 5131
  • 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: 19905
  • 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: 5131
  • 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: 19905
  • 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.