YouGroove Posted August 10, 2013 Posted August 10, 2013 I have a script : Hair.lua I create a table of hair models like that : hairModels{} function loadModels() hairModels[0]=Model:Load("hair1.mdl") end In another script Player.lua i put that : import : require "Scripts/Hair.lua" start function : loadModels() UpdatePhysics() if(Hair.hairModels[0]~=nil) then Hair.hairModels[0]:SetPosition(....) end The debugger says attemp to index Fhair is nil value Anyone have some idea on how to use that hair.lua file i import in Player.lua ? Script.Hair ? Quote Stop toying and make games
YouGroove Posted August 10, 2013 Author Posted August 10, 2013 SOLVED. All is fine, just need to simply do in Player.lua : if( hairModels[0]~=nil) then hairModels[0]:SetPosition(....) end Quote Stop toying and make games
Rick Posted August 10, 2013 Posted August 10, 2013 Yeah, files don't give any sort of namespace to your variables. You are making global variables in what you are doing. Make sure you understand that because if you use the same name for any of these for other global variables you will overwrite the original and cause issues. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.