Jump to content

Lua include file and variables


YouGroove
 Share

Recommended Posts

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 ?

Stop toying and make games

Link to comment
Share on other sites

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.

  • Upvote 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...