Page 1 of 1

Getting LOG Framework repeatFunction is deprecated messages?

Posted: Mon Oct 21, 2013 2:33 am
by fazzasx
Hi Everyone:)

I installed the LOG Framework by JKos and followed the instructions to the nail. I can get stuff working ok such as timers and talk but I keep seeing the below message whenever a monster spawns or if I open a door?
fw.repeatFunction is deprecated, use timers.repeatCall(interval,count,instant,callback,args) instead
I have not specified repeatfunction anywhere so its really confusing me :? Has anyone else seen this? Can someone advise what I need to do please?

I am running Grimrock 1.3.7 and I installed the latest Framework.

Let me know

Thanks

Re: Getting LOG Framework repeatFunction is deprecated messa

Posted: Tue Oct 22, 2013 1:00 am
by DesperateGames
Hello fazzasx,

I have absolutely no experience with LOG Framework, but I had a quick look at the documentation and the files. I did a "find-in-files" search for "fw.repeatFunction" across the framework files itself, and it seems that the framework is using the depreceated functions itself:

framework\modules\damage_dealing_doors.lua (2 hits)
Line 26: fw.repeatFunction(1,1,{door.id},function(door_id) data.removeEntity(door_id) end)
Line 34: fw.repeatFunction(1,1.5,{door.id},function(door_id) data.removeEntity(door_id) end)

framework\modules\fw_magic.lua (1 hit)
Line 452: fw.repeatFunction(1,v.cooldown,{monster.id},function(monster_id)

This would explain why you are seeing this messages even if you aren't explicitly calling the depreceated function. You can do three things:

1. You could contact JKos and ask whether this is intentional or not. I could imagine that maybe the function was changed but it slipped through / was forgotten that it is used in the framework itself in these places.

2. The parameters for both function seem to be the same, only the order is different:

old: fw.repeatFunction(count,interval,callbackargs,callback,instant)
new: timers.repeatCall(interval,count,instant,callback,args)

So you COULD try to edit the framework files to use the new function in the occurences above. I have questionable feelings about this, as I am not 100% sure whether the parameters are interchangeable without problems or not.

3. You could decomment the print()-statement to get rid of the message. It is in line 195 in framework\modules\fw.lua

I would go for 1.), there is a chance it might be a bug and maybe JKos can fix this for everybody.

Re: Getting LOG Framework repeatFunction is deprecated messa

Posted: Tue Oct 22, 2013 10:02 pm
by JKos
Hi,

It's been a while, but it's nice to see that someone still uses my framework. And DesperateGames is right, I forgot that repeatFunction is used in the framework, here is a fixed version of the damage_dealing_doors script-entity:

Code: Select all

damagePowers = {
		wooden=10,iron=25,ornament=15,
		metal=20,portcullis=15,secret=35
	}
	
function deactivate()
	fw.removeHooks('doors','damage_dealing_doors')
	fw.removeHooks('monsters','damage_dealing_doors')
end
	
function activate()
	fw.addHooks('doors','damage_dealing_doors',
		{
			onClose = function(door)
				if data.get(door,'opening') then
					return true
				end			
				local damagePower = 10 --default for custom doors
				for doorType,damage in pairs(damage_dealing_doors.damagePowers) do
					if string.find(door.name,doorType) then
						damagePower = damage
					end
				end
				data.set(door,'closing',1)
				timers.repeatCall(1,1,false,function(door_id) data.removeEntity(door_id) end,{door.id});
			
				damage_dealing_doors.dealDamage(door,damagePower)
			end,
			onOpen = function(door)
				if data.get(door,'closing') then
					return true
				end
				data.set(door,'opening',1)
				timers.repeatCall(2.5,1,false,function(door_id) data.removeEntity(door_id) end,{door.id});
									
			end
		}
	)

	fw.addHooks('monsters','damage_dealing_doors',
		{
			onMove=function(monst,dir)
				data.set(monst,"dir",dir)
			end,
			onDie = function(monst)
				-- clear dead monsters from data-table
				data.removeEntity(monst)
			end,
			onAttack = function (monst, attack)
				data.set(monst,"dir",monst.facing)
			end,
			onDamage = function(monst)
				 data.unset(monst,"dir")
			end,
		}
	)
end

function dealDamage(door, damagePower)
	-- do some damage to monsters on same tile as the door and moving through it
	local monstersAtDoor = entitiesAt(door.level,door.x,door.y)
	
	for monst in monstersAtDoor do
		if door.facing == data.get(monst,"dir") then
			damageTile(door.level,door.x,door.y,door.facing,5,"physical",damagePower)
		end
	end

	-- do some damage to monsters at other side of the door if it's moving through it	
	
	local monstersAtOtherSideOfDoor =  help.entitiesAtAhead(door)	
	local door_opposite_facing = help.getOppositeFacing(door)
	for monst in monstersAtOtherSideOfDoor do
		if door_opposite_facing == data.get(monst,"dir") then
			damageTile(monst.level,monst.x,monst.y,door_opposite_facing,5,"physical",damagePower)
		end
	end	
end

You can replace the script-entity part (the part inside double square brackets[[...]]) of the damage_dealing_doors.lua file with it. Or you can create a script entity named damage_dealing_doors and copy paste this script in it, so it will be used instead of the script included in framework, this solution allows you to make tweaks on this script if you will. Eg. you might like to adjust the damagePowers table or adjust the time how long the door stays open before it can be closed again by changing the inteval argument of the timers.repeatCall at line 33
For example:

Code: Select all

timers.repeatCall(4,1,false,function(door_id) data.removeEntity(door_id) end,{door.id});
Makes doors stay open for 4 seconds before they can be closed again (to prevent crushing monsters with doors repeatedly)

And I will update this in my framework too soon.

Re: Getting LOG Framework repeatFunction is deprecated messa

Posted: Tue Oct 22, 2013 11:57 pm
by fazzasx
Hi Desperategames and JKos :)

I replaced the script and that seems to have done the trick :)

Thanks for replying to this and yes JKos I would advise updating your framework with this fix.

I am pretty sure lots of people still use it as its very useful ;)

Thanks