Ask a simple question, get a simple answer
Re: Ask a simple question, get a simple answer
How do I change the emmision color of a model component. Does the asset pack have an example of this ?
And has any nod used a sort of gem socket areay or similar thing .... perhaps a numeric display?
And has any nod used a sort of gem socket areay or similar thing .... perhaps a numeric display?
Re: Ask a simple question, get a simple answer
How do I change the emmision color of a model component. Does the asset pack have an example of this ?
And has any nod used a sort of gem socket areay or similar thing .... perhaps a numeric display?
And has any nod used a sort of gem socket areay or similar thing .... perhaps a numeric display?
Re: Ask a simple question, get a simple answer
It's actually called emissiveColor; I always seem to forget that.
(Red, Green, Blue)

Code: Select all
snake_statue_1.model:setEmissiveColor(vec(.2,.4,.6))

Re: Ask a simple question, get a simple answer
Thanks Isaac. This helped alot. I think I will try this out on my models
Re: Ask a simple question, get a simple answer
I'm trying to add folders of the G1 asset pack into my mod.
Cozy, Desk and extra statues worked fine.
Now when I add the temple folder or something small like the extra lanterns folder, I'm running into an error when trying to load my dungeon in the dungeon editor.
What am I doing wrong?
https://ibb.co/jETUKy
https://ibb.co/jzSgzy
Cozy, Desk and extra statues worked fine.
Now when I add the temple folder or something small like the extra lanterns folder, I'm running into an error when trying to load my dungeon in the dungeon editor.
What am I doing wrong?
https://ibb.co/jETUKy
https://ibb.co/jzSgzy
Re: Ask a simple question, get a simple answer
Do not manually import G1MP files other than g1.lua. g1.lua automatically imports the needed files for the selected tilesets (and other assets). Look at the sample init.lua included in G1MP to see how to select which things to import.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Ask a simple question, get a simple answer
Works like a charm. Thank you!
I'm trying to change the G1 experience tome.
The original tome gives 1 full level
I want to change it into a fixed amount of 5000 experience
This is what I made of it, but doesn't seem to work
And this is the original code of the book
I'm trying to change the G1 experience tome.
The original tome gives 1 full level
I want to change it into a fixed amount of 5000 experience
This is what I made of it, but doesn't seem to work
Code: Select all
defineObject{
name = "g1_tome_experience",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/tome.fbx",
material = "g1_book2",
},
{
class = "Item",
uiName = "Memoirs of the Ages",
description = "The fallen are not truly dead until they are forgotten.",
gameEffect = "Gain 5000 experience",
gfxAtlas = "mod_assets/g1/items/icons.tga",
gfxIndex = 28,
weight = 1,
traits = { "tome" },
},
{
class = "UsableItem",
-- no sound, the level up sound will play when the user levels up anyway
onUseItem = function(self, champion)
hudPrint(champion:getName().." feels more experienced.")
local l = champion:getExp(5000)
end,
},
},
}
Code: Select all
defineObject{
name = "g1_tome_experience",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/tome.fbx",
material = "g1_book2",
},
{
class = "Item",
uiName = "Memoirs of the Ages",
description = "The fallen are not truly dead until they are forgotten.",
gameEffect = "Gain 1 experience level",
gfxAtlas = "mod_assets/g1/items/icons.tga",
gfxIndex = 28,
weight = 1,
traits = { "tome" },
},
{
class = "UsableItem",
-- no sound, the level up sound will play when the user levels up anyway
onUseItem = function(self, champion)
hudPrint(champion:getName().." feels more experienced.")
local xpReqs = {0,1000,3000,6000,10000,15000,21000,28000,36000,45000,55000,75000,100000,150000,200000,250000,300000,400000,500000}
local l = champion:getLevel()
local req = (xpReqs[l+1] or 1000000*(l-#xpReqs+1)) -- xp required for next level
local req2 = (xpReqs[l+2] or 1000000*(l-#xpReqs+2)) -- xp required for next next level
local lastReq = (xpReqs[l] or 1000000*(l-#xpReqs)) -- xp required for current level
local progress = (champion:getExp()-lastReq)/(req-lastReq) -- progress between current and next level
-- set the champion to the same proportion towards the next level that they were towards the level they gained by using the tome
-- for example, if the champion had 95000/100000 experience (4/5ths of the way between level 12 and level 13) they will have
-- 140000/150000 experience (4/5ths of the way between level 13 and level 14) experience after using the tome.
-- In other words, your yellow experience progress bar will be in the same place before and after the level change.
-- This makes it so that level changes are not breakpoints; the tome is equally effective regardless of your current exp.
-- also, effectively force exp rate to 100% because applying it to this would be dumb
local rate = champion:getCurrentStat("exp_rate")/100
-- the math.ceil is needed, otherwise non 100 exp_rate can cause you to fail to gain a full level if you are at the minimum
-- experience for your level (e.g. level 1 character may only get 999 xp without the math.ceil call)
-- It would be better to temporarily change the exp_rate to 100 so we don't have that particular jank (it can cause exp values
-- to be 1 too high) but unfortunately doing that with Champion:modifyBaseStat() or Champion:setBaseStat() etc. doesn't seem
-- to work; I think that the value of exp_rate that is actually applied is calculated before this item hook is called and
-- not recalculated until later.
-- But really, the maximum possible error is 1 xp in a game where the first level up requires 1000 xp, so don't worry about it.
champion:gainExp(math.ceil((req-champion:getExp()+progress*(req2-req))/rate))
return true
end,
},
},
}
Re: Ask a simple question, get a simple answer
The 'return true' at the bottom, is significant.
Also, the line:
should be:
Also, the line:
Code: Select all
local l = champion:getExp(5000)
Code: Select all
champion:gainExp(5000)
Re: Ask a simple question, get a simple answer
Thank you! 
Works perfect now!

Works perfect now!
Re: Ask a simple question, get a simple answer
I want to make a coinslot that accepts more than one coin. And everytime a coin is inserted it should increment a counter i have the coinslot connected too. What am I doing wrong here (used a dm coinslot)
... I can insert more coins, but the counter only increments once.
defineObject{
name = "dm_lock_coinslot_reusable",
baseObject = "lock",
components = {
{
class = "Model",
model = "mod_assets/kelly/models/locks/dm_coinslot.fbx",
offset = vec(0, 1.74, 0),
staticShadow = true,
},
{
class = "Clickable",
offset = vec(0, 1.74, 0),
size = vec(0.4, 0.4, 0.4),
onClick = function(self)
if self.go.lock:isEnabled() and getMouseItem() and getMouseItem().go.name == self.go.lock:getOpenedBy() then
GameMode.dm_tempLockItem = getMouseItem()
end
end,
},
{
class = "Lock",
sound = "key_lock",
openedBy = "dm_coin_gold",
onActivate = function(self)
local item = GameMode.dm_tempLockItem
if item:getStackSize() > 1 then
item:setStackSize(item:getStackSize()-1)
setMouseItem(item)
end
GameMode.dm_tempLockItem = nil
self:enable()
self.go.coinsNeeded:decrement()
end,
},
{
class = "Counter",
name = "coinsNeeded",
value = 1,
onActivate = function(self)
end,
},
},
tags = {"dm","dm_user"},
}
... I can insert more coins, but the counter only increments once.
defineObject{
name = "dm_lock_coinslot_reusable",
baseObject = "lock",
components = {
{
class = "Model",
model = "mod_assets/kelly/models/locks/dm_coinslot.fbx",
offset = vec(0, 1.74, 0),
staticShadow = true,
},
{
class = "Clickable",
offset = vec(0, 1.74, 0),
size = vec(0.4, 0.4, 0.4),
onClick = function(self)
if self.go.lock:isEnabled() and getMouseItem() and getMouseItem().go.name == self.go.lock:getOpenedBy() then
GameMode.dm_tempLockItem = getMouseItem()
end
end,
},
{
class = "Lock",
sound = "key_lock",
openedBy = "dm_coin_gold",
onActivate = function(self)
local item = GameMode.dm_tempLockItem
if item:getStackSize() > 1 then
item:setStackSize(item:getStackSize()-1)
setMouseItem(item)
end
GameMode.dm_tempLockItem = nil
self:enable()
self.go.coinsNeeded:decrement()
end,
},
{
class = "Counter",
name = "coinsNeeded",
value = 1,
onActivate = function(self)
end,
},
},
tags = {"dm","dm_user"},
}