Announcement

Collapse
No announcement yet.

Parsing Entities

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Parsing Entities

    I haven't given this enough thought to claim anything concrete, but my parsing delimiters concepts could probably be ported to Quake. I went looking in dpextensions and found this:

    Code:
    float(string s) stof = #81; // get numerical value from a string
    float(string filename, float mode) fopen = #110; // opens a file inside quake/gamedir/data/ (mode is FILE_READ, FILE_APPEND, or FILE_WRITE), returns fhandle >= 0 if successful, or fhandle < 0 if unable to open file for any reason
    void(float fhandle) fclose = #111; // closes a file
    string(float fhandle) fgets = #112; // reads a line of text from the file and returns as a tempstring
    void(float fhandle, string s, ...) fputs = #113; // writes a line of text to the end of the file
    float(string s) strlen = #114; // returns how many characters are in a string
    string(string s1, string s2, ...) strcat = #115; // concatenates two or more strings (for example "abc", "def" would return "abcdef") and returns as a tempstring
    string(string s, float start, float length) substring = #116; // returns a section of a string as a tempstring
    vector(string s) stov = #117; // returns vector value from a string
    string(string s, ...) strzone = #118; // makes a copy of a string into the string zone and returns it, this is often used to keep around a tempstring for longer periods of time (tempstrings are replaced often)
    void(string s) strunzone = #119; // removes a copy of a string from the string zone (you can not use that string again or it may crash!!!)
    That could be all I need to turn my string to object system into a string to entity system. The code will probably be a mess.

    Why would I do this? Well, I see it like this: Currently, if you want to include an (ex) monster in your QC you have to write an entire "class" for it and that class has to be compiled into the QC. By using external objects you just need a QC mod that can handle parsing it into the game. So maybe you would have something like this:

    Code:
    player:
    {
    	health:100;
    	takedamage:DAMAGE_AIM;
    	solid:SOLID_SLIDEBOX;
    	movetype:MOVETYPE_WALK;
    	show_hostile:0;
    	max_health:100;
    }
    Of course it would include all of the stuff I left out, including animation frame numbers. That object would reside as a text file somewhere. When QC loads it checks for files, or maybe just gets all the text files that are present within a specific folder. Then it parses the files out to their proper entity description and finally "injects" them into the game wherever the corresponding ent resides in the map.

    I'm not saying that I intend to build this. I am simply sharing something that has crossed my mind a few times. There's probably reasons why this would even be bad (cause all my specialty QC turns out to be "bad") and I am all ears on these potential reasons as long as you know what you are talking about.

    ---

    Completely lacking a RegEx system is a bummer. I'm assuming there is no RegEx in QC cause there is no RegEx type. That being said, a string to entity parser in QC is gonna be a procedural, loopy mess. I'm also not positive that the string manipulation features in dpextensions are even sufficient.

    I saw tokenize in dpextensions. I am curious if it could be used very creatively to help achieve this goal.

    Everything should only be one layer deep, so I don't really have to try and worry about never-ending nesting. It should all be pretty much where the main object container represents "self". Instantiating a self goes one dot deep. The possible use of arrays on an entity means I might have to go one dot and an index. Since I'm pretty sure it would be retarded to shove entities into an array that is a member of an entity, self.array[num] is probably as far as I will ever have to parse. This means that no one nesting possibility can ever happen inside of itself. No multi-dimensional arrays, no entities inside of entities, and the rest obviously cant have more versions of itself within it cause it never could.
    Last edited by MadGypsy; 11-15-2013, 06:16 PM.
    http://www.nextgenquake.com

  • #2
    loadfromfile("foo.ent");
    is easier. no need to faff around with json and arbitary fields and special constants etc.
    and its compatible with already existing .ent files.
    loadfromdata also exists.
    I'll admit that they don't invoke spawn functions though.
    Some Game Thing

    Comment


    • #3
      Let's back up a step. I hear what you're saying and I knew a lil hair of what you said, but let's consider this way. I'm not saying it's the best way or even a good way. I just want to consider this way.

      real questions - I know nothing:

      What's bad about it?

      Can this be made to work with negligible "bad"?

      Can I fake (or use) RegEx somehow?

      What does tokenize do? I don't mean showing me the function call, I get that part. When I say "split this string by commas", what happens to the non comma data?

      I think that's all I need to know. I'm still not saying that I am going to actually make this. There is a lot more to do outside of the parse than writing the parser itself. All of that data needs to be handled. An entire animator would need to be created to handle the frame numbers. What do I do about frames that perform a task? There would be a whole lot to do. The challenge is appealing to me, however.
      Last edited by MadGypsy; 11-15-2013, 06:38 PM.
      http://www.nextgenquake.com

      Comment


      • #4
        I'm used to split turning a string into an array of strings.

        It's a bit fun to think of how to write an entity "loader" in quakec, but there's many hard problems that come from the mechanics of the system. Parsing the text file crudely might be the easiest problem; there's a problem using nonprecached sounds/models, there's a problem of having custom functions (I assume the new entities will do new things), and there's even a problem of having the entity show up in a map once it's all done.

        I think you might actually be considering is writing quakec in quakec, but this quakec happens to be text files. One purpose of quakec is to create entities without having to rebuild the engine. You already get to make your own entities and functions with it, after all.

        Comment


        • #5
          My concept was to be able to inject models that aren't compiled into the QC. Precache and what-not is relatively simple. The QC would parse the string into an entity, within that I could easily say [precache(someVal)] - where someval is a path included in the object string.

          The real problem is what both of us said - how do I inject new behavior? Like on frame 5 of whatever animation "throw a dagger". Psssh there is no way to inject that. Someone would at the very least have to write "throw a dagger" code, which means they are editing the QC and therefore external injection is probably unnecessary.

          Like I stated earlier though, this is all conceptual. It's these nutty concepts that I consider which bring you things like my game controller for mapping and plugging a bunch of really good but, unrelated programs together to achieve a QC development environment. Actually I had a nutty idea that I got to work aces but, I never released it (i think). In my radiant build menu I made a 32 point compass of vars that can be used to position sunlight with compass points instead of numbers

          Code:
          <var name="E">90</var>
          <var name="EENE">101</var>
          <var name="EESE">79</var>
          <var name="ENE">113</var>
          <var name="ENNE">146</var>
          <var name="ESE">68</var>
          <var name="ESSE">34</var>
          <var name="N">180</var>
          <var name="NE">135</var>
          <var name="NENE">124</var>
          <var name="NNE">158</var>
          <var name="NNNE">169</var>
          <var name="NNNW">191</var>
          <var name="NNW">202</var>
          <var name="NW">225</var>
          <var name="NWNW">236</var>
          <var name="S">0</var>
          <var name="SE">45</var>
          <var name="SESE">56</var>
          <var name="SSE">23</var>
          <var name="SSSE">11</var>
          <var name="SSSW">349</var>
          <var name="SSW">337</var>
          <var name="SW">315</var>
          <var name="SWSW">304</var>
          <var name="W">270</var>
          <var name="WNNW">213</var>
          <var name="WNW">248</var>
          <var name="WSSW">326</var>
          <var name="WSW">292</var>
          <var name="WWNW">259</var>
          <var name="WWSW">281</var>
          implementation
          Code:
          -sunmangle "[NE],-60"
          You can even use that syntax in "customize" for the build menu within radiant. So many things have been made for Quake that you really have to think about something other than Quake to create anything original.
          http://www.nextgenquake.com

          Comment

          Working...
          X