• 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.

My own Script

Status
Not open for further replies.
Level 9
Joined
Sep 28, 2004
Messages
365
I can't find any tutorial for this. I would like to know if i want to create a custom script. Can it call functions?

Example of what i did. But it gives errors
JASS:
function ConeBool takes unit caster, unit victim, real radius returns boolean
	if (Cos(( GetUnitFacing(caster) - AngleBetweenPoints(GetUnitLoc(caster), GetUnitLoc(victim) )) > Cos( radius / 2.00 )) then
		return true
        endif

	return false
endfunction

I don't know what is wrong, anyone can help me? I am new to this and wanted to try out something new.
I want it so that i can use:
  • custom script: set udg_inConeRadius = ConeBool(castingunit, pickedunit, 180)
Just an example.

Thanks for helping!
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
castingunit and pickedunit aren't the correct codes...

Casting Unit = GetSpellAbilityUnit()
Picked Unit = GetEnumUnit()

Edit: okay, if the castingunit and pickedunit are variables (local variables), then it could be correct. but: in that case you didn't use the correct names in the function.

This is one of my test-functions:

JASS:
function test takes integer I, integer INT returns string
    local string IntT = I2S(I) + I2S(INT)
    return IntT
endfunction

function testing takes nothing returns nothing
    local integer I = 66
    local integer INT = 6
    
    call BJDebugMsg(test(I, INT))
endfunction

It will show "666".
You can easily convert the lower function to GUI, but then it has to be "call BJDebugMsg(test(udg_I, udg_INT))".
 
castingunit and pickedunit aren't the correct codes...

Casting Unit = GetSpellAbilityUnit()
Picked Unit = GetEnumUnit()

Edit: okay, if the castingunit and pickedunit are variables (local variables), then it could be correct. but: in that case you didn't use the correct names in the function.

Why not? Parameters and the values that're set in the function needn't have the same names, like you may see with your udg example.

The problem is the overuse of brackets.
To bad colors don't work with jass, so I'll show it without:

if (Cos(( GetUnitFacing(caster) - AngleBetweenPoints(GetUnitLoc(caster), GetUnitLoc(victim) )) > Cos( radius / 2.00 )) then

-> erase the first green bracket.
 
Status
Not open for further replies.
Top