error when converting lunadll.lua to link.lua

This is the place for discussion and support for LunaLua and related modifications and libraries.
Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
Shadowblitz16
Fighter Fly
Fighter Fly
Posts: 60
Joined: Tue Aug 09, 2016 1:41 pm

error when converting lunadll.lua to link.lua

Postby Shadowblitz16 » Mon Jun 26, 2017 9:10 pm

does anybody know why I get the following error when I use this script?

Code: Select all


local link      = {}
local colliders = loadSharedAPI("colliders")

-- Flags
local isInitialized = false
local isClanging    = false
local justClanged   = false

-- Hitbox modifiers
local hitX = 0
local hitY = 0
local hitWidth  = 0
local hitHeight = 0

-- Jump modifiers
local jumpHeight   = 6
local bounceHeight = 2

-- Speed modifiers 
local attackSpeed  = 2
local clangSpeed   = 16
local jumpSpeed    = 2
local walkSpeed    = 3
local runSpeed     = 5

-- Health, Magic, and Ammo
local health         = 0
local healthMax      = 4
local magic          = 0
local magicMax       = 4
local arrows         = 0
local arrowsMax      = 20
local bombs          = 0
local bombsMax       = 10

-- Physics
local velocityX = 0
local velocityY = 0
local frictionX = 0.1
local frictionY = 0.1

--Items
items  = {}
spells = {}

-- Sounds
local sfx_swordClang = Audio.SfxOpen("Sounds/AOL_Sword_Clang.ogg")


function math.sign(x)
   if (x < 0) then
     return -1
   elseif (x > 0) then
     return 1
   else
     return 0
   end
end

local function blockFilter(b)
	return not b.isHidden;
end

--Collision functions
local function checkForSwordClank()

	local colliding = false
	if (player:mem(0x106, FIELD_WORD)     == -1) then
		if (player:mem(0x114, FIELD_WORD) ==  8) then
			local box = colliders.Box(player.x - 28, player.y+22, 32, 8)
			colliding = colliders.collideBlock(box, colliders.BLOCK_SOLID, blockFilter)
			
			--box:Debug(true)
		elseif (player:mem(0x114, FIELD_WORD) == 7) then
			local box = colliders.Box(player.x - 28, player.y+16, 32, 8)
			colliding = colliders.collideBlock(box, colliders.BLOCK_SOLID, blockFilter)
			
			--box:Debug(true)
		end
	elseif (player:mem(0x106, FIELD_WORD) ==  1) then
		if (player:mem(0x114, FIELD_WORD) ==  8) then
			local box = colliders.Box(player.x + 20, player.y+22, 32, 8)
			colliding = colliders.collideBlock(box, colliders.BLOCK_SOLID, blockFilter)
			
			--box:Debug(true)
		elseif (player:mem(0x114, FIELD_WORD) == 7) then
			local box = colliders.Box(player.x + 20, player.y+16, 32, 8)
			colliding = colliders.collideBlock(box, colliders.BLOCK_SOLID, blockFilter)
			
			--box:Debug(true)
		end
	end
	
	return colliding
end
local function checkForCeiling()
	local colliding = false
	local box = colliders.Box(player.x + 3, player.y - 32, 20, 32)
	colliding = colliders.collideBlock(box, colliders.BLOCK_SOLID, blockFilter)
	
	return colliding
end
local function checkForFloor()
	local colliding = false
	local box = colliders.Box(player.x, player.y, 20, 32)
	colliding = colliders.collideBlock(box, colliders.BLOCK_SOLID, blockFilter)
	
	return colliding
end

--Events
function link.onTick()

	if (player.character == CHARACTER_LINK) then
		if (isInitialized == false) then
			Defines.jumpheight          = jumpHeight
			Defines.jumpheight_bounce   = bounceHeight
			Defines.player_walkspeed    = walkSpeed
			Defines.player_runspeed     = runSpeed
			Defines.player_link_fairyVineEnabled = false
				
			isInitialized = true
		else
		
			--reset single trigger variables
			justClanged = false
			--player.speedX =  16
			
			--Check if just clanged
			if     ((checkForSwordClank() == true)  and (isClanging == false)) then isClanging = true  justClanged = true
			elseif ((checkForSwordClank() == false) and (isClanging == true))  then isClanging = false 
			end

			--Perform clang logic
			if (justClanged) then
				Audio.SfxPlayCh(-1, sfx_swordClang, 0)
				if (player:mem(0x106, FIELD_WORD)     ==  -1) then
					--Check if on ground and if so set position, else add x speed
					if (player:mem(0x146, FIELD_WORD) ==   2) then player.x = player.x + 16 
					else player.speedX =  1.25 
					end
				elseif (player:mem(0x106, FIELD_WORD) ==   1) then
					--Check if on ground and if so set position, else add x speed
					velocityX = -1.25
				end
			end
			
			--Move player
			player.x = player.x + velocityX;
			player.y = player.y + velocityY;
			
			--If on ground
			if (player:mem(0x146, FIELD_WORD) == 2) then
				-- X Friction
				if   (math.abs(velocityX) > frictionX) then velocityX = velocityX - frictionX*math.sign(velocityX)
				else velocityX = 0
				end

				-- Y Friction
				if   (math.abs(velocityY) > frictionY) then velocityY = velocityY - frictionY*math.sign(velocityY)
				else velocityY = 0
				end
			end
		
			--Limit walk speed
			local test = false
			if ((player:mem(0x146, FIELD_WORD) == 2) and (player.leftKeyPressing or player.rightKeyPressing)) then
				test = true
				if (player.speedX >  walkSpeed) then player.speedX =  walkSpeed end
				if (player.speedX < -walkSpeed) then player.speedX = -walkSpeed end
			end
			
			--Constantly disable fairy
			player:mem(0x0E, FIELD_WORD, 1)
		end
	end
end

return link
error: http://imgur.com/a/qLOnX

User avatar
The0x539
Nipper Plant
Nipper Plant
Posts: 751
Joined: Fri Jan 22, 2016 8:02 pm
Current Project: SMBX2

Re: error when converting lunadll.lua to link.lua

Postby The0x539 » Mon Jun 26, 2017 9:53 pm

Use API.load() rather than loadAPI and loadSharedAPI.

Shadowblitz16
Fighter Fly
Fighter Fly
Posts: 60
Joined: Tue Aug 09, 2016 1:41 pm

Re: error when converting lunadll.lua to link.lua

Postby Shadowblitz16 » Tue Jun 27, 2017 4:29 pm

so this was actually caused by me having a lua script with the same api name laying around in the folders somewhere.
I deleted it and it fixed the problem


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 2 guests