Running a variable through a function and a Question

M

Mythic Fr0st

Guest
First the question part:

Now in php I would use a function like this (give or take a few mistakes)
PHP:
function CT (i)
{
if i < 10
set i = "0"+i
return i
}
how would I do this in jass? i've tried im pretty sure the (i) is in the wrong place (Error is "Expected Takes"
Code:
function CT (i) takes i returns i
if i < 10
set i = "0"+i
endif
endfunction

Also how would a run a variable though a function like

udg_s = CT(s) or something like that, in PHP

I could do s = CT(s) and it would run through the function and take effect, E.G if s was less than 10, it would show 0 and the value of s, any help plz

and can I have multiple functions in one?

function CT takes nothing returns nothing
blah
function RT takes nothing returns nothing
endfunction
endfunction?
 

Luth

Lex Luthor!
Reaction score
41
Its late, but lemme take a crack at it. No promises.

function CT takes integer i returns string
local string s = I2S(i)
if i < 10
set s = "0"+s
endif
return s
endfunction


local integer i = 7
set udg_myvar = CT(i)


You cannot have nested functions.


I think that answers all of your questions. :) GL
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top