Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
THOM
Posts: 1274
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

You must load it also from another script.

From your list in your post I get the impression, that you are now loading the standard assets partially from a file called "standard_assets" and partially from their own scripts. You should decide which solution you choose and then deactivate the other one completely. This way you can make sure that no double-loadings occur...
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Okay, you lost me there :) I have no idea where the "double load" would come from.
I simply have 1 global init file.

But maybe it's because of vanblam's asset pack I added. I'll go over every single folder and check every custom init file manually.

For shits and giggles and probably some /facepalms from the more experienced people here,
here is my current init file.

Code: Select all

-- This file has been generated by Dungeon Editor 2.2.4

-- import standard assets
import "mod_assets/scripts/standard_assets.lua"
import "assets/scripts/objects/base.lua"
import "assets/scripts/objects/generic.lua"
import "assets/scripts/spells/blob.lua"
import "assets/scripts/monsters/skeleton_knight_trooper.lua"
import "assets/scripts/monsters/uggardian.lua"

-- import custom assets
import "mod_assets/extra_essences/extra_essences.lua"
import "mod_assets/sx_winter_tileset/scripts/sx_winter_tileset_init.lua"
import "mod_assets/sx_urban_town/scripts/sx_urban_town_init.lua"
import "mod_assets/sx_river/sx_water_assets_init.lua"
import "mod_assets/scripts/items.lua"
import "mod_assets/scripts/monsters.lua"
import "mod_assets/scripts/objects.lua"
import "mod_assets/scripts/tiles.lua"
import "mod_assets/scripts/recipes.lua"
import "mod_assets/scripts/spells.lua"
import "mod_assets/scripts/materials.lua"
import "mod_assets/scripts/sounds.lua"
import "mod_assets/ext/grimtk/init.lua"
import "mod_assets/zim_assets/zim_init.lua"
import "mod_assets/dmcsb_pack/scripts/dmcsb_pack_init.lua"
import "mod_assets/vb_scripts/scripts_under_d/init.lua"
import "mod_assets/sx_towntileset/scripts/sx_towntileset_objects.lua"

import "mod_assets/sx_towntileset/scripts/sx_towntileset_materials.lua"

import "mod_assets/sx_towntileset/scripts/sx_towntileset_sounds.lua"

import "mod_assets/sx_towntileset/scripts/sx_tiles.lua"

import "mod_assets/scripts/asia/items.lua"
import "mod_assets/scripts/asia/monsters.lua"
import "mod_assets/scripts/asia/objects/ctomb.lua"
import "mod_assets/scripts/asia/tiles.lua"
import "mod_assets/scripts/asia/recipes.lua"
import "mod_assets/scripts/asia/spells.lua"
import "mod_assets/scripts/asia/materials/ctomb.lua"
import "mod_assets/scripts/asia/sounds.lua"
import "mod_assets/vb_scripts/scripts_util_s1/init.lua"
import "mod_assets/mam/scripts/mam_init.lua"
import "mod_assets/flowers/scripts/flowers.lua"
import "mod_assets/plugins/ghoul/ghoul.lua"

-- stone bridge
import "mod_assets/addons/bridge/bridge.lua"

-- town
import "mod_assets/addons/sx_town/sx_particles.lua"
import "mod_assets/addons/sx_town/sx_town_materials.lua"
import "mod_assets/addons/sx_town/sx_town_objects.lua"
import "mod_assets/addons/sx_town/sx_town_tiles.lua"

-- shipwreck complement to town
import "mod_assets/addons/shipwreck/shipwreck_objects.lua"

-- various objects
import "mod_assets/addons/others/materials.lua" 
import "mod_assets/addons/others/objects.lua"

-- waterfall based on Zimberzimber water flow
import "mod_assets/addons/waterfall/waterfall.lua" 

-- palm trees and animated palm tree
-- by Maneus and Skugasvein
-- big palm tree
import "mod_assets/addons/palm_tree/objects_palms.lua"

-- skuggasvein winter door
import "mod_assets/addons/sx_urban_town/sx_urban_town_objects.lua" 



-- dwarf tileset -- normal texture made by Maneus
-- beam by Minmay
-- modified castle models from LOG2 asset pack
import "mod_assets/addons/dwarf/dwarf_materials.lua" 
import "mod_assets/addons/dwarf/dwarf_objects.lua"
import "mod_assets/addons/dwarf/dwarf_particles.lua"
import "mod_assets/addons/dwarf/dwarf_tiles.lua"

-- outside ship
import "mod_assets/addons/ship/sx_ship_objects.lua"
import "mod_assets/addons/ship/sx_ship_tiles.lua"
G1_TILESETS_USED = {
	dungeon=true,
	deep_dungeon=true,
	northern_dungeon=true,

	temple=true,
	dark_temple=true,
	darkelf_temple=true,
	deep_temple=true,
	frozen_temple=true,
	high_temple=true,
	highelf_temple=true,
	southern_temple=true,}
G1_ELEVATION = true
G1_ENHANCED_FX = true
G1_OLD_ALTARS = true
G1_COZY = true
G1_DESK = true
G1_MERETHIF_TAPESTRIES = true
G1_PLAQUES = true
G1_EXTRA_SECRET_DOORS = true
G1_EXTRA_STATUES = true
G1_EXTRA_LANTERNS = true
G1_FOUNTAINS = true
G1_WINDOWS = true
G1_CATWALKS = true
G1_ORNAMENTAL_PILLAR = true
G1_STANDARD_ITEMS = true
G1_GLOVES = true
G1_BOOKS = true
G1_MINE_WEAPONS = true
G1_ORIENTAL = true
G1_ORRR2_ITEMS = true
G1_SHIELDS = true
G1_KEYS_GEMS = true
G1_TRANSLUCENT_GEMS = true
G1_OGRE = true
G1_SKELETON_WARRIOR = true
G1_TENTACLES = true
G1_WARDEN = true
G1_CULTIST = true
G1_GOROMORG = true
G1_GOROMORG_TURNATTACKS = true
G1_MOLT = true
G1_SCAVENGER = true
G1_SPIDER = true
G1_ICE_LIZARD = true
G1_LAGUARDIAN = true
G1_WATER_BOLT = true
G1_URGARDIAN = true
G1_GHOSTS = true
import "mod_assets/g1/g1.lua"

g1_createWeaponMonster("skeleton_trooper","torch","skeleton_knight_shield","skeleton_torcher")
g1_createWeaponMonster("skeleton_trooper","skullcleave","skeleton_knight_shield","skeleton_axe")
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Okay thanks Thom!

It was indeed vanblams under_d asset pack and util_s1 init files that loaded the standard assets as well in their own init notepad files. As I simply implemented them without having any experience. Problem solved :)

Default log2 ambient tracks are gone now as well as the broken and useless default tomb set.
User avatar
7Soul
Posts: 209
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul »

Is there any simple way to check if the item the champion has in its hand is an item that is supposed to be in the hand slot? (weapons, bows, wands, etc)

I'm checking if it has a meleeattack, missileattack, etc, component just wondering if there's a simpler way I missed
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mods
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Use traits for that. You can see examples in the asset pack weapon definitions.
User avatar
7Soul
Posts: 209
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul »

Isaac wrote: Tue Sep 24, 2019 8:27 pm Use traits for that. You can see examples in the asset pack weapon definitions.

I'm trying to check for any item in the hand that's supposed to go in the hand. This is because I was getting the effects of equipping an item (like a bracer) by just holding it in the hand (and this only happens because of my system of extra effects)

But I just went and made a function for that so it's fine, was just wondering if there was some kind of "item:isInRightSlot()" or whatever
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mods
User avatar
Zo Kath Ra
Posts: 937
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

7Soul wrote: Tue Sep 24, 2019 9:16 pm But I just went and made a function for that so it's fine, was just wondering if there was some kind of "item:isInRightSlot()" or whatever
Can you post the function you wrote?
User avatar
7Soul
Posts: 209
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul »

Zo Kath Ra wrote: Tue Sep 24, 2019 10:23 pm
7Soul wrote: Tue Sep 24, 2019 9:16 pm But I just went and made a function for that so it's fine, was just wondering if there was some kind of "item:isInRightSlot()" or whatever
Can you post the function you wrote?
It's just a check that returns true if a weapon-type item is in the hand, or true if the slot we're checking is not a hand slot

Code: Select all

function isHandItem(item, slot) -- returns true if a held item is in the appropriate slot, so you don't gain a bonus if an armor is in the hand, etc
	if item then
		if slot == ItemSlot.Weapon or slot == ItemSlot.OffHand then
			if item.go.meleeattack or item.go.rangedattack or item.go.throwattack or item.go.firearmattack or item:hasTrait("orb") then
				return true -- item in hand is a weapon, staff, etc
			else
				return false -- item in hand is not a weapon
			end
		else
			if slot ~= ItemSlot.Weapon2 and slot ~= ItemSlot.OffHand2 then -- this check is probably not needed
				return true -- slot isn't a hand slot and not a swapped slot
			end
		end
	end
	return true
end
("orb" trait is a trait I added to wands/staves/orbs)

An example of it in use:

Code: Select all

for slot = ItemSlot.Weapon, ItemSlot.Bracers do
	local item = champion:getItem(slot)
	local isHandItem = isHandItem(item, slot)
	if item and isHandItem then
		
	end	
end
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mods
User avatar
Eleven Warrior
Posts: 745
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

Hi all. This code (below) works when you interact with the npc np but if the player damages the npc this code activates:

md_npc_ratling2_2.monster:addConnector("onDamage",self.go.id,"npcdamage01a") --- Not working ---
but as soon as the program trys to destroy the npc it crashes it use to work before?? Im using the npc script by mahric.

Basically when the player attacks the npc a new npc is spawned in its place and the old one is destroyed but its not working I says the old npc doesn't exsist which it does like wtf?? It spawns the new ratling np. Just wont destroy the old one as fore mentioned.

Code: Select all

function Boat1npcs()
	mdNPC.script:registerNPC("md_npc_ratling2_2")
	md_npc_ratling2_2.monster:addConnector("onDamage",self.go.id,"npcdamage01a") --- Not working. see below function(sender) --
	mdNPC.script:setOnInteract("md_npc_ratling2_2", Npc_Scripts_01.script.onInteract01a) --- This works. ---
end

function npcdamage01a(sender)
spawn("ratling2",md_npc_ratling2_2.level,md_npc_ratling2_2.x,md_npc_ratling2_2.y,md_npc_ratling2_2.facing,md_npc_ratling2_2.elevation,nil)
	delayedCall(self.go.id,0.1,"killnpc01a") --- Is this the problem ---
end

--- Npc destroyed but it say error: no such thing as md_npc_ratling2_2 ---
function killnpc01a()
md_npc_ratling2_2:destroy()
end
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

I cannot easily test this... but you can.

Code: Select all

function killnpc01a()
	if md_npc_ratling2_2 then
		md_npc_ratling2_2:destroy()
	end
end
Is it possible that the md_npc_ratling2_2:destroy() function is called twice?
It IS the case that a monsters removal after calling destroy() is not instantaneous. It remains an object for a minute but significant amount of time afterwards.
Post Reply