Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Entity [371][prop_physics]
- @inputs [Base]:entity
- @persist [HT CT]:table [SpawnStatus CoreStatus]:string [HN CN I SpawnCounter]
- @persist [Base]:entity [ScaleFactor ToggleColMat ToggleShading] Indices
- @persist [DefaultColor DefaultScale]:vector
- if (first() | dupefinished())
- {
- Chip = entity()
- Indices = 1
- ScaleFactor = 1
- ToggleColMat = 1
- ToggleShading = 0
- #- Data structure
- #- HN++, HT[HN, table] = table(Index, Parent, ScaleType (Default 0), Pos, Ang, Scale, Model, Material, Color, Skin, Bodygroup Index, Bodygroup Sub-Index)
- # # # # # # # # # HOLOGRAM DATA START # # # # # # # # #
- I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, 0, 0), ang(-70, -180, 90), vec(0.756, 0.756, 0.8618), "models/mechanics/wheels/wheel_rugged_48.mdl", "sprops/sprops_grid", vec4(255, 255, 255, 255), 0)
- I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, -0.2944, 0), ang(0, 0, 0), vec(1.65, 0.825, 1.65), "models/sprops/geometry/fdisc_18.mdl", "", vec4(255, 255, 255, 255), 0)
- I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, -0.2944, 0), ang(0, 0, 0), vec(1.103, 0.4798, 1.103), "models/sprops/misc/tubes_thin/size_3/t_tube_36x12.mdl", "sprops/sprops_grid", vec4(255, 255, 255, 255), 0)
- I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, -0.2944, 0), ang(0, 0, 0), vec(1.025, 0.4817, 1.025), "models/sprops/misc/tubes_thin/size_3/t_tube_36x12.mdl", "sprops/sprops_grid", vec4(255, 255, 255, 255), 0)
- I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, -0.2944, 0), ang(0, 0, 0), vec(0.975, 0.4875, 0.975), "models/sprops/misc/tubes_thin/size_3/t_tube_36x12.mdl", "sprops/sprops_grid", vec4(255, 255, 255, 255), 0)
- I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, -0.2944, 0), ang(0, 0, 0), vec(1.175, 1.0575, 1.175), "models/sprops/misc/tubes_thin/size_3/t_tube_36x12.mdl", "sprops/sprops_grid", vec4(255, 255, 255, 255), 0)
- I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, -0.2944, 0), ang(0, 0, 0), vec(0.9, 0.486, 0.9), "models/sprops/misc/tubes_thin/size_3/t_tube_36x12.mdl", "sprops/sprops_grid", vec4(255, 255, 255, 255), 0)
- I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, 0.714, 0), ang(0, 0, -90), vec(2.3, 2.3, 0.46), "models/sprops/misc/cones/size_1/cone_12x12.mdl", "", vec4(255, 255, 255, 255), 0)
- CN++, CT[CN,table] = table(I, 1, vec(0, 0, 2.9207), vec(0, 0, -1))
- I++, HN++, HT[HN,table] = table(I, Base, 0, vec(0, 2.1576, 0), ang(0, 0, 0), vec(1.09, 0.9592, 1.09), "models/sprops/geometry/fdisc_12.mdl", "", vec4(255, 255, 255, 255), 0)
- # # # # # # # # # HOLOGRAM DATA END # # # # # # # # #
- #- Create a hologram from data array
- function table:holo() {
- local Index = This[1, number] * Indices
- local Entity = This[2, entity]
- local Parent = This[2, entity]
- local Rescale = (This[6, vector] / (This[3, number] ? 12 : 1)) * ScaleFactor
- holoCreate(Index, Entity:toWorld(This[4, vector] * ScaleFactor), Rescale, Entity:toWorld(This[5, angle]), DefaultColor, This[7, string] ?: "cube")
- holoParent(Index, Parent)
- if (ToggleColMat) {
- holoMaterial(Index, This[8, string])
- holoColor(Index, This[9, vector4])
- holoSkin(Index, This[10, number])
- holoBodygroup(Index, This[11, number], This[12, number])
- }
- if (ToggleShading) { holoDisableShading(Index, 1) }
- }
- #- Clip a hologram from data array
- function table:clip() {
- holoClipEnabled(This[1, number] * Indices, This[2, number], 1)
- holoClip(This[1, number] * Indices, This[2, number], This[3, vector] * ScaleFactor, This[4, vector], 0)
- }
- #- Load the contraption
- function loadContraption() {
- switch (SpawnStatus) {
- case "InitSpawn",
- if (clk("Start")) {
- SpawnStatus = "LoadHolograms"
- }
- Chip:soundPlay("Blip", 0, "@^garrysmod/content_downloaded.wav", 0.212)
- break
- case "LoadHolograms",
- while (perf() & holoCanCreate() & SpawnCounter < HN) {
- SpawnCounter++
- HT[SpawnCounter, table]:holo()
- if (SpawnCounter >= HN) {
- SpawnStatus = CN > 0 ? "LoadClips" : "PrintStatus"
- SpawnCounter = 0
- break
- }
- }
- break
- case "LoadClips",
- while (perf() & SpawnCounter < CN) {
- SpawnCounter++
- CT[SpawnCounter, table]:clip()
- if (SpawnCounter >= CN) {
- SpawnStatus = "PrintStatus"
- SpawnCounter = 0
- break
- }
- }
- break
- case "PrintStatus",
- printColor( vec(222,37,188), "PAC to Holo: ", vec(255,255,255), "Loaded " + HN + " holograms and " + CN + " clips." )
- HT:clear()
- CT:clear()
- CoreStatus = "InitPostSpawn"
- SpawnStatus = ""
- break
- }
- }
- CoreStatus = "InitSpawn"
- SpawnStatus = "InitSpawn"
- DefaultColor = vec(255, 255, 255)
- runOnTick(1)
- timer("Start", 500)
- }
- # Credit to Shadowscion for the initial base hologram spawning code.
- elseif (CoreStatus == "InitSpawn")
- {
- loadContraption()
- }
- elseif (CoreStatus == "InitPostSpawn")
- {
- # This is your "if (first())" section of the code.
- CoreStatus = "RunThisCode"
- }
- elseif (CoreStatus == "RunThisCode")
- {
- # This is your interal ran section of the code.
- runOnTick(0)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement