Questions of naming conventions and shorthands in TE4 lua

If you have a module that you'd like comments on or would like to know how to create your very own module, post here

Moderator: Moderator

Post Reply
Message
Author
Psiweapon
Wayist
Posts: 23
Joined: Sat Mar 19, 2016 3:38 pm

Questions of naming conventions and shorthands in TE4 lua

#1 Post by Psiweapon »

When a long time ago I started modding Zap'M into PRIME, there were a LOT of shorthands used in code, it's just natural, but I had nobody to ask, since the original dev had long since lost interest in his game.

Even if this forum isn't terribly active, it seems that there are some people around willing to answer some questions. And there are a lot of single letter words I can't fathom what they mean.

What do all these stand for?

" _M " such as found when defining functions in Player.lua (as per the wiki). My guess is that it stands for whatever class you're defining a method for, so you can latter access it via class:method or self:method. Am I wrong?

" d " and " o " such as found in:

Code: Select all

function _M:playerPickup()
	--if 2 or more objects, display a pickup dialog, otherwise just picks up - according to wiki
		if game.level.map:getObject(self.x, self.y, 2) then	
			local d d = self:showPickupFloor("Pickup", nil, function(o, item)
				self:pickupFloor(item, true)
				self.changed = true
				d:used()
			end)
		else
			self:pickupFloor(1, true)
			self:sortInven()
			self:useEnergy()
			
		self.changed = true
		end
	end
	
" t " such as found in the player init function:

Code: Select all

function _M:init(t, no_default)
	t.display=t.display or '@'
	t.color_r=t.color_r or 230
	t.color_g=t.color_g or 230
	t.color_b=t.color_b or 230

	t.player = true
	t.type = t.type or "humanoid"
	t.subtype = t.subtype or "player"
	t.faction = t.faction or "players"

	t.lite = t.lite or 0

	mod.class.Actor.init(self, t, no_default)
	engine.interface.PlayerHotkeys.init(self, t)

	self.descriptor = {}
end
" tg " , such as found when defining a talent:

Code: Select all

newTalent{
	name = "Acid Spray",
	type = {"role/combat", 1},
	points = 1,
	cooldown = 6,
	power = 2,
	range = 6,
	action = function(self, t)
		local tg = {type="ball", range=self:getTalentRange(t), radius=1, talent=t}
		local x, y = self:getTarget(tg)
		if not x or not y then return nil end
		self:project(tg, x, y, DamageType.ACID, 1 + self:getDex(), {type="acid"})
		return true
	end,
	info = function(self, t)
		return "Zshhhhhhhhh!"
	end,
}

To prove I'm trying to do my homework, I'll tell you that I just looked up what " _ " is used for in lua and apparently it's used when you want to ignore a variable.

Come on, lend me a hand, I'll add a shorthand meaning list to the module howto guides 8)

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Questions of naming conventions and shorthands in TE4 lu

#2 Post by HousePet »

The tg stands for targeter.

I don't think that d, o, or t stands for anything.
Unless it is drop, object and thingy? :lol:
My feedback meter decays into coding. Give me feedback and I make mods.

Psiweapon
Wayist
Posts: 23
Joined: Sat Mar 19, 2016 3:38 pm

Re: Questions of naming conventions and shorthands in TE4 lu

#3 Post by Psiweapon »

Hey, thanks for replying. That's at least one clarified :)

I assume that most of the single-letter words are local variables... but ones that see frequent enough use to make repeating them a chore.

0player
Uruivellas
Posts: 717
Joined: Fri May 24, 2013 4:27 pm

Re: Questions of naming conventions and shorthands in TE4 lu

#4 Post by 0player »

"t" stands for "table". It's just a lua table with some parameters of an actor.
"o" is most definitely an "object", ie an equippable/holdable thing.
"d" in that case stands for "dialog", but it's not common at all.
"_M" is lua convention about current module, and TE4 implements classes using (slightly tweaked) modules.

stinkstink
Spiderkin
Posts: 543
Joined: Sat Feb 11, 2012 1:12 am

Re: Questions of naming conventions and shorthands in TE4 lu

#5 Post by stinkstink »

When used in talent definitions/callbacks/hooks, t is often shorthand for Talent. Likewise, eff is commonly for temporary Effect.

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: Questions of naming conventions and shorthands in TE4 lu

#6 Post by jenx »

'wtf' stands for 'where's that function?'
MADNESS rocks

Psiweapon
Wayist
Posts: 23
Joined: Sat Mar 19, 2016 3:38 pm

Re: Questions of naming conventions and shorthands in TE4 lu

#7 Post by Psiweapon »

jenx wrote:'wtf' stands for 'where's that function?'
And, can you read this? " 7u7 " :lol:

But in all honesty, I did find another 3-letter weird word:

" fct "

And one of the few that is explained either in the reference or the wiki: " s " which usually stands for a drawing surface.

Post Reply