Jump to content

Get value from another lua entity


macklebee
 Share

Recommended Posts

I am setting a key/value in object's script file. I have a sbx that has this object loaded into it. Looking at the sbx file in notepad, my custom key/value is being written to the sbx. I have the map loaded into sandbox and I am using the fpscontroller.lua file to scan the current world entites for this key, but yet it never finds it. Does this not work because its in the editor and I would need to actually load the sbx in my own lua file to run separately from the editor? Or is this a limitation of a multistate lua system versus a single state?

 

pick=CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,2.0),0,0)
if pick~=nil then
	for entity in iterate(CurrentWorld().entities) do
		if GetEntityKey(entity,"myvalue","")=="1" then
			if entity==pick.entity then
				if EntityDistance(camera, pick.entity)<3 then
					myotherkey = 1

				else
					myotherkey = 0
				end
			end
		end
	end
end

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Use

 

for model in iterate(fw.main.world.entities) do
	if(model:GetKey("Name") == name) then
		return model
	end
end

 

You don't know what CurrentWorld() is returning because there can be multiple worlds.

 

yes i have already tried this as well as performing GetGlobalObject for the main_world and setting the world to fw.main.world etc... still no response at all...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

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...