LuaCraft

Minecraft / Forge modding with Lua



Here are some code samples to get everyone started.

High Jump, makes players jump quite high and take no fall damage.
function entityFall(ent, distance)
	if (IsPlayer(ent)) then
		return true
	end
end
hook.Add("entity.fall", "Fall!", entityFall)

function entityJump(ent)
	local jumpVec = Vector(0, 0, 1.5)
	if (IsPlayer(ent)) then
		ent:SetVelocity(jumpVec)
	end
end
hook.Add("entity.jump", "Jump!", entityJump)


Biome name, your position and information about what you look at.
local font = surface.GetDefaultFont()

local matEye = Resource("silkicons:eye.png")
local matMap = Resource("silkicons:map.png")
local matTime = Resource("silkicons:time.png")
local matWorld = Resource("silkicons:world.png")

function _R.World:GetTimeString()
	local worldTime = (self:GetTime() + 8000) % 24000
	local hour = math.floor(worldTime / 1000)
	local minute = math.floor((worldTime % 1000 / 1000) * 60) % 60

	return string.format("%02d:%02d", hour, minute)
end

function extraInfo(time, phase)
	local world = World()
	local me = LocalPlayer()
	local pos = me:GetPos()
	local biome = world:GetBiome(pos)
	
	surface.SetTexture(matWorld)
	surface.DrawTexturedRect(2, 2, 8, 8)
	font:DrawText(biome, 12, 2, true)
	
	surface.SetTexture(matMap)
	surface.DrawTexturedRect(2, 12, 8, 8)
	font:DrawText(string.format("%d, %d", math.floor(pos.x), math.floor(pos.y)), 12, 12, true)

	surface.SetTexture(matTime)
	surface.DrawTexturedRect(2, 22, 8, 8)
	font:DrawText(world:GetTimeString(), 12, 22, true)

	local tr = me:GetEyeTrace()
	if (tr.HitBlock) then
		surface.SetTexture(matEye)
		surface.DrawTexturedRect(2, 32, 8, 8)
		font:DrawText(tr.HitBlock:GetName(), 12, 32, true)
	end
end
hook.Add("render.gameoverlay", "Extra Info", extraInfo)


3D rendering, because everyone loves that!
local vec1 = Vector(-190, 315, 72)
local vec2 = vec1 + Vector(0, 0, 1.2) 

local ang1 = Angle(0, 160, 0)

local lightGrey = Color(200, 200, 200, 255)
local lightBlue = Color(50, 50, 230, 255)

function gameRender(renderTime)
	render.SetDrawColor(lightBlue)
	render.DrawText("LuaCraft!", vec2, ang1, 1.25, true)
	
	render.SetDrawColor(lightGrey)
	render.DrawText("Forge modding with Lua", vec3, ang1, 0.5)
end
hook.Add("render.world", "3D Render", gameRender)


Have fun with this and feel free to post suggestions or whatever else is on your mind.
Happy coding!
Author LuaStoned
Version 1.0, 3.1 years ago
Downloads 670 total
Minecraft 1.7.2
Website luacraft.com

The profit from this advertising space goes directly to the mod developer.

Consider turning off AdBlock on mods.io to support the Minecraft community!

Versions

Minecraft 1.7.2
  • 1.0
    2014-05-08