• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Codegen info 1.28 patch higher (jassCode)

Status
Not open for further replies.
Level 6
Joined
Jun 28, 2016
Messages
70
Hi evryone, i know i'm a ghost on this community but since you are one of the most active one i often come by to seek your knowledge :)

Today i have a problem, indeed my map does not want to save for 2 line of jass code :

1) function CodeGen_ConvertUnit takes integer id returns integer
2) function CodeGen_ConvertUnit takes integer id returns integer

yes its the same one but for some reason the error is linked to thoses 2 do i need to use another variable for each of them or not : trying to customize the "codegen" system to add a bag to the save able list of unit.
[/SIZE]
The code : (injass)

function CodeGen_SaveToDisk takes string loadcode, string filename returns nothing
call PreloadGenClear()
call PreloadGenStart()
call Preload(loadcode)
call PreloadGenEnd(filename)
call ClearSelection()
endfunction

function CodeGen_Init takes nothing returns nothing
local integer i = 1
local integer b = udg_SaveLoad_Base
local integer m = udg_SaveLoad_MaxValue
loop
exitwhen i >= udg_SaveLoad_MaxValue
set udg_SaveLoad_Char = SubString(udg_SaveLoad_Alphabet, i, i+1)
set i = i + 1
endloop
set udg_SaveLoad_Alphabet = SubString(udg_SaveLoad_Alphabet, 0, 1) + SubString(udg_SaveLoad_Alphabet, m + 1, b)
set udg_SaveLoad_Base = b - m
endfunction

function CodeGen_ConvertUnit takes integer id returns integer
local integer i = 1
loop
exitwhen i > udg_SaveLoad_HeroCount
if (id == udg_SaveLoad_Hero) then
return i
endif
set i = i + 1
endloop
return 0
endfunction


function CodeGen_ConvertUnit takes integer id returns integer
local integer i = 1
loop
exitwhen i > udg_SaveLoad_bagCount
if (id == udg_SaveLoad_bag) then
return i
endif
set i = i + 1
endloop
return 0
endfunction


Once again i'l be gratefull if you could teach me a thing or two in helping me to resolve this mysterious problem :) !

jasserror2.PNG

jasserror1.PNG
 
Last edited:
The error is really simple. You declared a function twice.
To put things into perspective

JASS:
function foo takes nothing returns nothing
endfunction

function foo takes nothing returns nothing
endfunction

As you can see from above, the function foo is declared twice. This will cause an error,
due to functions requiring unique names.
In practice, you wouldn't write two functions that have the same attributes,
because by then, you wouldn't be able to differentiate which one is being used.

Now, with that in mind, do check out your triggers and see if you've copied a trigger
or something. Examine libraries or scopes which have the function ConvertUnit.
Erase the copy and done.

On a side note, to post jass code, you'll need to use the following tags:
[code=jass][/code]
 
Status
Not open for further replies.
Top