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!
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

FloorTriggerComponent automatically looks for a component called "animation" and if it finds one, it will treat it as an AnimationComponent and try to play its "activate" and "deactivate" animations when the FloorTriggerComponent is activated and deactivated. You're getting the error because you don't have a "deactivate" animation defined in the AnimationComponent.
As it is, the easiest fix is to rename the AnimationComponent, like this:

Code: Select all

    defineObject{
       name = "floor_spike_trap_auto",
       baseObject = "base_floor_decoration",
       components = {
          {
             class = "Model",
             model = "assets/models/env/tomb_floor_spiketrap.fbx",
          },
          {
             class = "FloorTrigger",
             onActivate = function(self)
                self.go.biscuits:play("activate")
                self.go.tiledamager:enable()
             end,
          },
          {
             class = "Animation",
             name = "biscuits",
             animations = {
                activate = "assets/animations/env/tomb_floor_spiketrap_hit.fbx",
             },
          },
          {
             class = "TileDamager",
             attackPower = 50,
              damageType = "physical",   -- TODO: change to "pure"
              screenEffect = "damage_screen",
              cameraShake = true,
             sound = "spike_trap",
             floorTrap = true,
             enabled = false,
             onHitObstacle = function(self, obstacle)
                if obstacle.go.name == "beach_thicket_01" then return false end
             end,
             onHitMonster = function(self, monster)
                if monster.go.name == "air_elemental" then return false end
             end,
          },
          {
             class = "Controller",
             onActivate = function(self)
                self.go.biscuits:play("activate")
                self.go.tiledamager:enable()
             end,
          },
       },
       editorIcon = 284,
    }
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.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by bongobeat »

works very well, thanks for your replies


well, biscuit is a funny name, were you eating some biscuits when seeing this?
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

How come onClickItemSlot doesn't always receive a champion?

Code: Select all

------------------------------ On Click Item Slot
			onClickItemSlot = function(self, champion, container, slot, button)
				print("self")
				print(self)
				print("champion")
				print(champion)
				print("container")
				print(container)
				print("slot")
				print(slot)
				print("button")
				print(button)
				--	Prevent item insertion/removal from hands
				if champion then
					if champion:hasCondition("frozen") then
						if slot and (button == 0 or button == 1) then
							return false
						end
					end
				end
			end,
Image

EDIT: Apparently opening the inventory fixes this. Is this just editor related?
EDIT2: It will index only the champion whose inventory was opened last
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

I don't know if this was already answered but I could not find it... Is there a solution to stop spell projectiles from flying through stairs?
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

add a ProjectileColliderComponent to the stairs
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.
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

So, a quick fix in a script entity, run on mod start:

Code: Select all

for level=1,Dungeon.getMaxLevels() do
  for e in Dungeon.getMap(level):allEntities() do
    if e.stairs and not e.projectilecollider then
      e:createComponent("ProjectileCollider"):setOffset(vec(0,0,1.5))
    end
  end 
end
Eburt
Posts: 69
Joined: Thu Feb 05, 2015 5:44 am

Re: Ask a simple question, get a simple answer

Post by Eburt »

I'm having trouble with a custom animation.

I export from Blender to fbx and use GrimFBX to generate the .model and .animation files. I do get a couple messages in GrimFBX, "GrimAnimation: Could not open file for writing." but it doesn't seem to matter - everything still loads into GMT just fine. I assign my materials and can play the animation correctly. I run the saved animation through GrimAnimConverter. Everything seems to work fine until I get it into game, at which point the animated portions of the model are invisible (and playing the animation doesn't seem to do anything). I've checked the bounding box and that is correct.

I also tried exporting the model from Blender to obj and importing into GMT that way. This also works fine and I can get my model to appear in-game. However, the animations don't seem to work - I assume because the .model generated from the obj only has the mesh nodes, not those associated with the bones.

Has anyone run into a similar situation? Any advice/troubleshooting steps would be much appreciated.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Try this exporter instead. The pipeline you are describing isn't really functional - it generates bad model files - and I can't think of a workaround.
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.
Eburt
Posts: 69
Joined: Thu Feb 05, 2015 5:44 am

Re: Ask a simple question, get a simple answer

Post by Eburt »

Thanks for the replay minmay. Unfortunately, I'm not able to get it to export correctly using that script. Can't get the model to open in GMT or Grimrock (obviously meaning I don't know if the animation worked).

I assume this is something wrong with the model itself, since importing a default asset and re-exporting works fine. Is there something that needs to be set up or configured for this to work?
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 »

Eburt wrote:Thanks for the replay minmay. Unfortunately, I'm not able to get it to export correctly using that script. Can't get the model to open in GMT or Grimrock (obviously meaning I don't know if the animation worked).

I assume this is something wrong with the model itself, since importing a default asset and re-exporting works fine. Is there something that needs to be set up or configured for this to work?
That script does work, but depends on Blender 2.71 or 2.72. The recent versions of Blender cause trouble for it. I keep both installed; current, and 2.72
Post Reply