• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!
Kazeon
Reaction score
627

Profile posts Latest activity Postings Experience Media Albums Resources About Medals

  • If it is still an op-limit issue, then you should probably put it in a separate function and run that on a separate thread. It might cause a big lag spike, but at least try it to see if it works. From there, you can optimize it or reduce the spike as needed:
    globals
    integer startX = 0
    integer startY = 0
    player trackPlayer = 0
    endglobals

    private function createTrackables takes nothing returns nothing
    local Track track = CreateTrackForPlayer(TRACKABLE_PATH, startX, startY, 0., 270., trackPlayer)
    call RegisterClickEvent(track, function onClick)
    call RegisterHoverEvent(track, function onHover)
    endfunction

    private function initTrackable takes nothing returns nothing
    local player p = GetEnumPlayer()
    local integer pn = GetPlayerId(p)

    set trackPlayer = p
    set startX = LOCATION_X - TRACKABLE_EXPAND_AREA

    loop
    exitwhen startX > InventoryAreaMaxX
    set startY = LOCATION_Y - TRACKABLE_EXPAND_AREA
    loop
    exitwhen startY > InventoryAreaMaxY + TRACKABLE_EXPAND_AREA
    call ForForce(bj_FORCE_PLAYER[0], function createTrackables)
    set startY = startY + 32
    endloop
    set startX = startX + 32
    endloop
    call BJDebugMsg("end")
    endfunction

    It is a little ugly because you have to pass values across a function, but at least it should work.
    It is probably hitting the op limit. Generating massive amounts of trackables in an area is very expensive. At the moment, given the input of 0 for pn, the outer loop will take 50 iterations to complete. The inner loop will take 60 iterations to complete. However, since it is a nested loop, the grand total will be 50*60 = 3000 iterations (a.k.a. 3000 trackables). It probably hits the op limit pretty quickly, too.

    To fix it, you'll need to either: (1) reduce the number of iterations (2) run the actions on a separate thread (e.g. using ForForce(), TriggerEvaluate(), ExecuteFunc(), or whatever) (I recommend ForForce). Still, there might be a lag spike. To reduce the lag spike, change the Z field (where it says LOCATION_Z) to 0. Trackables don't specify a z-parameter, so it is actually done by generating a platform at that height before placing the trackable (and creating/removing a destructable is really slow). If the input is 0, my system will skip creating the destructable in general, and that can save a lot of performance.

    Otherwise, just moving it to a separate thread should be fine. It might get a little laggy since starting a new thread is expensive, so you can always split it over time using a timer or something like that.
    Just wanted to say that if you have any suggestions, post them in the gaias subforum here on hive instead of writing me a visitor message, as with almost all major decisions regarding the game I'll take the community oppinion into consideration.
    You do have to create first.

    >> so why do this check results syntax error?
    >> if EmptySlot[1] > 0 then :/

    You must to if integer(EmptySlot[1]) > 0 then
    That won't work because Tables are integers and the 0 would overwrite. Think of it as arrays. You wouldn't set an array to X and then set it to Y and expect it to still remember the X. This would work:


    set EmptySlot[GetHandleId(whichUnit)] = Table.create()
    set EmptySlot2[GetHandleId(whichUnit)] = 0
    Well, I'm in final grade and need to face the final school exam.
    Sure thing, however, the scale of moderation is higher at THW, make sure to follow Moderators Guide for approval here if it doesn't meet THW rules yet :)
    Hi! i would like to ask youu something, sir.
    How can you restart a map via triggers? like in your flappy bird map?
    Thank you, I didn't think about that, when converting the code from GUI to JASS.
    The first release was mostly custom script, but GUI.
    I'm subscribed at the map thread and no, when I tested it, it does not. Elapsed time works but he also said it does not which is PRETTY weird.
    Just a note from the Shinobi Showdown, he actually tried that and does not work and will never (tested, sounds does not play at Map Init) but he also said that it does not stop at Elapsed time which is weird because for me it works.
    Purpose of adding extra space and/or linebreaks comes from readability of the code. Its more convenient for other users to be able to actually read and understand script without scraching their own head and asking whats going on out there.

    In case of campareSubstrings method, there are multiple locals, instead of one, like in most other methods. To separate variable declaration from actual operations, additional linebreak is needed to add readability. This is not the case when we have merely 5-6 code lines with single local.
    Operators behave generally like functions, they differ however, syntactically from them. Operators allow programmers to simplify their code, adding intuivive syntax and perform multiple operations with single sign (its not limited to signs tho). It is usefull in various cases, and arrays being the most common example with their [] and = operators.

    Since you asked me about strings, lets consider a string example:
    local string s = "this is an example string" Note that such string is sequence of contingous characters, thus we can interpret such string object as an array or vector of elements of type char.
    There are situations when you want to access specified element from such vector, and you do want to do this without need of iterating through whole container, or just to make code more elegant, you want to avoid spam of function calls such setchar/getchar.

    Here come operator usefullness. Operator [] functions as access caller (getter function) while = works as assignment (setter). In jass there is, however, []= instead which works in the similar way.

    Now, example is worth more than thousand words:
    // consider the same string sequence as above, but within object of type String
    local String s = String.create("this is an example string")

    // now, lets say we want to access 7th element, thus:
    local string char7 = s[7]
    // print it:
    call BJDebugMsg(char7) // outputs: "s"

    // lets use []= as "setchar" method:
    set s[7] = "X"
    // print it:
    call BJDebugMsg(s.str) // outputs: "this iX an examaple string"
    Well, it indeed grants much more visuals to the chat but my map's a single player and chances are it'll not serve any purpose as far as I know and no offense intended.
    I don't know, you have to benchmark it, if you really want to know the result.
    Don't think too speed freaky, many times the difference are a few nanoseconds, which has no influence at all.
    If speed would matter that much you couldn't make a map in GUI at all.


    Btw a nested loop and two loops are very different things.
    It should be f different types in a single index. I believe hashtables sometimes let you do that but it's not good practice and hasn't been tested.
    Check for libraries if you want to use them, but your not sure if they do exist. This is more an optional feature for public resources,
    because you should know if those libraries exist in your own map.

    static if LIBRARY_TimerUtils then
    set timer = NewTimer()
    //Map has TimerUtils, so the script uses TimerUtils API
    else
    set timer = CreateTimer()
    //No TimerUtils. Create the timer here.
    endif
  • Loading…
  • Loading…
  • Loading…
  • Loading…
  • Loading…
  • Loading…
  • Loading…
  • Loading…
Top