• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Most simple Jass triggers wont work anymore

Status
Not open for further replies.
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

What's up everyone, I wasn't active in these forums for a long time now. Somehow I got a bit back into the old Wc3 Editor stuff, but I already have problems I can't explain. For example this:

JASS:
function HSelect_Actions takes nothing returns nothing
    call BJDebugMsg(GetUnitName(GetSoldUnit()))
endfunction

function InitTrig_HSelect takes nothing returns nothing
    local integer i = 0
    set gg_trg_HSelect = CreateTrigger()
    
    loop
        exitwhen i == 13
        call TriggerRegisterPlayerUnitEvent(gg_trg_HSelect,Player(i),EVENT_PLAYER_UNIT_SELL,null)
        call BJDebugMsg("Init: " + I2S(i))
        set i = i + 1
    endloop
    call TriggerAddAction(gg_trg_HSelect,function HSelect_Actions)
    call BJDebugMsg("Action was added")
endfunction
A very simple trigger, tho it doesn't work. The name of the sold unit isn't displayed at all. I hope someone can say what's going on here,, because to be honest, I don't see the mistake by now...

Greetings and Peace
- Dr. Boom

Edit:
- I still use the Jass NewGen Pack v5d and I'll refuse to take the newest one (but this shouldn't be the problem)
- Else JassHelper and Wc3 itself are up-to-date.

Edit 2:
- When I recode the same function with GUI, it works without any problems o_O
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I am assuming ("Action was added") message is displaying.

I am also assuming the seller unit belongs to neutral passive, so instead of exitwhen i == 13, you should use exitwhen i == 16.
 
Level 16
Joined
May 1, 2008
Messages
1,605
I am assuming ("Action was added") message is displaying.

I am also assuming the seller unit belongs to neutral passive, so instead of exitwhen i == 13, you should use exitwhen i == 16.


exitwhen i == 16, works so fine!... I thought I tested it tho o_O
Anyway thanks^^


... so the event BJ cuases the error.. mhm mhm
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
A few things (looks like it's solved?).

First, you should state what your code is supposed to do, and then tell us what it's doing instead.

Second, it's not necessary to use the suffixes/prefixes that come when GUI is translated to JASS. They are ugly and bulky.

Third, standard vJASS does not use Trigger Actions (or at least the style I learned). Trigger Conditions are used instead.

Here is a more vJASS like version

JASS:
library PrintSoldUnitName initializer init

globals
endglobals

private function main takes nothing returns boolean
	call BJDebugMsg(GetUnitName(GetSoldUnit()))
	return false
endfunction

private function init takes nothing returns nothing
	local integer i = 0
	local trigger t = CreateTrigger()
	loop
		exitwhen i == 13
		call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SELL, null)
		call BJDebugMsg("Init: " + I2S(i))
		set i = i + 1
	endloop
	call TriggerAddCondition(t, Condition(function main))
	call BJDebugMsg("Condition was added.")
	set t = null
endfunction

endlibrary
 
Level 16
Joined
May 1, 2008
Messages
1,605
Well yes it is solved already. I love vJass coding, but this was just an example trigger, in which case it would be okay to deal with vJass. The original trigger is way too complexe and easier in just Jass (would take me too long time to explain this now)

And about the GUI, I don't use GUI at all, but since I didn't find any error of my jass trigger, I just wanted to see if it works in GUI or not.
Also I thought it's pretty obvious what this trigger should do and I said what doesn't work so..
 
Status
Not open for further replies.
Top