Jump to content

ethanwdp

Member
  • Posts

    584
  • Joined

  • Last visited

Community Answers

  1. ethanwdp's post in Random titles with profession was marked as the answer   
    I've tackled with something like this, where I needed to have randomization. Since tables are able to hold information as numbered entries, I just had a random number generator pull out an entry based on the number generated.
     
    Example: Table has 5entries, 1,2,3,4, and 5.. RNG generates 3, so I use the third entry.
     
    This should do the trick:
    titleTable = {"Pvt. ","Sgt. ","Cpt. "}local function GRN(argTable) local randNumber = ZombRandBetween(1, #argTable) -- sets the maximum generated number to the size of the given table. Example: fooTable has 2 entries, so the maximum number is 2. return argTable[randNumber]endlocal function soldier_start(player, square) local profession = player:getDescriptor():getProfession(); if profession == 'soldier' then getPlayer():getDescriptor():setForename( GRN(titleTable) ); endendsoldier_start(getPlayer())
  2. ethanwdp's post in What can I use to return SliceY? was marked as the answer   
    Figured it out.
     
    Turns out that the slice wasn't important, and using nil instead worked fine.
  3. ethanwdp's post in Player Update was marked as the answer   
    getPlayer():resetModel()
  4. ethanwdp's post in getXP was marked as the answer   
    It's getPlayer():getXp()
     
    Yes, the "P" in "Xp" is supposed to be lowercase, which is odd.
  5. ethanwdp's post in getDirectionTo woes was marked as the answer   
    EDIT: Nevermind, figured it out.
     
    getDirectionTo() only returns North West or North for some reason, so I used IsoDirections.fromAngle(getPlayer():getAngle()). Works like a charm now:
     
    Code:
     
  6. ethanwdp's post in Create context menu problems was marked as the answer   
    Ah, okay. I misinterpreted the question, my bad.
     
    If you want the Enable sub menu to appear, you have to register it as one.
     
    Try this:
     
  7. ethanwdp's post in Trying to barricade an object below mouse was marked as the answer   
    Edit2: RoboMatt was on the right track, as it turns out. The barricade TA's timer is not hardcoded in, and you can remove it. I was also barking up the wrong tree for objects, I had to first detect the instance of the object, and then store it in a variable. I then call ISTimedActionQueue.add(ISBarricadeAction:new(getPlayer(), variableThatIStoredInstanceIn, 0));
     
    Here's the working code:
     
     
    You need a hammer equipped(will work on making that automatic later), but it successfully barricades it.
     
    Now that I have a framework for it, I can also make it barricade to a specific level, and unbarricade to a specific level.
     
    Edit 3: Fully working function with many safe guards in place to ensure instant barricading without disrupting the users inventory or equipped items:
     
  8. ethanwdp's post in Change Moodle Level was marked as the answer   
    getPlayer():getStats():setPain(0);
     
    setPain would be the set function for the moodle, for example setHunger. They have dedicated set functions.
     
    They go up to 4, each increasing level is an increase in severity.
  9. ethanwdp's post in In what order are mods loaded? was marked as the answer   
    Alphabetically.
     
    Code to determine this:
     
  10. ethanwdp's post in Can't get RichTextPanel to log more than one string was marked as the answer   
    Figured it out. For some reason, the global table that stored the lines wasn't registering it if I stored it in the letmespeakcommands lua file as opposed to the main letmespeakwindow file.
     
    Code:
    letmespeakcommands

     
    letmespeakwindow
  11. ethanwdp's post in Confusing Mods was marked as the answer   
    You have Winrar, right?
    Winrar is, well, the program that opens Rar files. If you don't have it already, I'd recommend it.
    It's free (after 30 days it begs you to buy it whenever you open winrar, but you can close the notification), it's a lot better than other zip/rar/whatever managers I've used, and it can open rar files.
     
    People (like me) usually use it to compress their mods to make it a faster download, but I stopped using the format after I realized not everybody could use it.
  12. ethanwdp's post in How to test .lua code on the fly? was marked as the answer   
    Some of the code there was from an early version, so the lua interpreter might be buggy (fixed version below)
    And for your question, I have no clue. I don't have much experience with lua interpreters. That was my first time making one
    Not too sure how autocompletion would work. The ISTextEntryBox doesn't support tooltips AFAIK.
     
    Btw, here's an updated lua interpreter, because the last one couldn't even accept spaces:
     
    letmespeakcommands
     
    Updated CheatCore:
    I would throw up a download, but the rest of this mod still needs a lot of work. Hope that works in the meantime.
  13. ethanwdp's post in Trying to detect enter key press for ISTextEntryBox was marked as the answer   
    EDIT:
    Figured it out.
    I decided to modify the original ISTextEntryBox, and make the onCommandEntered() function do something.
    My hunch was right, it DOES invoke onCommandEntered() properly, as it's just mirroring a few Java files.
    When I made it do something, like print, it actually worked. I'm guessing that's because the default function is empty, probably because making it return true makes horrors happen.
     
    So I added this line to my code:
     
    And it worked! It seemed to override the default ISTextEntryBox:onCommandEntered(), and I didn't have to include an override file.
     
    After doing some tweaking, here's the new (working) code:
     
  14. ethanwdp's post in getVirtualZombie() is no longer a thing in B32, how do I spawn a zombie now? was marked as the answer   
    Sorry for the late reply, was a bit busy.
    I figured it out, spawnHorde(x,y,x2,y2,z, numberToSpawn) works perfectly . Here's what I did:
     
    As it would turn out, spawnHorde also works for any number of zombies, including a single one.
  15. ethanwdp's post in getVirtualZombie() is no longer a thing in B32, how do I spawn a zombie now? was marked as the answer   
    Sorry for the late reply, was a bit busy.
    I figured it out, spawnHorde(x,y,x2,y2,z, numberToSpawn) works perfectly . Here's what I did:
     
    As it would turn out, spawnHorde also works for any number of zombies, including a single one.
  16. ethanwdp's post in Check weapon attachment was marked as the answer   
    When in doubt, download JD (or any Java class decompiler) and check the code for functions you can call.
    In this particular case, zombie/inventory/types/HandWeapon.class would come in handy. If it declares a function there, you can use it.
    So let's say you wanted to check for a scope on the player's currently equipped item. You could use something like...
     
    if getPlayer():getPrimaryHandItem():getScope() then
            print("Successfully retrieved "..getPlayer():getPrimaryHandItem():getScope():getName())
    end
     
    It's like a chain, if getPlayer() returns true then it goes on to call getPrimaryHandItem(), and if that returns true then it calls getScope, etc etc.
    Usually, if you want to be able to use a classes functions, you have to get it first. Usually you just plonk get before the class name, so say you're trying to access a VirtualZombieManager function, so you use getVirtualZombieManager():getBlahBlah().
     
     
    But let's say that you wanted to check for, say, an 8x scope only. You could use something like...
     
    if getPlayer():getPrimaryHandItem():getScope():getName() == "x8 Scope" then
            print("Successfully retrieved "..getPlayer():getPrimaryHandItem():getScope():getName())
    end
     
    getName() obtains the name of the item in a string. AFAIK, it is case sensitive.
     
    Or, if you want it to print only when there's a scope and a stock of some sort, then you could do...
     
    if getPlayer():getPrimaryHandItem():getScope() and getPlayer():getPrimaryHandItem():getStock() then
            print("Successfully retrieved "..getPlayer():getPrimaryHandItem():getScope():getName().." And "..getPlayer():getPrimaryHandItem():getStock():getName())
     
    end
     
    And, if you wanted to make that even shorter and easier, you could just save the first part of the chain (as in, getPlayer():getPrimaryHandItem()) into a function.
    So, for example...
     
    local weapon = getPlayer():getPrimaryHandItem()
     
    Because it's not technically a function, there's no need to use brackets or anything, just call it like so...
     
    local weapon = getPlayer():getPrimaryHandItem()
        
    if weapon:getScope() and weapon:getStock() then
            print("Successfully retrieved "..weapon:getScope():getName().." And "..weapon:getStock():getName())
    end
     
    And so on.
    If there's anything I left unclear, feel free to ask.
  17. ethanwdp's post in Check weapon attachment was marked as the answer   
    When in doubt, download JD (or any Java class decompiler) and check the code for functions you can call.
    In this particular case, zombie/inventory/types/HandWeapon.class would come in handy. If it declares a function there, you can use it.
    So let's say you wanted to check for a scope on the player's currently equipped item. You could use something like...
     
    if getPlayer():getPrimaryHandItem():getScope() then
            print("Successfully retrieved "..getPlayer():getPrimaryHandItem():getScope():getName())
    end
     
    It's like a chain, if getPlayer() returns true then it goes on to call getPrimaryHandItem(), and if that returns true then it calls getScope, etc etc.
    Usually, if you want to be able to use a classes functions, you have to get it first. Usually you just plonk get before the class name, so say you're trying to access a VirtualZombieManager function, so you use getVirtualZombieManager():getBlahBlah().
     
     
    But let's say that you wanted to check for, say, an 8x scope only. You could use something like...
     
    if getPlayer():getPrimaryHandItem():getScope():getName() == "x8 Scope" then
            print("Successfully retrieved "..getPlayer():getPrimaryHandItem():getScope():getName())
    end
     
    getName() obtains the name of the item in a string. AFAIK, it is case sensitive.
     
    Or, if you want it to print only when there's a scope and a stock of some sort, then you could do...
     
    if getPlayer():getPrimaryHandItem():getScope() and getPlayer():getPrimaryHandItem():getStock() then
            print("Successfully retrieved "..getPlayer():getPrimaryHandItem():getScope():getName().." And "..getPlayer():getPrimaryHandItem():getStock():getName())
     
    end
     
    And, if you wanted to make that even shorter and easier, you could just save the first part of the chain (as in, getPlayer():getPrimaryHandItem()) into a function.
    So, for example...
     
    local weapon = getPlayer():getPrimaryHandItem()
     
    Because it's not technically a function, there's no need to use brackets or anything, just call it like so...
     
    local weapon = getPlayer():getPrimaryHandItem()
        
    if weapon:getScope() and weapon:getStock() then
            print("Successfully retrieved "..weapon:getScope():getName().." And "..weapon:getStock():getName())
    end
     
    And so on.
    If there's anything I left unclear, feel free to ask.
×
×
  • Create New...