Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 30

Thread: Rules of Scripting

  1. #11

    Default

    Quote Originally Posted by Sor View Post
    I'm for this idea of splitting those indexes up. I'm using the same method to assign indexes to huddraw functions in my projects so will switch over when this is incorporated.
    But I wonder how we are going to receive a -1 or 256 error response in script?
    Maybe if nothing is available, return the integer 0. Then scripting will allow us evaluate it as a boolean. If 0, then it's false.
    local.killsHud = getNextIHud
    if(local.killsHud)
    {

    }
    else
    {
    println "No IHuddraw indexes available."
    }
    Quote Originally Posted by Sor View Post
    On the same subject, what are we going to do those rules? While I'm sure the most active scripters on here would conform without a hitch, I don't think everyone will.
    You are right, not everyone will do it. But, with the mod loader that RR is coming out with, we could make documentation of how to use this mod loader and also these Standardized Rules for using the mod loader. Then, we just hope for the best I think, lol.

  2. #12
    Über Prodigy & Developer Razo[R]apiD's Avatar
    Join Date
    May 2010
    Location
    Poland, Lublin
    Posts
    3,257

    Default

    Sor,

    Stuff like local.sVariable, local.aVariable, etc. is just for us, coders. The rules are also only for us, who will write whole libs and loader. Those are just scripting guide lines for us, so we use the same coding style through whole project.

    Let's say, Armageddon has added 300+ lines of code, and now I want to fix something. I see variable called local.hud, and I don't know wheter it's a hud index, or maybe hud text, or maybe an array with hud text, hud pos etc. I'll have to look through those 300+ lines of code to actually find the line where Armageddon assigned something to local.hud so I can know what's in there.

    Byt let's say the script has 300+ lines of code, and at 10th line, Arma did local.hud = "some text", but on 73rd line he did local.hud = 1

    If we use the naming convention I proposed, I immediately see that local.iHud is an integer, and I can assume that it's a hud index or something.
    It's just easier for us. Also the guide lines are only for us, we won't enforce them on anyone except those who will work on Reborn .PK3 content so we work with the same coding style through whole work.

    This is to make our life easier and code to look cleaner.

    ----------------------------------------

    I'm adding:

    * Reading whole file into text variable (string)
    * Saving whole string variable into file

    These two will be very fast because they will use byte operation, so you will need to open a file in binary mode to use them. Then you can parse the string, etc. It's good when you don't have to update certain lines of the file but just write or read it all.

    * Move/Rename file
    * Remove file
    * Copy file
    * File exists

    Some handy stuff

    * sin, cos, tan, tan2, asin, acos, atan, sinh, cosh, tanh, exp, log, log10, pow, sqrt, and some more, they will be faster and more precise, but we'll still create wrappers for them in our libs

    Now I actually think of adding command that will return variable name

    local.mytest = "lol"
    local.name = varname local.mytest

    conprintf local.name will give you "mytest"

    I think this is possible.

    I'll also try to add a command to open files from .pk3, read them and save them into .pk3.

  3. #13
    Banned
    Join Date
    May 2010
    Location
    fuck off?
    Posts
    1,145

    Default

    sounds amazing additions,

    I like the variable naming, I will keep it and redo all the scripts at some point. A bit hectic at the moment in life and I feel its not needed to be rushes right now anyway.

  4. #14
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    Uhm... not sure if the variable naming will actually do what it's supposed to. Say you write a function to which you can pass on several variables:
    Code:
    myFunc local.fVar local.vVar:
    end
    Now, if we use the varname command to convert it to a string, it won't tell us for sure that fVar is a float. Because we used "fVar" in the receiving function with the expectation that fVar will be a float.
    This defeats the purpose. It would only work by either returning every single reference pointer (vars, targetname..) in the engine for the same piece of data or by returning the variable's name in the linking/previous thread.

    And if this is only for the assumption that fVar is a float or vVar is a vector, then why can't we just name the variables whatever we like and still work with regards to the expected type of variable.

    Quote Originally Posted by RazoRapid
    * Reading whole file into text variable (string)
    * Saving whole string variable into file

    These two will be very fast because they will use byte operation, so you will need to open a file in binary mode to use them. Then you can parse the string, etc. It's good when you don't have to update certain lines of the file but just write or read it all.

    * Move/Rename file
    * Remove file
    * Copy file
    * File exists

    Some handy stuff

    * sin, cos, tan, tan2, asin, acos, atan, sinh, cosh, tanh, exp, log, log10, pow, sqrt, and some more, they will be faster and more precise, but we'll still create wrappers for them in our libs
    Awesome stuff. I can't wait. But don't strings have a maximum capacity of 1024 chars? When text in the file is longer than 1024 chars, how are you going to circumvent that?
    Last edited by Sor; September 16th, 2012 at 07:25 PM.

  5. #15
    Über Prodigy & Developer Razo[R]apiD's Avatar
    Join Date
    May 2010
    Location
    Poland, Lublin
    Posts
    3,257

    Default

    Why do you assume that it has 1024 maximum lenght? I though it's just limited by the memory.

    Ad. It's easier for other coders to work with someone's code and to maintain the code when you have to get back to the code you wrote months ago. It's not a problem for me to write and use names that are meaningful for me. But when someone else will try to fix something in my code, we will need to spend additional time to actually get the idea what this or that variable is for. When he sees variable with v in it's name he knows it's a vector and this may clarify a lot of stuff in the code that this person has never seen before and now has to fix something in it.

    http://en.wikipedia.org/wiki/Hungarian_notation

    There are some disadvantages pointed out too, but most of them don't apply for us. However, we can also just try to use very descriptive names. Instead of local.text, use local.hudTextToBeDisplayed. And I don't mind long variable names if they are descriptive enough.

    This is just to make refactoring easier and so on. Also our scripting language is untyped, so this notation makes it easier to remember the type of variable.

  6. #16

    Default

    Ability to use macros and #define in scripting, as well as the possibility to use hexadecimal numbers, and long double variable type in scripting

    but then I don't know if this is really useful.

    And an ability to create sphere, cube, torus etc in-game via scripting?
    Last edited by Ley0k; September 17th, 2012 at 08:27 AM.

  7. #17
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    I know it's limited by memory but my assumption was the engine could prevent any memory problems by setting a cap of 1024 on the memory of each string, like it does with variables and entities. Interestingly, the only reason simple entities like info_pathnode, listener etc. don't have such a cap is because the developers couldn't afford to be limited by 1024 pathnodes on the large single player maps they made.

    Razo, I agree, but I think most of the knowledgeable scripters, active or otherwise, already know that lines of code needn't be unnecessarily cryptic and wrote scripts with this in mind. They, like me, probably didn't do that to make it easier for other people per se, but first and foremost they did it to make it easier for themselves when they have to or want to edit/update/re-write an old work of theirs in the future. Besides, it's easy to find out which type of variable a random one is by looking at how the script handles it or even declares it. Usually, the type of variable isn't as important as from which thread/script it's coming from, is. That variables should be descriptive, no problem, but I usually make those names up as I go along (as functional descriptions) so it's hard for me to unlearn that and to make the variables conform to standardized notations in the future.

    Interestingly, the later works of jv_map, such as skylimit or bot2beta (and the later, unreleased betas), contained scripts that were deliberately converted by an external program he had written in order to make them as unreadable as possible to the inquisitive eyes of an aspiring modder. He, on the other hand, would have the only clean and descriptive version for himself. I think he did to prevent lots of people, who don't really know what they're doing, from releasing modded versions of his work full of errors and trivial, insignificant, unnecessary 'bling'. I guess he must have figured that making his work a towering wall of incomprehension, less might be tempted to add their silly modifications to it. To that sentiment, I believe scripters are entitled to the liberty of making their scripts unreadable to 'scripting tourists'. Not only will that make them come running to the forums where they might actually learn something, but if they invest double the time into understanding such a script, they'll understand it twice as well.
    Last edited by Sor; September 17th, 2012 at 05:18 PM.

  8. #18

    Default

    I added hud.scr and anticham.scr to the repository.

    I noticed that for the anticham textures, I have more than 125 textures so since we've split them in 2, I don't have enough indexes now.
    Should I just change it to one method instead of 2? level.hud.nextHudID ?

  9. #19
    Über Prodigy & Developer Razo[R]apiD's Avatar
    Join Date
    May 2010
    Location
    Poland, Lublin
    Posts
    3,257

    Default

    What if you have more than 255 indexes? Will you use every? I think that Anticham concept needs to be reworked. Problem is we don't know wheter the texture got displayed or not. If my hacked sking texture will be out of your list of 256 skins, you won't do me anything.

    I think we should introduce rotations. So we can check even 1k+ textures. We should use for example up to 10 indexes. Then take 10 textures display them for a minute, take next 10 and so on. It can't be too fast (this won't annoy cheaters), and it can't be too slow (this won't affect cheaters).

    We can also use random display times from chosen range, and also random textures, or random blocks of textures.

    What I am saying is that Anticham is too ineffective to let it eat up a lot of resources (indexes)

  10. #20

    Default

    Yes I agree. It annoys me that we can only do 256.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •