Libraries???

elpini0

New Member
Reaction score
1
Hi, im working on a new map and I was looking for a trigger to make trees respawn.

I found this:

JASS:
library REGROWTREES initializer Init
globals
    private constant real RegrowAfter = 23.0 // seconds to wait until tree regrows
    private constant real Range = 250.0      // distance around tree that needs to be free of units before regrowing
    private unit u
    private group g = CreateGroup()
    private boolexpr b
    private boolean ok
endglobals
private function IsTree takes nothing returns boolean
    local boolean b
    call SetUnitX(u, GetWidgetX(GetFilterDestructable()))
    call SetUnitY(u, GetWidgetY(GetFilterDestructable()))
    set b = IssueTargetOrder(u, "harvest", GetFilterDestructable())
    call IssueImmediateOrder(u, "stop")
    return b
endfunction
private function W2D takes widget w returns destructable
    return w // do not inline
    return null
endfunction
private function IsUnitNear takes nothing returns boolean
    if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.5 then
        set ok = false
    endif
    return false
endfunction
private function Regrow takes nothing returns nothing
    local widget t = GetTriggerWidget()
    call TriggerSleepAction(RegrowAfter)
    loop
        set ok = true
        call GroupClear(g)
        call GroupEnumUnitsInRange(g, GetWidgetX(t), GetWidgetY(t), Range, b)
        exitwhen ok
        call TriggerSleepAction(3.0)
    endloop
    call DestructableRestoreLife(W2D(t), GetDestructableMaxLife(W2D(t)), true)
    set t = null
endfunction
private function Register takes nothing returns nothing
    call TriggerRegisterDeathEvent(bj_destInRegionDiesTrig, GetEnumDestructable())
endfunction
private function Init takes nothing returns nothing
    set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'nmpe', 0, 0, 0) // Mur'gul Slave...
    call SetUnitInvulnerable(u, true)
    call ShowUnit(u, false)
    call UnitAddAbility(u, 'Aloc') // Locust
    call UnitAddAbility(u, 'Ahrl') // Harvest Lumber
    set bj_destInRegionDiesTrig = CreateTrigger()
    call EnumDestructablesInRect(bj_mapInitialPlayableArea, Condition(function IsTree), function Register)
    call TriggerAddAction(bj_destInRegionDiesTrig, function Regrow)
    set b = Condition(function IsUnitNear)
    call RemoveUnit(u)
    set u = null
endfunction
endlibrary


Well, my problem is that i searched a lot and couldn't find HOW THE HELL DO I MAKE THIS USEFUL!

I tried making a new trigger called "regrowth", converted to personally edited text and copypasted (after erasing the previous text)

And when i test the map with World Editor, TFT opens its main screen... Not the map. So, i switched off the trigger with the library and it worked fine.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
This seems to be a quite old "system", as it still uses 'return bugs'...
JASS:
private function W2D takes widget w returns destructable
    return w // do not inline
    return null
endfunction


That kind of return behavior isn't allowed anymore, just replace the "Regrow" function with this:
JASS:
private function Regrow takes nothing returns nothing
    local destructable t = GetTriggerDestructable()
    call TriggerSleepAction(RegrowAfter)
    loop
        set ok = true
        call GroupClear(g)
        call GroupEnumUnitsInRange(g, GetWidgetX(t), GetWidgetY(t), Range, b)
        exitwhen ok
        call TriggerSleepAction(3.0)
    endloop
    call DestructableRestoreLife(t, GetDestructableMaxLife(t), true)
    set t = null
endfunction


(Freehanded :S)
 

elpini0

New Member
Reaction score
1
Thank you for your response.

The problem is that i don't know how to "add a library" to my map.

I copy-paste the whole library into a new empty trigger and test the map, but in stead of play the map, the main manu of TFT shows up. So, i switch off the "trigger" or whatever that is (where i pasted the library) and it works fine, obviously not applying the desired effect that the library would have done.
 

elpini0

New Member
Reaction score
1
well, my newgen pack is updated from 2007, which is the latest version (as far as i know...)

And i think it has the latest version of the jasshelper too, doesn't it?
 

Komaqtion

You can change this now in User CP.
Reaction score
469
No it doesn't...
Download the file here, and extract it in the "jasshelper" folder in the Newgen folder :D
http://www.wc3c.net/showthread.php?t=88142

Also, have you made the changes I showed you ? :S
You do add that library correctly (I'd believe) itäs just that that library isn't compatible with the latest version of WC3, that's why you need to alter the code there, to make it work :D
 

elpini0

New Member
Reaction score
1
Thank you for your attention.

I tried to follow the steps to update the jasshelper, but i just can't understand how to do it...

What files should i upgrade? I downloaded the 0.A.2.B.jasshelper.7z file and then i'm lost...
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Extract the file by using Winrar or 7-zip.
Copy clijasshelper.exe and jasshelper.exe into your NewGen/Jasshelper/ folder.
 

Jesus4Lyf

Good Idea™
Reaction score
397
I copy-paste the whole library into a new empty trigger and test the map, but in stead of play the map, the main manu of TFT shows up.
Save the map before hitting test map. ie. immediately before you hit test map, save it first.
Let us know any syntax errors if there are any... after making sure you remove that W2D function.
 

elpini0

New Member
Reaction score
1
Extract the file by using Winrar or 7-zip.
Copy clijasshelper.exe and jasshelper.exe into your NewGen/Jasshelper/ folder.

Well, I actually did that and at first it showed an error message of "missing bin/SFmpq.dll".

I picked up both .exe to the NewGen folder where the IS a folder called "bin".

Then the error message turns into "JASSHelper Error // Missing arguments: <commonj> <blizzardj> <mappath>"
 

elpini0

New Member
Reaction score
1
Save the map before hitting test map. ie. immediately before you hit test map, save it first.
Let us know any syntax errors if there are any... after making sure you remove that W2D function.

Actually there are syntax problems... from line 1 to line 57...

Line 1: syntax error
Line 1: Statement outside of function
Line 1: Statement outside of function
Line 1: Statement outside of function
Line 1: Statement outside of function
Line 1: Statement outside of function
Line 2: Statement outside of function
Line 2: Statement outside of function
Line 3: Statement outside of function
Line 3: Statement outside of function
Line 3: Statement outside of function
Line 3: Statement outside of function
[...]

Mixed with other types of error...
 

tooltiperror

Super Moderator
Reaction score
231
First of all, you can make a copy of your bin folder found inside of the NewGen folder and put it inside your NewGen folder, in case you need to run it as a command line utility.

Second, you should get an updated common.j and blizzard.j by extracting it from the patch.mpq.

Third, you should have the .DLL in both bin's.
 

elpini0

New Member
Reaction score
1
First of all, you can make a copy of your bin folder found inside of the NewGen folder and put it inside your NewGen folder, in case you need to run it as a command line utility.

Second, you should get an updated common.j and blizzard.j by extracting it from the patch.mpq.

Third, you should have the .DLL in both bin's.

But why am i having all these problems when people can actually use lirbaries without any problem??

I reinstalled NewGen pack, updated both .exe files, copied the bin folder and still doesn't work...

JASS:
library REGROWTREES initializer Init
globals
    private constant real RegrowAfter = 8.0 // seconds to wait until tree regrows
    private constant real Range = 80.0      // distance around tree that needs to be free of units before regrowing
    private unit u
    private group g = CreateGroup()
    private boolexpr b
    private boolean ok
endglobals
private function IsTree takes nothing returns boolean
    local boolean b
    call SetUnitX(u, GetWidgetX(GetFilterDestructable()))
    call SetUnitY(u, GetWidgetY(GetFilterDestructable()))
    set b = IssueTargetOrder(u, &quot;harvest&quot;, GetFilterDestructable())
    call IssueImmediateOrder(u, &quot;stop&quot;)
    return b
endfunction
private function W2D takes widget w returns destructable
    return w // do not inline
    return null
endfunction
private function IsUnitNear takes nothing returns boolean
    if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) &gt; 0.5 then
        set ok = false
    endif
    return false
endfunction
private function Regrow takes nothing returns nothing
    local destructable t = GetTriggerDestructable()
    call TriggerSleepAction(RegrowAfter)
    loop
        set ok = true
        call GroupClear(g)
        call GroupEnumUnitsInRange(g, GetWidgetX(t), GetWidgetY(t), Range, b)
        exitwhen ok
        call TriggerSleepAction(3.0)
    endloop
    call DestructableRestoreLife(t, GetDestructableMaxLife(t), true)
    set t = null
endfunction
private function Register takes nothing returns nothing
    call TriggerRegisterDeathEvent(bj_destInRegionDiesTrig, GetEnumDestructable())
endfunction
private function Init takes nothing returns nothing
    set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), &#039;nmpe&#039;, 0, 0, 0) // Mur&#039;gul Slave...
    call SetUnitInvulnerable(u, true)
    call ShowUnit(u, false)
    call UnitAddAbility(u, &#039;Aloc&#039;) // Locust
    call UnitAddAbility(u, &#039;Ahrl&#039;) // Harvest Lumber
    set bj_destInRegionDiesTrig = CreateTrigger()
    call EnumDestructablesInRect(bj_mapInitialPlayableArea, Condition(function IsTree), function Register)
    call TriggerAddAction(bj_destInRegionDiesTrig, function Regrow)
    set b = Condition(function IsUnitNear)
    call RemoveUnit(u)
    set u = null
endfunction
endlibrary


That's the library, again...
 

elpini0

New Member
Reaction score
1
I forgot to add that the "Enable Jasshelper" text has a tick next to it... Maybe that means it is enabled...
 

Komaqtion

You can change this now in User CP.
Reaction score
469
As I said, you need to remove this:
JASS:
private function W2D takes widget w returns destructable
    return w // do not inline
    return null
endfunction


And could you then also comment the lines which have an error in them ? :O
 

elpini0

New Member
Reaction score
1
I downloaded the map Damage.w3x whcih contains the libraries Damage, AIDS and Event. I tested the map without toching anything. It doesnt work, for which I guess my NewGen WE is badly installed, or my JassHelper out of date...

[EDIT]
I think JassHelper is not working... I click on "show previous errors" and it gives the message "JassHelper didn't find any syntax error the last time it was called". Maybe it has never been called
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top