Making item into projectile fails assert

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

Making item into projectile fails assert

Post by minmay »

Let's say I have an item that is already on the map and is on the ground (not flying). I want to "throw" the item with a script. Assume e is the item's GameObject.

Code: Select all

local p = e:createComponent("Projectile")
p:setVelocity(8)
p:setFallingVelocity(8)
p:setGravity(4)
This appears to work fine at first, making the item into a projectile, but as soon as it collides with something and the game tries to place it on the ground again, this assert fails:

Code: Select all

[string "Item.lua"]:0: item is not flying
stack traceback:
	[C]: in function 'assert'
	[string "Item.lua"]: in function 'land'
	[string "Item.lua"]: in main chunk
	[string "GameObject.lua"]: in function 'sendMessage'
	[string "Projectile.lua"]: in function 'update'
	[string "Map.lua"]: in function 'updateComponents'
	[string "Map.lua"]: in function 'updateEntities'
	[string "Dungeon.lua"]: in function 'updateLevels'
	[string "GameMode.lua"]: in function 'update'
	[string "DungeonEditor.lua"]: in main chunk
        ...
How can I make the item flying?
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
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Making item into projectile fails assert

Post by petri »

Bug confirmed. Unfortunately I can't think of a workaround for this problem. I've added this to the top of my todo list for the next version.

Thank you for the bug report!
Post Reply

Return to “Mod Creation”