Questions of naming conventions and shorthands in TE4 lua
Posted: Tue Mar 22, 2016 7:49 pm
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:
" t " such as found in the player init function:
" tg " , such as found when defining a talent:
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
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
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
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
