Flexman Posted December 9, 2009 Share Posted December 9, 2009 This LUA code is used with one of the Dexsoft radio tower models. It adds three lights and makes the top one blink at a specified interval and colour. But the view range isn't all that great. I was going to ask for suggestions for setting the Corona view range as I tried Lua: entity:SetViewRange( near, far, recursive ) as per the Wiki but only got an error. However the following worked: EntityViewRange(entity.antennalight[i],800,1000) Here's the full script if interested. dofile("Scripts/base.lua") function InitDialog(grid) base_InitDialog(grid) --custom properties group=grid:AddGroup( "Beacon" ) group:AddProperty( "blinkspeed",PROPERTY_INTEGER,1000,"Blink Speed") group:AddProperty("beaconcolor",PROPERTY_COLOR,"","Beacon Color") group:Expand(1) end function Spawn(model) local entity=base_Spawn(model) entity.antennalight={} entity.blinkspeed = tonumber(model:GetKey("blinkspeed","1000")) entity.beaconcolor = Vec4(1.0,0,0,1) entity.lasttime = AppTime() entity.blinktoggle = 1 for i=0,2 do entity.antennalight[i] = CreateCorona(model) entity.antennalight[i]:Paint(LoadMaterial("abstract::flare1.mat"),1) entity.antennalight[i]:SetParent(model,0) entity.antennalight[i]:SetColor(entity.beaconcolor,0) SetCoronaRadius(entity.antennalight[i],1,1) EntityViewRange(entity.antennalight[i],800,1000) end -- Fixed light positions on our antenna entity.antennalight[0]:SetPosition(Vec3(0,35,0.1),0) entity.antennalight[1]:SetPosition(Vec3(1.5,25.2,0.1),0) entity.antennalight[2]:SetPosition(Vec3(-1.5,25.2,0.1),0) base_SetKey("collisiontype",COLLISION_PROP) --An update function for one instance. Declaring the function as part of the entity table allows us to use "self" for the table function entity:Update() if (AppTime()-self.lasttime>entity.blinkspeed) then self.lasttime = AppTime() self.blinktoggle = -self.blinktoggle if (self.blinktoggle>0) then self.antennalight[0]:Hide() else self.antennalight[0]:Show() end end end end function SetKey(model, key, value) local entity=entitytable[model] if entity==nil then return 1 end if entity.model==nil then return 1 end if key=="blinkspeed" then entity.blinkspeed = tonumber(value) elseif key=="beaconcolor" then entity.beaconcolor=StringToColor(value) entity.beaconcolor.w = 1 entity.antennalight[0]:SetColor(entity.beaconcolor,0) entity.antennalight[1]:SetColor(entity.beaconcolor,0) entity.antennalight[2]:SetColor(entity.beaconcolor,0) end return 1 end --Update function, called during every UpdateWorld() function Update(world) if world==world_main then local model,entity for model,entity in pairs(entitytable) do if model.world==world then entity:Update() end end end end Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
macklebee Posted December 9, 2009 Share Posted December 9, 2009 Thanks for this. I am enjoying playing around with it on various models. Quote 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 More sharing options...
ESP Posted December 9, 2009 Share Posted December 9, 2009 Hi, Did anyone work out how to cut and paste code from the forum? I just get one line no matter where I paste to... Robin Quote Programmer , Intel Quad core, NVIDIA GeForce GT 220, Windows 7 Pro, Galaxy Tab 2 ( 7" and 10"), LE2,LE3,3DWS Link to comment Share on other sites More sharing options...
Marleys Ghost Posted December 9, 2009 Share Posted December 9, 2009 Hi, Did anyone work out how to cut and paste code from the forum? I just get one line no matter where I paste to... Robin I use wordpad. Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
ESP Posted December 9, 2009 Share Posted December 9, 2009 Cheers. A bit tortuous and we loose formatting, but at least I get the code. Robin Quote Programmer , Intel Quad core, NVIDIA GeForce GT 220, Windows 7 Pro, Galaxy Tab 2 ( 7" and 10"), LE2,LE3,3DWS Link to comment Share on other sites More sharing options...
macklebee Posted December 9, 2009 Share Posted December 9, 2009 ? I just select all of the code, right-click copy, then paste it directly into a models script... I don't lose the indents/formats by doing this. Quote 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 More sharing options...
ESP Posted December 10, 2009 Share Posted December 10, 2009 I get... dofile("Scripts/base.lua")function InitDialog(grid) base_InitDialog(grid) --custom properties group=grid:AddGroup( "Beacon" ) group:AddProperty( "blinkspeed",PROPERTY_INTEGER,1000,"Blink Speed") group:AddProperty("beaconcolor",PROPERTY_COLOR,"","Beacon Color") group:Expand(1)endfunction Spawn(model) local entity=base_Spawn(model) entity.antennalight={} entity.blinkspeed = tonumber(model:GetKey("blinkspeed","1000")) entity.beaconcolor = Vec4(1.0,0,0,1) entity.lasttime = AppTime() entity.blinktoggle = 1 for i=0,2 do entity.antennalight[i] = CreateCorona(model) entity.antennalight[i]:Paint(LoadMaterial("abstract::flare1.mat"),1) entity.antennalight[i]:SetParent(model,0) entity.antennalight[i]:SetColor(entity.beaconcolor,0) SetCoronaRadius(entity.antennalight[i],1,1) EntityViewRange(entity.antennalight[i],800,1000) end -- Fixed light positions on our antenna entity.antennalight[0]:SetPosition(Vec3(0,35,0.1),0) entity.antennalight[1]:SetPosition(Vec3(1.5,25.2,0.1),0) entity.antennalight[2]:SetPosition(Vec3(-1.5,25.2,0.1),0) base_SetKey("collisiontype",COLLISION_PROP) --An update function for one instance. Declaring the function as part of the entity table allows us to use "self" for the table function entity:Update() if (AppTime()-self.lasttime>entity.blinkspeed) then self.lasttime = AppTime() self.blinktoggle = -self.blinktoggle if (self.blinktoggle>0) then self.antennalight[0]:Hide() else self.antennalight[0]:Show() end end endendfunction SetKey(model, key, value) local entity=entitytable[model] if entity==nil then return 1 end if entity.model==nil then return 1 end if key=="blinkspeed" then entity.blinkspeed = tonumber(value) elseif key=="beaconcolor" then entity.beaconcolor=StringToColor(value) entity.beaconcolor.w = 1 entity.antennalight[0]:SetColor(entity.beaconcolor,0) entity.antennalight[1]:SetColor(entity.beaconcolor,0) entity.antennalight[2]:SetColor(entity.beaconcolor,0) end return 1end--Update function, called during every UpdateWorld()function Update(world) if world==world_main then local model,entity for model,entity in pairs(entitytable) do if model.world==world then entity:Update() end end endend Robin Quote Programmer , Intel Quad core, NVIDIA GeForce GT 220, Windows 7 Pro, Galaxy Tab 2 ( 7" and 10"), LE2,LE3,3DWS Link to comment Share on other sites More sharing options...
macklebee Posted December 10, 2009 Share Posted December 10, 2009 oh that sucks Quote 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 More sharing options...
Flexman Posted December 10, 2009 Author Share Posted December 10, 2009 Maybe paste it into a different editor? I highly recommend Notepad++ from http://notepad-plus.sourceforge.net/uk/site.htm Small footprint, versatile and free. Never had a problem pasting code. But what I will do, is make the above code available as a download in the...downloads...section. Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
ESP Posted December 10, 2009 Share Posted December 10, 2009 Notepad++ gives me... dofile("Scripts/base.lua")function InitDialog(grid) base_InitDialog(grid) --custom properties group=grid:AddGroup( "Beacon" ) group:AddProperty( "blinkspeed",PROPERTY_INTEGER,1000,"Blink Speed") group:AddProperty("beaconcolor",PROPERTY_COLOR,"","Beacon Color") group:Expand(1)endfunction Spawn(model) local entity=base_Spawn(model) entity.antennalight={} entity.blinkspeed = tonumber(model:GetKey("blinkspeed","1000")) entity.beaconcolor = Vec4(1.0,0,0,1) entity.lasttime = AppTime() entity.blinktoggle = 1 for i=0,2 do entity.antennalight[i] = CreateCorona(model) entity.antennalight[i]:Paint(LoadMaterial("abstract::flare1.mat"),1) entity.antennalight[i]:SetParent(model,0) entity.antennalight[i]:SetColor(entity.beaconcolor,0) SetCoronaRadius(entity.antennalight[i],1,1) EntityViewRange(entity.antennalight[i],800,1000) end -- Fixed light positions on our antenna entity.antennalight[0]:SetPosition(Vec3(0,35,0.1),0) entity.antennalight[1]:SetPosition(Vec3(1.5,25.2,0.1),0) entity.antennalight[2]:SetPosition(Vec3(-1.5,25.2,0.1),0) base_SetKey("collisiontype",COLLISION_PROP) --An update function for one instance. Declaring the function as part of the entity table allows us to use "self" for the table function entity:Update() if (AppTime()-self.lasttime>entity.blinkspeed) then self.lasttime = AppTime() self.blinktoggle = -self.blinktoggle if (self.blinktoggle>0) then self.antennalight[0]:Hide() else self.antennalight[0]:Show() end end endendfunction SetKey(model, key, value) local entity=entitytable[model] if entity==nil then return 1 end if entity.model==nil then return 1 end if key=="blinkspeed" then entity.blinkspeed = tonumber(value) elseif key=="beaconcolor" then entity.beaconcolor=StringToColor(value) entity.beaconcolor.w = 1 entity.antennalight[0]:SetColor(entity.beaconcolor,0) entity.antennalight[1]:SetColor(entity.beaconcolor,0) entity.antennalight[2]:SetColor(entity.beaconcolor,0) end return 1end--Update function, called during every UpdateWorld()function Update(world) if world==world_main then local model,entity for model,entity in pairs(entitytable) do if model.world==world then entity:Update() end end endend Nice looking editor though Robin Quote Programmer , Intel Quad core, NVIDIA GeForce GT 220, Windows 7 Pro, Galaxy Tab 2 ( 7" and 10"), LE2,LE3,3DWS Link to comment Share on other sites More sharing options...
carlb Posted December 10, 2009 Share Posted December 10, 2009 it cut and paste fine from firefox to wordpad and notepad for me with no problem what browser you using Quote Asus ROG STRIX B350-F GAMMING AMD Ryzen 7 1700x 32 gb ddr4 15 TB raid 5 HD Nvidia EVGA 1060GTX Win10 64bit Link to comment Share on other sites More sharing options...
ESP Posted December 10, 2009 Share Posted December 10, 2009 I.E.8 Robin Quote Programmer , Intel Quad core, NVIDIA GeForce GT 220, Windows 7 Pro, Galaxy Tab 2 ( 7" and 10"), LE2,LE3,3DWS Link to comment Share on other sites More sharing options...
carlb Posted December 10, 2009 Share Posted December 10, 2009 yep I.E 8 is the problem lol i would say get firefox or something else Quote Asus ROG STRIX B350-F GAMMING AMD Ryzen 7 1700x 32 gb ddr4 15 TB raid 5 HD Nvidia EVGA 1060GTX Win10 64bit Link to comment Share on other sites More sharing options...
ESP Posted December 10, 2009 Share Posted December 10, 2009 Yeh... Chrome works. All I need now is to be able to sculpt Robin Quote Programmer , Intel Quad core, NVIDIA GeForce GT 220, Windows 7 Pro, Galaxy Tab 2 ( 7" and 10"), LE2,LE3,3DWS Link to comment Share on other sites More sharing options...
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.