Jump to content

Photo

Automatic Global Script Combiner


  • Please log in to reply
40 replies to this topic

#1 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 04 October 2017 - 07:53 AM

Version 2 is here!

 

This one is something more people probably wanted: a program to combine global scripts into one slot. This process tends to stump a lot of new questmakers, so with this it should be a bit simpler. To use it, just:

  1. Download the HTML file and open it in your web browser
  2. Copy your global script file into the Your Global Script field.
  3. Copy the new script you're adding into the Global Script to Combine field. Unlike the last version, you can now copy scripts off the database in full and it'll stick the functions and constants above the global.
  4. Set Label Name to what it should label the parts of the script as in the combined global.
  5. Check Auto Indent to make it consistently indent everything
  6. Hit combine, If it worked, the second field will say ^^^ DONE ^^^ and you can copy the combined script from the first field. If this doesn't happen, that probably means the script you pasted didn't come with an example global included: it's just a bunch of functions. Unfortunately, in those cases it will still have to be combined manually.
  7. After combining your scripts any imports from the scripts will be moved down to the Imports Removed field. This is to prevent duplicate header errors. Just remember to import each of them at least once in your main script file.

Hopefully you guys will find this handy. Lemme know if you encounter any bugs.

 

Old download and instructions


  • Anthus, judasrising, Shane and 5 others like this

#2 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 04 October 2017 - 08:24 AM

Seems to work great. This'll help so many people ;O Good job Moosh.



#3 Geoffrey

Geoffrey

    Chosen One

  • Members

Posted 04 October 2017 - 09:34 PM

You are a god.


  • Jared likes this

#4 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 04 October 2017 - 09:58 PM

I love this, and I love the support you've given me with my bugs. Thank you so much!

 

Definitely pin this. :)



#5 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 05 October 2017 - 02:31 AM

I've updated the OP with a new version of the program. This time you can paste entire database scripts and it'll isolate the script block for you, making it even easier to use.


  • Jared likes this

#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 05 October 2017 - 03:10 AM

I'll have a look at this later. I may be able to optimise it, or do other magical goodies.

It strikes me that you could do a diff map to accomplish this goal. :)


I could probably write a simple C programme to do it, too.

Something you will like for the future, is function pointers, that are planned for 2.60. With those, you will be able to assign a pointer to a function, and that would make global script stuff stupidly simple, as longh as the scripter follows a formula:


int PreWDFunctions[256]; int PostWDFunctions[256];
global script active_generic{
    void run(){
        while(1){
            RunPreWaitDrawFunctions();
            Waitdraw();
            RunPostWaitDrawFunctions();
            Waitframe();
        }
    }
}

An init script sequence would store the pointers for these functions in the arrays, and the functions would run instructions in the enqueued order. This would make creating a script thatadds functions to the global active script as simple as adding a new init sequence script (another new model):

global script Init_MyHeader{
    void run(){
        void foo() { //doSomething;}
            
            int *p = foo;
            for (int q = 0;q < 256; q++)    
            {
                if ( PreWDFunctions[q] == 0 ) //no function in this index
                {
                    PreWDFunctions[q] = *ptr;
                    //pointer to the function is stored, so the function is
                    //automatically enqueued
                }
            }
        }  
    }
}
Essentially, you will be able to store funcytion calls in arrays, so the init script need only append the function to the appropriate section of the rray, and all functions in the array are run in oder by the global activre script. Howzat for simplicity?

This naturally, does not address global vars, but other magic can help with that.

-------

Anyway.... I'll look at your generator. Most of this can be done inC with string compares, so I suppose I shall see what you are using to accomplish your goal; fingers crossed that the word 'Java' is not involved.

At the lease, it will provide a mid-term solution for the userbase, and sounds as it it wil be beneficial to the average user.

#7 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 05 October 2017 - 03:35 AM

I'll have a look at this later. I may be able to optimise it, or do other magical goodies.

It strikes me that you could do a diff map to accomplish this goal. :)

I could probably write a simple C programme to do it, too.

I have no doubt the whole thing is awful in terms of optimization. This is only like the second time I've used Javascript ever, and already I've seen a couple places where I reinvented the wheel. :P

 

If you want to make your own version in C, you're more than welcome to do so.



#8 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 05 October 2017 - 08:15 AM

I found an obscure bug. Having an "{" in a comment "//" still applies indenting. Also I don't really approve of it automatically writing ^^^ DONE ^^^ into the second text field. If someone puts that into their script it'll give an error. xD Being able to put in one's whole scriptfile makes this much better though so goodjob on that.


Edited by Avataro, 05 October 2017 - 08:16 AM.


#9 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 05 October 2017 - 08:33 AM

I found an obscure bug. Having an "{" in a comment "//" still applies indenting.

Is there a script on the database that does this? I noticed this was a thing, but I figured in most cases where there's commented out code, the braces will still come in pairs, so it'd sort itself out. Notepad++ also has this behavior I noticed.

 

 

Also I don't really approve of it automatically writing ^^^ DONE ^^^ into the second text field. If someone puts that into their script it'll give an error.

That's actually there to prevent errors. I wanted to make it easier to add scripts in relatively quick succession, so I took out unnecessary step of copying from the third text field back to the first and instead had it print the result back to the first. But this introduced the issue of accidentally adding the same script twice by accident. So I had it print out ^^^ DONE ^^^ which simultaneously shows the user which field to copy from, clears the script from the other field, and prevents combining twice in a row because the button does nothing if there's no script in the second field.


  • Avaro likes this

#10 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 05 October 2017 - 08:40 AM

Is there a script on the database that does this?

 

Ah, well yeah I did it here https://www.purezc.n...=scripts&id=216 I'll fix that quickly.


Edited by Avataro, 05 October 2017 - 08:40 AM.


#11 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 05 October 2017 - 09:13 AM

Well regardless, I went ahead and added an exception to the tabbing function for braces in comments. It's likely there'll be other scripts out there with similar comments. Heck, they could even be some of mine. :P



#12 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 05 October 2017 - 10:45 AM

Would it be possible to update this so you can put FFC scripts in it as well? That way you can have ALL your quest's scripts in a single file? Or is that not a thing?



#13 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 05 October 2017 - 10:57 AM

Would it be possible to update this so you can put FFC scripts in it as well? That way you can have ALL your quest's scripts in a single file? Or is that not a thing?

In theory I could, but to combine an FFC script into your script file all you need to do is copy the whole thing and paste it at the bottom of the script. So doing it through this would just add extra steps.


  • Jared likes this

#14 Anthus

Anthus

    Lord of Liquids

  • Members
  • Location:Ohio

Posted 05 October 2017 - 11:45 PM

Is this the real life? Or.. is this just fantasy? This seems too good to be real.

 

I need to go take a nap.

 

(But seriously, this is something that I'm sure a ton of people, myself included, will find a lot of use from. Thanks for another amazing ZC contribution, you're a wizard among men :))



#15 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 06 October 2017 - 07:29 PM

I have no doubt the whole thing is awful in terms of optimization. This is only like the second time I've used Javascript ever, and already I've seen a couple places where I reinvented the wheel. :P
 
If you want to make your own version in C, you're more than welcome to do so.


I wanted to mention that I worded this poorly. I was not aiming to imply that your code is going to be terrible, or anything of that nature. I primarily meant, that I might want to port it away from JS, and make it a platform-compiled binary of some sort; but I'm not sure if I will find the time to do that, ever.

In C, you could do this with string compares and text matching, but nothing is perfect. I might prefer to do this kind of thing in Pascal.

Would it be possible to update this so you can put FFC scripts in it as well? That way you can have ALL your quest's scripts in a single file? Or is that not a thing?


That is an append utility. All that you need to do for that, is to run strcat() on a series of text files. A tool for doing this is likely find its way into ZQuest, in the future (i.e., output all code to a file). ;)


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users