BieHDC Posted June 2, 2013 Posted June 2, 2013 Hello, i want to make a random car map with markers and i have dissallowed vehicles. Now when the vehicle isnt allowed i get a predefined vehicle (id=429), but i want that it will as often math.random, until a allowed vehicle is calculated. Please help me fix Here is code: function generateZufallCarID () vehicleID = math.random(399, 609) if disallowedVehicle[vehicleID] then return 429 else return vehicleID end end
BieHDC Posted June 3, 2013 Author Posted June 3, 2013 I already saw it but i dont kwon where and how to put in
Cadu12 Posted June 3, 2013 Posted June 3, 2013 function generateZufallCarID() vehicleID = math.random(399, 609) while disallowed[vehicleID] do vehicleID = math.random(399, 609) end return vehicleID end
BieHDC Posted June 3, 2013 Author Posted June 3, 2013 Now i get this error: ERROR: BieHDChexagontowers\hexatowers.lua:25: attempt to index global 'disallowed' (a nil value) Here is the disallowed vehicle list: disallowedVehicle = {[430] = true, [435] = true, [450] = true, [591] = true, [606] = true, [607] = true, [610] = true, [611] = true, [584] = true, [608] = true, [592] = true, [577] = true, [472] = true, [473] = true, [493] = true, [595] = true, [484] = true, [430] = true, [453] = true, [452] = true, [446] = true, [454] = true, [539] = true, [538] = true, [537] = true, [590] = true, [569] = true, [570] = true, [449] = true}
BieHDC Posted June 3, 2013 Author Posted June 3, 2013 I may have found the error: I think you written disallowed[vehicleID] but it schould be disallowedVehicle[vehicleID] while disallowedVehicle[vehicleID] do vehicleID = math.random(399, 609)
iPrestege Posted June 3, 2013 Posted June 3, 2013 (edited) Yes it should because the table variable is 'disallowedVehicle' if it works don't say thank you to me it's for Cadu . Edited June 3, 2013 by Guest
Cadu12 Posted June 3, 2013 Posted June 3, 2013 Oh, yes, I forget write "Vehicle" that global. You're welcome.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now