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

[Evaluated] [Assignment] Week 1

Status
Not open for further replies.
Level 3
Joined
Sep 21, 2005
Messages
33
I have a random question, why do you have to declare integers as 1 or 0 or whatever before you use them in loops, i thought integers defaulted to 0 if you did not declare them but if i use code like:
local integer i
loop
exitwhen i==4
set i = i+1
endloop
anything i put in the loop or after it will not fire unless i declare i as 0 first.
 

Attachments

  • xD.Dune vJASS Student W1.w3m
    21.5 KB · Views: 8
  • xD.Dune Assignment 1.w3m
    16.8 KB · Views: 5
Thank you for your submission.
I will evaluate it as soon as possible.

As for your question, well, it's because integers without values crash Warcraft III.
In GUI, when you create a variable, the editor will automatically generate some JASS code that initializes the value to 0. This way, GUI coders don't have to suffer from such things.

i needs to have a value set.

Only arrays have default, initialized values.
integer arrays default to 0, string arrays default to "", boolean arrays default to false, real arrays default to 0.0, and everything else defaults to null.
 
Code:
Lesson 1

        Good job
        
Lesson 2

        Good job
        
Lesson 3

        Good job
        
Lesson 4

        Good job
        
Lesson 5

        Good job
        
Lesson 6

        Failed
        
            Did not call the custom functions (TheFunction and DisplayMessage)
        
Lesson 6 P2

        Failed
        
            GetAIDifficulty takes a player, not a player number
            You used types for everything else without the names, 
            so it is safe to assume that when you wrote "player number",
            you thought it was a type
        
Lesson 7

        Good job
        
Lesson 8

        Failed
        
            You didn't get the values in the other bases
            2 and 4 are not octal. Octal numbers begin with a 0
        
Lesson 10

        Good job
        
Project 1

        Failed
        
            - Did not name variables correctly
            - They were supposed to be named:
                player0
                player1
                player2
                etc...
                
            - Used things not covered yet. (Variable initialization)
            - Created incorrect unit types
            
        Otherwise, good job. You did the calls correctly and that is what matters the most.

C-
 
Status
Not open for further replies.
Top