this is bad because I need to increment his speed the opposite way he is facing when he stabs a wall.
I tried setting the memory values for sliding and slippery but they don't seem to do anything.
does anybody know how to get around it?
this is my code so far..
Code: Select all
local hud = loadSharedAPI("hud")
local colliders = loadSharedAPI("colliders")
--variables
isInitialized = false
--config
local jumpHeight = 6
local bounceHeight = 2
local attackSpeed = 2
local jumpSpeed = 2
local walkSpeed = 2
local runSpeed = 5
--Items
local hasCandle = false
local hasBoomarang = false
local hasBombs = false
local hasBoots = false
local hasBow = false
local hasGloves = false
local hasHookshot = false
local hasRing = false
-- 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
--sounds
local sfx_swordClang = Audio.SfxOpen("Sounds/AOL_Sword_Clang.ogg")
local function blockFilter(b)
return not b.isHidden;
end
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
function 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
if (checkForSwordClank() == true) then
if (Audio.SfxIsPlaying(0) == 0) then
Audio.SfxPlayCh(0, sfx_swordClang, 0)
end
if (player:mem(0x106, FIELD_WORD) == -1) then
if (checkForFloor() == true) then player:mem(0x3C, FIELD_WORD, -1) end
player.speedX = player.speedX + 16
elseif (player:mem(0x106, FIELD_WORD) == 1) then
if (checkForFloor() == true) then player:mem(0x3C, FIELD_WORD, -1) end
player.speedX = player.speedX - 16
end
end
Text.print(player:mem(0x114, FIELD_WORD), 0, 32);
if (player.speedX > walkSpeed) then player.speedX = walkSpeed end
if (player.speedX < -walkSpeed) then player.speedX = -walkSpeed end
--if (player:mem(0x14, FIELD_WORD) > 8) then player:mem(0x14, FIELD_WORD, 0) end
end
end
end