Discord
Login
Community
DARK THEME

Random Not Working

Why is this not working? init = function() Safe = 0 notSafe = 1 chance = [Safe,notSafe] decideCoin() end

decideCoin = function(list) choice = random.listItem(list) if choice == chance[0] then // Safe print("safe") else print("not") end end

init = function() 
   Safe = 0 
   notSafe = 1 
   chance = [Safe,notSafe] 
   decideCoin() 
end

decideCoin = function(list) 
   choice = list[random.nextInt(list.length)] 
   if choice == chance[0] then 
     // Safe print("safe") 
   else 
     print("not") 
   end 
end

still not working,

Warning: length is not defined, defaulting to zero, in file "main" at line 9, column 36

Warning: 0 is not defined, defaulting to zero, in file "main" at line 9, column 16

It would show those errors and always show the same thing, I want a way to randomly run either function one or function two

init = function() 
   Safe = 0 
   notSafe = 1 
   chance = [Safe,notSafe] 
   decideCoin(chance) 
end

decideCoin = function(list) 
   choice = list[random.nextInt(list.length)] 
   if choice == chance[0] then 
     // Safe print("safe") 
   else 
     print("not") 
   end 
end

How do you get the code snippet looking thing in the replies? BTW I got something working

also would you be interested? https://microstudio.dev/community/questions/game-jam/1066/

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community