| 01-17-2004, 05:20 PM | #1 |
Ive coded a function on the main "tree", if you will (aka when you select your maps name at the top), and am trying to call it now. I know that function doesnt have any errors, so it must be how I call it. Heres what I do: Code:
local unit CallUnit = GroupPickRandomUnit(GetUnitsSelectedAll(Player(0))) local string Value = SubStringBJ(GetEventPlayerChatString(), 5, 10) call setValues (CallUnit, "string", value) and my function's first line: Code:
function setValues takes unit CustVal, string ValueType, string Value returns nothing What could be my problem? Also, how would I go about getting a return value from a function (a different one, not this one. This one isnt supposed to return anything)? Thanks for helping a poor lonly JASS n00b like me emote_confused :( |
| 01-17-2004, 05:26 PM | #2 |
JASS is case sensitive. local string Value = SubStringBJ(GetEventPlayerChatString(), 5, 10) call setValues (CallUnit, "string", value) It needs to be call setValues (CallUnit, "string", Value) To return something in a function declare the type in the header of the function like: function foo takes nothing returns integer and then use the return statement somewhere in your function. return 0 will end the function and return 0. So it can be used like this in another function: set x = foo() |
| 01-17-2004, 06:03 PM | #3 |
The odd thing is I knew JASS was case sensitive and checked that call about 100 times, and I missed it ://// . Nevermind about the second part, i reread it and I think i get what your saying :D I tried what you said for the return, and I have another problem :////. The first line of function (different one): Code:
function getValues takes unit value, string ValueType returns string My call part: Code:
local unit Value= GetTriggerUnit () local string Type= "string" call getValues (Value, Type) // Above this works fine, but how do I get the returned string? // Ive tried: local string Result = getValues() // and local string Result = getValues(Value, Type) // But niether works SOrry for being such a n00b. Im really not used to JASS syntax :( |
| 01-17-2004, 07:57 PM | #4 |
The last line looks like it should work. It is the right syntax to use. |
| 01-18-2004, 01:50 AM | #5 |
Hmm. Well, Im helping out on a trigger based spell, so I made a JASS function to set the XP (I got the values from blizzards site). It works fine in one spell, but doesnt in the other. Heres my function (declared in same area as last): Code:
function GiveXP takes unit Hero, unit killed returns nothing
local integer UnitLevel = GetUnitLevel(killed)
local integer XPgiven
if (UnitLevel == 1 ) then
set XPgiven = 25
endif
if (UnitLevel == 2 ) then
set XPgiven = 40
endif
if (UnitLevel == 3 ) then
set XPgiven = 60
endif
if (UnitLevel == 4 ) then
set XPgiven = 85
endif
if (UnitLevel == 5 ) then
set XPgiven = 115
endif
if (UnitLevel == 6 ) then
set XPgiven = 150
endif
if (UnitLevel == 7 ) then
set XPgiven = 190
endif
if (UnitLevel == 8 ) then
set XPgiven = 235
endif
if (UnitLevel == 9 ) then
set XPgiven = 285
endif
if (UnitLevel == 10) then
set XPgiven = 340
endif
call AddHeroXPSwapped( XPgiven, Hero, true )
endfunctionand my call: Code:
Events: Unit - A unit Begins casting an ability Conditions: (Ability being cast) Equal to [my ability ;)] Actions: Custom script: call GiveXP (GetOrderTargetUnit(), GetOrderTargetUnit()) Why doesnt this work, when this call does: Code:
If ((Owner of unt_Caster[(Custom value of (Dying unit))]) Not equal to (Owner of (Picked unit))) then do (Custom script: call GiveXP (udg_unt_Caster[GetUnitUserData(GetDyingUnit() )], GetEnumUnit() )) else do (Do nothing) Both are copy as text from GUI. The second (working one) is in a massive damage trigger. I know the first (nonworking) does fire, for the unit explodes. Im going to be so damned pissed if I made another idiotic mistake and overlooked it for the 1000th time (ive been checking this for the better part of 1/2 hour) Also, thanks ALOT for helping out. I cannot express my gratitude with words :D . |
