Page 1 of 1

Making Custom Torch?

Posted: Mon Apr 21, 2014 12:21 pm
by Jupelius
I have started to create a mod. I have a little experience of scripting, but i still get confused how the ingame systems are sets.

I have made four custom torches. And they work fine. The problem is the torch holder.
I made a custom torch holder cloning the alcove and that worket, but the torch doesn't light up :(

That could work with my torches, because they are not exactly ment to give much light, more of
a soul binding torch or something like that :) I intendent to use them in puzzles with basic puzzles
and monster puzzles. No not a moster soul binding torches ;) or... hmm... That would be interest
too, to steal the lifespam to torches by hitting enemys :P Light up my torch :D Whoop, whoop... :D

But still what i would want to do, would have a dimmer custom torch with my graphics. I actyally modelled and
have the torches different look in the game already :) So the torces is'nt the proplem at all...

Torch holder doesn't have the "onInsertItem" hook. So here is what i did with the alcove.

Code: Select all

cloneObject{
	name = "sacrament_torch_holder",
	baseObject = "eye_socket_left",
	model = "mod_assets/models/jp_sacrament_torch_holder.fbx",
	anchorPos = vec(0.05, 1.53, -0.25),
	anchorRotation = vec(0, -20, -90),
	targetPos = vec(0.00, 1.53, -0.25),
	targetSize = vec(0.2, 0.4, 0.2),	
	placement = "wall",
	replacesWall = false,
	onInsertItem = function(self, item)
		return item.name == "sacrament_torch_5" and item:setFuel(5) and self:getItemCount() == 0 or 
				item.name == "sacrament_torch_15" and item:setFuel(15) and self:getItemCount() == 0 or
					item.name == "sacrament_torch_30" and item:setFuel(30) and self:getItemCount() == 0
	end,
	editorIcon = 92,
And here is one of my torches...

Code: Select all

cloneObject{
	name = "sacrament_torch_15",
	baseObject = "torch",
	uiName = "Sacrament torch",
	model = "mod_assets/models/JP_item_sacrament_torch_Grimrock.fbx",
	description = "These torches doesn't light up, or emit warmth at all. They are to bind souls from other sides. They need altar to work. This have the mark of ******",
	fuel = 15,
	weight = 5.3,
	}
Anyone know how to make a custom torches which would light up in the torch holder, but would not take a regular torch. And to modify the regular torch holder not to take custom torches?

Re: Making Custom Torch?

Posted: Mon Apr 21, 2014 3:51 pm
by Skuggasveinn
Creating custom torch holder - you got that covered
Creating custom torch - you got that covered

here's what's missing
Create a lightsource.
SpoilerShow

Code: Select all

defineObject{
	name = "custom_torch_light",
	class = "LightSource",
	lightPosition = vec(0.6, 2.3, 0),
	lightRange = 10,
	lightColor = vec(1, 0.5, 0.25),
	brightness = 11,
	castShadow = true,
	particleSystem = "custom_torch_particlesystem",
	placement = "pillar",
	editorIcon = 108,
}
you can point to the exist ones if you don't want the light to be different, also the light source uses a particle system for the flames and the smoke, again you can point to the existing ones or create your own.

Then you need a script that goes through the items in the alcove (your torch holder) and spawns the lightsource when the torch is placed in it, and kills it when you take the torch out. (here is a link to some scripts that go through alcoves)
viewtopic.php?p=31524#p31524

If you need an example of spawning lightsources you can have a look at some "lanters" I made some time ago
http://www.nexusmods.com/grimrock/mods/159/?

Hope that gets you on the right track.

Skuggasveinn.

Re: Making Custom Torch?

Posted: Sun Apr 27, 2014 8:29 pm
by Jupelius
I still could not figure how you could set the light source for active and deactive.
I mean, i cant put lightsource in the level, which would be deactived relatively to torchholder (alcove in this case). I can have a lightsource which would deactive when placing a custom torch :)
I could write a script to deactive all the lightsources in the level, but that would just mess all other things later on... I cleaned a bit my torchholder script, to not have some bugs in it...
So just dont take examples from my previously messy script if you are learning from these forums :P

I also made a script, where you can make a "scroll" text, by putting a scroll in alcove. Still i have to write the alcoves name in the script, and that is a pain in the ass :/ And messy....
SpoilerShow
function leimaustesti()
for item in prison_alcove_signment3:containedItems() do -- Takes items inside named alcove
item:setScrollText("Newest signment: Bring me some food") -- Sets the items a text inside the alcove
end
end
if I make a script like this.
SpoilerShow
function universaalileimain()
for item in entitiesAt(party.level,party.x,party.y) do -- Takes a item inside a partys coordinate
if item.name == "scroll" then -- Asks if the item is scroll
item:setScrollText("Newest signment: Does this work? ") -- Places a text for it only if it is a scroll
end
end
end
Then it works a fine, but if I a have also placed a scroll to floor, it will have the same text, when putting things in alcove :D

So if you can call items by:
findEntity(id)
entitiesAt(level, x, y)
allEntities(level)

So how can i call a certain alcove, by script whitout writing its name directly?
I have tried a different ways to locate a alcove and torchholders and things from code, but i just cant make them work,
unless i just directly name them in the script. And then i constantly need to correct my scripts and that just wont work for me...
Need to play with scripting a bit more, but advices would be nice :)

Maeby i need to replace the "item" for "alcove" in the beginning to work...
Well i will try that some day...
I have scripted to my "Logitech G13 gamekeyboard" with LUA script... So I just need to understand the game mechanics and shit...
I like simple and clean scripts, so im not going to copy complicated scripts, if i dont understand them first :)

Even if i could just make a torchholder spawn a lightsource with unique ID in its own cordinates, i think i could make it work.
But i cant figure to do that eather...

But the lanter mod and script helpet little to understand how the game handles the lighting systems and particles and everything :)

Re: Making Custom Torch?

Posted: Sun Apr 27, 2014 9:36 pm
by Jupelius
I accidentally got the stamping alcove, for scrolls to work somehow.
I mean, it takes all the alcoves from partys coordinate.
SpoilerShow
function Bleimauslaite()

for item in entitiesAt(party.level,party.x,party.y) do -- Seems to include alcoves and all...
if item.name == "prison_alcove" then -- Needet to refer the item right global name (name that is in the "asset browser in the left" in the dungeon editor hud)
for item in item:containedItems() do -- Confuses when i call item inside a item, when the two things are different things in one centence :)
item:setScrollText("Newest signment: A Random Alcove Works!") -- Seems to work, even if you just set the text to all items inside alcove. Meaning torch in the alcove doesnt broke the script in some reason?
end
end
end
end
Also this is what is half the time confusing me...
SpoilerShow
local function scrolls()
defineObject{
name = "scroll",
class = "Item", -- Here is the "Item" word again and it is so WRONG to confuce this when handling items in scripting. "item" is the right refer to global item handling in LUA and that thingy there is just a grimrocks statistic for things...
uiName = "Scroll",
model = "assets/models/items/scroll.fbx",
gfxIndex = 112,
scroll = true,
weight = 0.3,
}
And to be clear, here is the right reference again...
SpoilerShow
defineObject{
name = "prison_alcove", -- In the scripting this is the name i needet to refer!, if i wanted to make custom alcoves, and same name shows in the dungeon editor - asset browser
class = "Alcove",
model = "assets/models/env/prison_wall_alcove.fbx",
replacesWall = true,
anchorPos = vec(0, 0.85, 0.2),
targetPos = vec(0,1.3,0),
targetSize = vec(0.6, 0.5, 0.6),
placement = "wall",
editorIcon = 8,
}
Maeby i can get the torchholders to work in the same style...
Correct me if im in the wrong path here ;)