Skip to content

Instantly share code, notes, and snippets.

@x4fx77x4f
x4fx77x4f / screengrab.lua
Last active April 14, 2021 04:16
Utility to easily create pixel perfect captures of StarfallEx chips
-- The below line is the *only* one you need to change.
--@include chopper.txt
-- The following are optional.
local OVERRIDE_WIDTH = false and 320
local OVERRIDE_HEIGHT = false and 240
local OVERRIDE_RT = false and 'out' -- Name of rendertarget to save, or none to save the screen
local OVERRIDE_DELAY = false and 2 -- How many seconds to wait until capturing
local THRESHOLD = quotaMax()*0.9
-- End configuration.
@x4fx77x4f
x4fx77x4f / sm64.lua
Last active April 21, 2021 04:09
Tests relating to loading and displaying the Super Mario 64 logo in StarfallEx
--@name Super Mario 64
--@client
-- assets
local SF_DATAPATH = 'data/sf_filedata/sm64/'
--[[
local its_a_me
bass.loadFile(
datapath..'/sound/samples/sfx_mario_peach/07_mario_its_a_me_mario.aiff',
'noplay',
@x4fx77x4f
x4fx77x4f / a.lua
Last active April 20, 2021 01:53
Helper functions for loading assets asynchronously and/or with 'includedata'
--@includedata chopsrampage/chopper.obj
--@includedata chopsrampage/palette.png
local cacheIdentifier = 'chopsrampage' -- This must equal the prefix on the paths to includedata.
local cacheExtensions = {
txt = true,
dat = true,
json = true,
xml = true,
csv = true,
jpg = true,
@x4fx77x4f
x4fx77x4f / chopper.lua
Last active May 2, 2021 15:39
Helicopter demo for StarfallEx
--@name Helicopter demo
--@client
--@includedata chopsrampage/chopper.obj
--@includedata chopsrampage/palette.png
-- Load a model of a helicopter and display it.
local data = getScripts()
local obj = assert(data['chopsrampage/chopper.obj'], "includedata failed! you need to update starfall!")
local matpath = file.writeTemp('palette.png', data['chopsrampage/palette.png'])
local mat = material.createFromImage('../'..matpath, '')
local threshold = quotaMax()*0.5
@x4fx77x4f
x4fx77x4f / clickjack3.lua
Last active April 9, 2021 22:25
Proof of concept for permission request clickjacking in StarfallEx
--@name 3D Tetris
--@author Sparky
--@client
-- Proof of concept for permission request clickjacking in StarfallEx.
-- Usage: Give the chip an interesting name, put a HUD next to it,
-- hook the HUD up to it, convince people to activate the HUD, laugh.
-- redressing
-- https://github.com/thegrb93/StarfallEx/blob/master/lua/starfall/editor/sfderma.lua
@x4fx77x4f
x4fx77x4f / cl_init.lua
Last active April 10, 2021 20:15
Pixel perfect dithering in StarfallEx in realtime using stencils
--@name Chop's Rampage
--@client
--@include chopsrampage/dither.lua
dofile('chopsrampage/dither.lua')
render.createRenderTarget('display')
local testang = Angle()
local test = holograms.create(Vector(100, 50, -30), testang, 'models/starfall/holograms/box.mdl', Vector(150, 150, 150))
test:setNoDraw(true)
@x4fx77x4f
x4fx77x4f / basic.lua
Created March 27, 2021 23:28
Very basic BASIC lexer in Lua
--@name BASIC
--@server
local code = [[
10 PRINT "Hello, World!"
20 END
]]
local lexer = {}
lexer.data = code
@x4fx77x4f
x4fx77x4f / lol.lua
Last active May 12, 2021 23:28
Scripts relating to my string method PR for StarfallEx
-- https://lua-users.org/wiki/MetatableEvents
local metatable = {
__index = true,
__newindex = true,
--__mode = true,
__call = true,
--__metatable = true,
--__tostring = true,
__len = true, -- Lua 5.2+
__pairs = true, -- Lua 5.2+
@x4fx77x4f
x4fx77x4f / fenvcheck.lua
Last active April 5, 2021 18:55
Script to check for problems with getfenv/setfenv
--@shared
local env = {}
env.getfenv = getfenv
local function func(...)
local fenv = getfenv(...)
return fenv
end
setfenv(func, env)
local labels = {
[_G] = "_G",
@x4fx77x4f
x4fx77x4f / fh_debouncer.lua
Last active September 25, 2021 20:04
KeyPress and KeyRelease debouncer for StarfallEx, to fix the hooks being run multiple times when the key was only hit once
--@name Key debouncer
--@shared
local hook = hook
local hook_add = hook.add
local hook_remove = hook.remove
local hook_run = hook.run
local isFirstTimePredicted = isFirstTimePredicted
local string = string
local string_lower = string.lower
local string_sub = string.sub