Jump to content

havenphillip

Members
  • Content Count

    250
  • Joined

  • Last visited

Community Reputation

50 Excellent

Profile Information

  • Gender
    Male

Recent Profile Visitors

915 profile views
  1. What do you already have? I bet it's as simple as adding a timer to it.
  2. My bad. I did something else and forgot. The terrain works fine. Sorry about that lol. But is there a way to access the imported terrain in script?
  3. Wet and rainy environment. I haven't quite worked out all the kinks but this is pretty good. An improved wet terrain from my last one, an object "wettener" shader and a rain shader. Included a map showing it all together in Wet Environment/Maps. Also the mud material and skybox I used in the map. Create a pivot and attach the wet.lua script. Drag a material to your terrain platform and attach wetterrain.lua script. Put rain.lua in the PostEffects box under the root in the Scene tab. Credits to Shadmar, Ma-Shell, and a few things from Shadertoy somewhere I don't even know. Wet Environment.zip
  4. I have this wettening effect I'm working on but as soon as I create terrain everything vanishes. So I want to know how to tell it not to count the .raw.
  5. Oh, duh. I was telling it to go nil for k,v in pairs (self.modelTable) do for i = 0, self.modelTable[k]:CountSurfaces()-1, 1 do surface = self.modelTable[k]:GetSurface(i) mat = surface:GetMaterial() mat:SetShader(shader) shader:SetVec4("ex_color",self.color) mat:SetColor(self.color) self.modelTable[k] = nil -- derp end end
  6. Ah man now I'm getting "attempt to index nil value" error when I add a crawler to the scene. What's that about? Do I need to do some kind of CountChildren() cycle? for k,v in pairs (self.modelTable) do for i = 0, self.modelTable[k]:CountSurfaces()-1, 1 do surface = self.modelTable[k]:GetSurface(i) <- giving me an error on this line mat = surface:GetMaterial() mat:SetShader(shader) shader:SetVec4("ex_color",self.color) mat:SetColor(self.color) self.modelTable[k] = nil end end
  7. Ah thanks! This seems to be working so far: for k,v in pairs (self.modelTable) do for i = 0, self.modelTable[k]:CountSurfaces()-1, 1 do surface = self.modelTable[k]:GetSurface(i) mat = surface:GetMaterial() mat:SetShader(shader) shader:SetVec4("ex_color",self.color) mat:SetColor(self.color) self.modelTable[k] = nil end end
  8. I keep getting this error. How can I fix this? I'm trying to grab everything in the scene and change the color of it with a bounding box. It works fine so long as I don't put a model in the scene that has a model childed to it. The "generator_withbutton.mdl" is an example. When I put that in the scene I get the error. for k,v in pairs (self.modelTable) do surface = self.modelTable[k]:GetSurface(0) mat = surface:GetMaterial() mat:SetShader(shader) shader:SetVec4("ex_color",self.color) mat:SetColor(self.color) self.modelTable[k] = nil end
  9. Ah ok I see. But now it's blue, even though the color is set to 1,1,1. How do I fix that?: surface = self.entity:GetSurface(0) mat = surface:GetMaterial() mat:SetColor(1,1,1) shader = Shader:Load("Gloss/wet_rock.shader"); mat:SetShader(shader) self.entity:SetMaterial(mat) shader:SetFloat("puddlesize", self.puddleSize) shader:SetFloat("puddlefade", self.puddleFade) shader:SetFloat("intensity" , self.intensity) mat:Release()
  10. Actually I see GetSurface() but I'm getting this funky looking rock which ought to look more like the second picture. Here's my code here so far: function Script:Start() --mat = Material:Load("Gloss/wet_rock.mat") mat = Material:Create() surface = self.entity:GetSurface(0) surface:SetMaterial(material) shader = Shader:Load("Gloss/wet_rock.shader"); mat:SetShader(shader) self.entity:SetMaterial(mat) shader:SetFloat("puddlesize", self.puddleSize) shader:SetFloat("puddlefade", self.puddleFade) shader:SetFloat("intensity" , self.intensity) mat:Release() end
  11. If I drag a material onto a model or brush, how can I then reference that material from a code placed on that object or brush without having to create a material then add a bunch of textures? I just want to reference the material I put on it. Something like a Material:GetCurrent() for the entity?
  12. In the above timer script you have to use "defaultFont = context:GetFont()" at the start of your PostRender() function, then you set the font to the font you want with " context:SetFont(self.font) ", then you "DrawText(...)" and after you have to set it back to the default font with " context:SetFont(defaultFont)." I'm guessing you have other scripts that use the DrawText() function? You have to use "defaultFont = context:GetFont()" and " context:SetFont(defaultFont) " in every script that uses "DrawText(...)". Basic Font script: This shouldn't change your other fonts because you're resetting the font back to the default here: Script.myFont = "" --path "Font" Script.color = Vec4(1,1,1,1) --color "Color" Script.size = 12 function Script:Start() self.myFont= Font:Load(self.myFont,self.size) end function Script:PostRender(context) defaultFont = context:GetFont() --at start of every postrender function context:SetBlendMode(1) context:SetColor(self.color) context:SetFont(self.myFont) -- changed to your font context:DrawText("My Text" ,20,20,100,100) context:SetFont(defaultFont) -- change font back to default at end of every postrender function anywhere "SetFont()" and "DrawText()" are used end
  13. The clock isn't restarting because the script is calling Time:GetCurrent(). When you change maps the application doesn't restart, so it's counting the application running time. So what you need is Time:GetSpeed(). That's probably a better way to do a timer anyway. Script.font = "" -- path "Font" -- use TrueType font file Script.pos = Vec2(0,30) -- Vec2 "Position" Script.size = 15 -- float "Size" Script.color = Vec4(1,1,0,1) -- color "Color" Script.offset = 20 -- int "Offset" -- make larger if numbers get cut off Script.countSpeed = 0.05 -- float "Count Speed" (smaller is slower) Script.time = 0 function Script:Start() self.font = Font:Load(self.font,self.size) if self.font == nil then Debug:Error("Select a font") end end function Script:UpdateWorld() self.counter = Time:GetSpeed() * self.countSpeed self.time = self.time + self.counter end function Script:PostRender(context) defaultFont = context:GetFont() r = self.size + self.offset w = self.pos.x + window:GetWidth()/2 - self.offset h = self.pos.y context:SetBlendMode(1) context:SetColor(self.color) context:SetFont(self.font) context:DrawText(Math:Round(self.time),w,h,r,r,Text.VCenter+Text.Center) context:SetFont(defaultFont) end Not sure what you mean by the font sizes. You want to change the font in the gui?
  14. I would try something like: function Script:UpdateWorld() If window:KeyHit(Key.A) then changemapname=self.mapname end Here's the triggerChangeMap script. --[[ This script will act as a trigger to change the current map. Place this at the end of your map to make the player progress to the next level. ]]-- Script.mapname=""--string "Map Name" function Script:Start() self.enabled=true end function Script:Collision(entity, position, normal, speed) changemapname=self.mapname end function Script:Enable()--in if self.enabled==false then self.enabled=true self:CallOutputs("Enable") end end function Script:Disable()--in if self.enabled then self.enabled=false self:CallOutputs("Disable") end end
×
×
  • Create New...