Re: Ask a simple question, get a simple answer
Posted: Thu Apr 05, 2018 8:31 pm
Does anyone know why this is happening? Why do I get the black tiles behind my object? .. not from all sides when I walk around it.
Official Legend of Grimrock Forums
http://grimrock.net/forum/
Hey lostsol,lostsol wrote: Here is what I'm working with:Also, I did not mention this in my original post. Focusing on Energy, with a Willpower attribute score of 10, this function works perfectly. Below 10 and the champion actually slowly loses energy. Beyond 10 and regeneration starts happening again, although at a very slow rate, like 1 point every 1-2 minutes. I really, really hope I'm doing something boneheaded here..SpoilerShowCode: Select all
defineTrait{ name = "no_regen", uiName = "", icon = 0, description = "", hidden = true, onRecomputeStats = function(champion, level) if level > 0 then champion:addStatModifier("energy_regeneration_rate", -100) champion:addStatModifier("health_regeneration_rate", -100) end end, }
Code: Select all
onAttack = function(self, champion, slot)
local clip = self.go.firearmattack:getClipSize()
local load = self.go.firearmattack:getLoadedCount()
local count = (self.go.firearmattack:getClipSize() - self.go.firearmattack:getLoadedCount())
local item
local stack
for i=1,ItemSlot.MaxSlots do
item = champion:getItem(i)
if item and item:hasTrait("arc") then
stack = item.go.item:getStackSize()
break
end
end
if stack and stack > count then
self.go.firearmattack:setLoadedCount(clip)
item.go.item:setStackSize(stack - count) elseif
stack and stack <= count then
self.go.firearmattack:setLoadedCount(load + stack)
item.go.item:setStackSize(0)
end
playSound("firearm_jammed")
end,
Code: Select all
function a() -- Function does not have upvalues
local x = "cat"
print(x)
end
y = "dog"
function b() -- Function does not have upvalues
print(y)
end
local z = "goat"
function c() -- Function has an upvalue!
print(z)
end
Code: Select all
defineObject{
name = "candle",
baseObject = "base_item",
components = {
{
class = "Model",
model = "mod_assets/objects/models/candle.fbx",
staticShadow = true,
},
{
class = "Item",
uiName = "Candle",
description ="Candle.",
gfxAtlas = "mod_assets/textures/other_items_atlas/custom_icon_atlas.tga",
gfxIndex = 25,
weight = 3.0,
fitContainer = false,
},
{
class = "TorchItem",
fuel = 1100,
},
{
class = "Light",
range = 3.5,
color = vec(1.1, 0.68, 0.35),
brightness = 7,
castShadow = true,
staticShadows = true,
staticShadowDistance = 0,
shadowMapSize = 256,
fillLight = true,
--offset = vec(0, 0.46, 0),
onUpdate = function(self)
local noise = math.noise(Time.currentTime()*3 + 123) * 0.5 + 0.9
self:setBrightness(noise * 10)
end,
},
{
class = "Particle",
particleSystem = "single_candle",
},
},
}
Ahh I see now, my thinking was way off. I thought that "local stack", and then later "stack = ..." was an upvalue. Anyway, thanks for the explanation and examples.minmay wrote:The code you posted does not contain any functions with upvalues. An upvalue is a local variable that is declared outside of a function that references it.
I would guess that your gfxAtlas and / or gfxIndex is pointing to the wrong place.Mysterious wrote:Hi all
Ok im trying to create and candle that acts like a torch. With the below script I have the candle model thxs (THOM) and the 2d icon. The problem im having is when you pick up the candle it goes invisible there is no candle 2d icon on the mouse. If I place the candle on the handle icon there is no candle icon and the hand picture disappears. I'm not sure what's going wrong please help ty