itHyperoX Posted July 7, 2017 Posted July 7, 2017 Error:Line 23 : attemt to index local 'weather' (a nil value) local weatherTable={ { weatherid=0, name="Nagyon meleg"}, { weatherid=1, name="Meleg"}, { weatherid=2, name="Napos, kissé ködös"}, { weatherid=9, name="Ködös"}, } local currentWeatherTable={} function setNewWeather() while (#currentWeatherTable<7) do table.insert(currentWeatherTable,weatherTable[math.random(1,#weatherTable)]) end end function weatherSystemStart() setWeather(1) end addEventHandler("onResourceStart", resourceRoot,setNewWeather) addEventHandler("onResourceStart", resourceRoot,weatherSystemStart) function newWeather() local weather=table.remove(currentWeatherTable,1) outputChatBox("The Weather changes. ("..weather.name..")",root,255,255,255,true) setWeather(weather.weatherid) end setTimer(newWeather,360,0) Whats the problem?
WorthlessCynomys Posted July 7, 2017 Posted July 7, 2017 What is the problem like? Describe it, please.
itHyperoX Posted July 7, 2017 Author Posted July 7, 2017 When changing the weather, randomly get this erro: Error:Line 23 : attemt to index local 'weather' (a nil value) then the timer dead. Need to restart. After some time again error, then need restart..
Moderators IIYAMA Posted July 7, 2017 Moderators Posted July 7, 2017 if #currentWeatherTable == 0 then setNewWeather() end Place between line 21 and 22. (in the current code here) Which will full up the 'currentWeatherTable' table again.
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