aboutsummaryrefslogtreecommitdiff
path: root/test/glum_test.lua
blob: 9f538ad09d632057aaaa15b88c06cf711d04b149 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
--local glum = dofile("../src/test.lua")
local glum = dofile("../src/glum.lua")

local f5 = io.open("../src/glum.lua", "r")
local str5 = f5:read("*a")
f5:close()

local str = [[

AddCSLuaFile()

ENT.Type = "point"
ENT.DisableDuplicator = true

--
-- Make this entity always networked
--
function ENT:UpdateTransmitState() return TRANSMIT_ALWAYS end

--
-- Networked / Saved Data
--
function ENT:SetupDataTables()

	self:NetworkVar( "Vector", 0, "TopColor", { KeyName = "topcolor", Edit = { type = "VectorColor", category = "Main", order = 1 } } )
	self:NetworkVar( "Vector", 1, "BottomColor", { KeyName = "bottomcolor", Edit = { type = "VectorColor", category = "Main", title = "Color Bottom", order = 2 } } )
	self:NetworkVar( "Float", 0, "FadeBias", { KeyName = "fadebias", Edit = { type = "Float", category = "Main", min = 0, max = 1, order = 3 } } )

	self:NetworkVar( "Float", 4, "SunSize", { KeyName = "sunsize", Edit = { type = "Float", min = 0, max = 10, category = "Sun" } } )
	self:NetworkVar( "Vector", 2, "SunNormal", { KeyName = "sunnormal" } ) -- No editing this - it's for coders only
	self:NetworkVar( "Vector", 3, "SunColor", { KeyName = "suncolor", Edit = { type = "VectorColor", category = "Sun" } } )

	self:NetworkVar( "Float", 2, "DuskScale", { KeyName = "duskscale", Edit = { type = "Float", min = 0, max = 1, category = "Dusk" } } )
	self:NetworkVar( "Float", 3, "DuskIntensity", { KeyName = "duskintensity", Edit = { type = "Float", min = 0, max = 10, category = "Dusk" } } )
	self:NetworkVar( "Vector", 4, "DuskColor", { KeyName = "duskcolor", Edit = { type = "VectorColor", category = "Dusk" } } )

	self:NetworkVar( "Bool", 0, "DrawStars", { KeyName = "drawstars", Edit = { type = "Boolean", category = "Stars", order = 10 } } )
	self:NetworkVar( "String", 0, "StarTexture", { KeyName = "startexture", Edit = { type = "Texture", group = "Stars", category = "Stars", order = 11 } } )

	self:NetworkVarElement( "Angle", 0, 'p', "StarScale", { KeyName = "starscale", Edit = { type = "Float", min = 0, max = 5, category = "Stars", order = 12 } } )
	self:NetworkVarElement( "Angle", 0, 'y', "StarFade", { KeyName = "starfade", Edit = { type = "Float", min = 0, max = 5, category = "Stars", order = 13 } } )
	self:NetworkVarElement( "Angle", 0, 'r', "StarSpeed", { KeyName = "starspeed", Edit = { type = "Float", min = 0, max = 5, category = "Stars", order = 14 } } )

	self:NetworkVar( "Float", 1, "HDRScale", { KeyName = "hdrscale", Edit = { type = "Float", category = "Main", min = 0, max = 1, order = 4 } } )

	--
	-- Entity defaults
	--
	if ( SERVER ) then

		self:SetTopColor( Vector( 0.2, 0.5, 1.0 ) )
		self:SetBottomColor( Vector( 0.8, 1.0, 1.0 ) )
		self:SetFadeBias( 1 )


		self:SetSunNormal( Vector( 0.4, 0.0, 0.01 ) )
		self:SetSunColor( Vector( 0.2, 0.1, 0.0 ) )
		self:SetSunSize( 2.0 )

		self:SetDuskColor( Vector( 1.0, 0.2, 0.0 ) )
		self:SetDuskScale( 1 )
		self:SetDuskIntensity( 1 )

		self:SetDrawStars( true )
		self:SetStarSpeed( 0.01 )
		self:SetStarScale( 0.5 )
		self:SetStarFade( 1.5 )
		self:SetStarTexture( "skybox/starfield" )

		self:SetHDRScale( 0.66 )

	end

end

function ENT:Initialize()
end

function ENT:KeyValue( key, value )

	if ( self:SetNetworkKeyValue( key, value ) ) then
		return
	end

	-- TODO: sunposmethod
	-- 		0 : "Custom - Use the Sun Normal to position the sun"
	--		1 : "Automatic - Find a env_sun entity and use that"

end

function ENT:Think()

	--
	-- Find an env_sun - if we don't already have one.
	--
	if ( SERVER && self.EnvSun == nil ) then

		-- so this closure only gets called once - even if it fails
		self.EnvSun = false

		local list = ents.FindByClass( "env_sun" )
		if ( #list > 0 ) then
			self.EnvSun = list[1]
		end

	end

	--
	-- If we have a sun - force our sun normal to its value
	--
	if ( SERVER && IsValid( self.EnvSun ) ) then

		local vec = self.EnvSun:GetInternalVariable( "m_vDirection" )

		if ( isvector( vec ) ) then
			self:SetSunNormal( vec )
		end

	end

	--
	-- Become the active sky again if we're not already
	--
	if ( CLIENT && g_SkyPaint != self ) then

		if ( !IsValid( g_SkyPaint ) ) then
			g_SkyPaint = self
		end

	end

end

--
-- To prevent server insanity - only let admins edit the sky.
--
function ENT:CanEditVariables( ply )

	return ply:IsAdmin()

end

]]

local min = glum.minify(str)
--local comp = glum.uglify(min)
print(min)

--[[
local fuzzel = loadstring(f)()
local options = {
    "test",
    "toste",
    "testing",
    "teste",
}
print(fuzzel.ffd("tennor",options))
]]