love.filesystem.load() ISSUE

Issue #947 invalid
Eliter Scripts
created an issue

the following code will NOT work. I have a lua FILE the contains a 'State', that I did not want in the main.lua.

--[[
this script was made by 'Eliter Scripts'. This script is owned by 'Eliter'. The author of this code
will NOT be removed. removing the author from this code will be considered piracy, and plagiarism.
acts of plagiarism in the United States of America will be sentenced jail time.
]]--
--[[
reason: not defined yet.
type: Game
version: 1.0ALPHA
State: unable to publish
]]--

function GRequire(ARG1)
    if not type(ARG1)=="string" then
        return error("GRequire() needs a string, got a "..type(ARG1))
    else
        if love.filesystem.isFile(ARG1) or love.filesystem.isDirectory(ARG1) then
        else
            if GRsuggestion then
                return error("GRequire() return an error, due to '"..ARG1.."' not being a directory/file. Found '"..ARG1.."' At: '"..GRsuggestion.."'")
            else
                return error("GRequire() return an error, due to '"..ARG1.."' not being a directory/file.")
            end
        end
    end
end



function love.load()
    GRequire("Menus/SettingsState.lua")
    GRequire("Graphics")
    GRequire("Levels")
    GRequire("Menus")
    GRequire("Music")
    GRequire("Sounds")
    MusicVolume=0.1
    SquarePos=0
    game_start=love.timer.getTime()
    Xscreen,Yscreen = love.window.getDimensions()
    ValidStates={"LoginState", "CreditState", "PlayState","ManipulateState","Settings"}
    CurrentState="LoginState"
    ShadeNum=200
    Last_Seen=love.timer.getTime()
    BackToLoginText="to go back to the home screen, you must mouse wheel click this bar."
    BackToLoginTextPos=7.1*#BackToLoginText+Yscreen
    BackToLoginText2="to go back to the home screen, you must mouse wheel click this bar."
    BackToLoginTextPos2=7.1*#BackToLoginText2+Yscreen
    loading_Image=love.graphics.newImage("Graphics/Loading.jpg")
    imgData_Tobu=love.image.newImageData("Graphics/Tobu_logo.png")
    img_Tobu=love.graphics.newImage("Graphics/Tobu_logo.png")
    imgData_Itro=love.image.newImageData("Graphics/Itro_logo.png")
    img_Itro=love.graphics.newImage("Graphics/Itro_logo.png")
    imgData_Etori=love.image.newImageData("Graphics/Etori_logo.png")
    img_Etori=love.graphics.newImage("Graphics/Etori_logo.png")
    CreditInfo={false,false,false}
    print("BAM BAM DA BAM")
    CreditCurPos=0
    local Xloading, Yloading = loading_Image:getDimensions()
    love.graphics.setBackgroundColor( 255,255,255)
    love.graphics.draw(loading_Image,((Xscreen/2)-(Xloading/2)),((Yscreen/2)-(Yloading/2)))
    JustLoaded=true
    G_NAME="Gopher's Hideout"
    love.window.setTitle(G_NAME.." is loading...")
    Color_BAM=0
    UP=1
    MouseVis=1
    Welcome_Sound = love.audio.newSource("Sounds/Welcome.wav","static")
    QuickGunShot_Sound = love.audio.newSource("Sounds/QuickGunShot.ogg","static")
    HoverBeep_Sound=love.audio.newSource("Sounds/HoverBeep.wav","static")
    FM_Color={128,128,128,100}
    LM_Color={128,128,128,200}
    LM_change={1,1,1}
    FM_change={1,1,1}
    Game_start=love.timer.getTime()
    FPS_Show=false
    FPS_Color=false
    L1=love.filesystem.read("Levels/1/info.txt")
    ChosenDifficulty=1
    ChosenDiffText={
    "Easy",
    "intermediate",
    "Hard",
    "Pro",
    "DANG!",
    "Imposible"
    }
    DiffRate=0
    PlayOptionSize=300
    CreditOptionSize=300
    ManipulateOptionSize=150
    MenuY=16
    SettingsFunction=love.filesystem.load("Menus/Settings.lua")


    love.window.setTitle(G_NAME.." is loading Sound Files (may take a bit)")
    MusicFiles = love.filesystem.getDirectoryItems("Music/")
    Song={}
    PermitMusic=true
    for i=1,#MusicFiles do
        Song[i]=love.audio.newSource("Music/"..MusicFiles[i],"static")
        love.window.setTitle(G_NAME.." is loading song "..MusicFiles[i].."(May take a bit!)")
    end
    SongData={}
    SongLength={}
    SongName={}
    for i=1,#MusicFiles do
        SongData[i]=love.sound.newSoundData("Music/"..MusicFiles[i])
        SongLength[i]=SongData[i]:getDuration()
        SongName[i]=love
    end
    SongPlaying=false
    SongToggle=true


    ConfigSettings=love.filesystem.load("configurations.lua")
    PlayState=love.filesystem.load("Menus/PlayState.lua")
end



function State(StateToChange)
    local TESTY=" "
    if type(StateToChange)==type(TESTY) then
        for i=1,#ValidStates do
            if StateToChange==ValidStates[i] then
            CurrentState=StateToChange
            print("State changed to: "..StateToChange)
            TESTFORFOR=true
            break
            end
        end
        if TESTFORFOR==true then
        TESTFORFOR=false
        else
        return error("custom function 'State()' Arg 1: got '"..StateToChange.."' (invalid state).")
        end
    else
    return error("custom function 'State()' Arg 1: got "..type(StateToChange).." (expected string).")
    end
end



function love.draw()
local CurrentFunction="Draw"
local Current_Time=love.timer.getTime()
love_draw_legal=false
local Cir_Rad=40
    if MouseVis==1 then
    love.graphics.setColor(256,0,0,75)
    love.graphics.line(Xmouse,0,Xmouse,Yscreen)
    love.graphics.setColor(0,0,256,75)
    love.graphics.line(0,Ymouse,Xscreen,Ymouse)
    end
    if CurrentState=="LoginState" then
    love.graphics.setBackgroundColor( 255,255,255)
    love.graphics.setColor(0,255,0,150)
    love.graphics.rectangle("fill",(Xscreen/2)-(PlayOptionSize/2),(Yscreen/MenuY)*2,PlayOptionSize,(Yscreen/MenuY))
    love.graphics.setColor(0,0,0,256)
    love.graphics.print("PLAY!",((Xscreen/2)-(PlayOptionSize/2)+((PlayOptionSize*(7.1*5))/2)),(Yscreen/MenuY)*2.5)
    love.graphics.setColor(255,0,0,150)
    love.graphics.rectangle("fill",(Xscreen/2)-(CreditOptionSize/2),(Yscreen/MenuY)*4,CreditOptionSize,(Yscreen/MenuY)) 
    love.graphics.rectangle("fill",(Xscreen/2)-ManipulateOptionSize,(Yscreen/MenuY)*6,ManipulateOptionSize-2,(Yscreen/MenuY))
        if SongPlaying==true then
        --love.graphics.setColor(0,0,0,100)
        --love.graphics.rectangle("fill",0,Yscreen-30,string.len(MusicFiles[SongCurrPlaying])*7.1,30)
        love.graphics.setColor(0,0,0,256)
        love.graphics.print(MusicFiles[SongCurrPlaying],1,1,1,1,1)
        end
    end
    if CurrentState=="PlayState" then
        love.graphics.setColor(150,150,150,100)
        love.graphics.rectangle("fill",0,Yscreen-(Yscreen/20),Xscreen,(Yscreen/20))
        love.graphics.setColor(256,256,256,200)
        love.graphics.print(BackToLoginText,BackToLoginTextPos,(Yscreen/20)*19.25,0,1,1)
    end
    if CurrentState=="CreditState" then
        love.graphics.draw(img_Tobu,0,0,0,0.5,0.5)
        love.graphics.draw(img_Itro,0,(imgData_Tobu:getHeight()/2)+(Yscreen/40),0,0.5,0.5)
        love.graphics.print("Etori",0,(imgData_Tobu:getHeight()/2)+(imgData_Itro:getHeight()/2)+((Yscreen/40)*2),0,1,1)
        love.graphics.setColor(150,150,150,100)
        love.graphics.rectangle("fill",0,Yscreen-(Yscreen/20),Xscreen,(Yscreen/20))
    end

    if MouseVis==2 then
    love.graphics.setColor(FM_Color)
    love.graphics.circle("fill",Xmouse,Ymouse,Cir_Rad)
    love.graphics.setColor(LM_Color)
    love.graphics.circle("line",Xmouse,Ymouse,Cir_Rad)
    love.graphics.setColor(0,0,0,150)
    love.graphics.line((Xmouse-Cir_Rad),Ymouse,(Xmouse+Cir_Rad),Ymouse)
    love.graphics.line(Xmouse,(Ymouse-Cir_Rad),Xmouse,(Ymouse+Cir_Rad))
    end




    if CurrentState=="PlayState" then
    love.graphics.setColor(255,255,255,200)
    local TextPos = Xscreen-(string.len(ChosenDiffText[ChosenDifficulty])*7.1)
    local RectEnd = string.len(ChosenDiffText[ChosenDifficulty])*7.1
    love.graphics.rectangle("fill",TextPos,0,RectEnd,13)
    love.graphics.setColor(0,0,0,255)
    love.graphics.print(ChosenDiffText[ChosenDifficulty],TextPos,0,0,1,1)
    end
    if FPS_Show==true then
        love.graphics.setColor(0,0,0,255)
    local FPS_Text="FPS: "..love.timer.getFPS().." Delta: "..love.timer.getDelta()
    love.graphics.print(FPS_Text,1,1,0,1,1)
    love.graphics.setColor(255,255,255,100)
    love.graphics.rectangle("fill",0,0,(#(tostring(FPS_Text))*7.1),13)
    end
end



function love.update(dt)
local CurrentFunction="Update"
    Xscreen,Yscreen = love.window.getDimensions()
    if CurrentState=="PlayState" then
    BackToLoginTextPos=BackToLoginTextPos-80*dt
        if BackToLoginTextPos<(-1*(#BackToLoginText*7.1)) then
        BackToLoginTextPos=(7.1*#BackToLoginText)+Yscreen
        end
    end
    if CurrentState=="LoginState" then
    SquarePos=SquarePos+64*dt
        if SquarePos>=((-1)*(Xscreen/40)) then
        SquarePos=0
        end
    end
    if CurrentState=="CreditState" then
    BackToLoginTextPos2=BackToLoginTextPos2-80*dt
        if BackToLoginTextPos2<(-1*(#BackToLoginText2*7.1)) then
        BackToLoginTextPos2=(7.1*#BackToLoginText2)+Yscreen
        end
    end
    if CurrentState=="PlayState" then   
    end
    if CurrentState=="Settings" then
    local FARTFART= SettingsFunction()
    end
    if love.timer.getTime()-Last_Seen>=1 then
    print("1 Second has passed")
    print("Information:")
    print(string.rep("=",20))
        if SongToggle==true and type(SongCurrPlaying)=="number" then
        print("Song: "..MusicFiles[SongCurrPlaying])
        end
    Last_Seen=love.timer.getTime()
        if CurrentState=="CreditState" then
        ShadeNum=ShadeNum+32*dt
            if ShadeNum>=256 then
            ShadeNum=150
            end
        end
        if MouseVis==1 then
            for i=1,3 do
                local chance=math.random(1,2)
                if chance==1 then
                LM_change[i]=1
                elseif chance==2 then
                LM_change[i]=2
                end
            end
            for i=1,3 do
                local chance=math.random(1,2)
                if chance==1 then
                FM_change[i]=1
                elseif chance==2 then
                FM_change[i]=2
                end
            end
        end
    end


    if JustLoaded==true then
    JustLoaded=false
    love.window.setTitle(G_NAME.." By 1K Gaming")
    love.audio.play(Welcome_Sound)
    end
Xmouse, Ymouse = love.mouse.getPosition()
if MouseVis==1 or MouseVis==2 then
love.mouse.setVisible(false)
else
love.mouse.setVisible(true)
end
--print("Update #"..UP..".  TIME: "..dt)
UP=UP+1
    if love.keyboard.isDown("alt") then
        if  love.keyboard.isDown("F4") then
        love.event.quit()
        end
    end
    if SongToggle==true then
    if SongPlaying==false then
    local RanSong=math.random(1,#Song)
    Song[RanSong]:play()
    Song[RanSong]:setVolume(0.1)
    SongCurrPlaying=RanSong
    SongPlaying=true
    end
    Song[SongCurrPlaying]:setVolume(MusicVolume)
    if love.keyboard.isDown("tab") then
        SongPlaying=false
        love.audio.stop(Song[SongCurrPlaying])
    end
    if Song[SongCurrPlaying]:tell("seconds")>=(SongLength[SongCurrPlaying]-0.25) then
    SongPlaying=false
    end
    end
    for i=1,3 do
        if LM_change[i]==1 then
        LM_Color[i]=LM_Color[i]+0.1
        elseif LM_change[i]==2 then
        LM_Color[i]=LM_Color[i]-0.1
        end
        if LM_Color[i]>256 then
        LM_Color[i]=256
        elseif LM_Color[i]<0 then
        LM_Color[i]=0
        end
    end
    for i=1,3 do
        if FM_change[i]==1 then
        LM_Color[i]=LM_Color[i]+0.1
        elseif FM_change[i]==2 then
        FM_Color[i]=LM_Color[i]-0.1
        end
        if FM_Color[i]>256 then
        FM_Color[i]=256
        elseif LM_Color[i]<0 then
        FM_Color[i]=0
        end
    end
end



function love.focus(bool)
end



function love.keypressed( key, unicode )
local CurrentFunction="keypressed"
print("KEY PRE: "..key)
    if key=="f1" then
    MouseVis=MouseVis+1
        if MouseVis>3 then
        MouseVis=1
        end
    end
    if key=="f3" then
    FPS_Show= not FPS_Show
    end
    if CurrentState=="PlayState" then
    if key=="up" then
    ChosenDifficulty=ChosenDifficulty+1
    end
    if key=="down" then
    ChosenDifficulty=ChosenDifficulty-1
    end
    end
    if key=="escape" then
    State("LoginState")
    end
    if key=="pageup" and MusicVolume<1 then
    MusicVolume=MusicVolume+0.1
    end
    if key=="pagedown" and MusicVolume>0.1 then
    MusicVolume=MusicVolume-0.1
    end
end



function love.keyreleased( key, unicode )
local CurrentFunction="keyreleased"
print("KEY REL: "..key)
    if CurrentState=="LoginState" then
    if key=="q" then
    SongToggle=not SongToggle
        if SongToggle==false then
        Song[SongCurrPlaying]:stop()
        SongPlaying=false
        end
    end
    end
    if key=="f8" then
    print("Current State: "..CurrentState)
    end
end



function love.mousepressed( x, y, button )
local CurrentFunction="mousepressed"
    Mouse_Press=button
    if button=="l" or button=="r" then
    love.audio.rewind(QuickGunShot_Sound)
    love.audio.play(QuickGunShot_Sound)
    end
    if CurrentState=="LoginState" then
    if button=="l" or button=="r" then
        if x>=((Xscreen/2)-(PlayOptionSize/2)) and x<=(((Xscreen/2)+PlayOptionSize)) and y>=(Yscreen/MenuY)*2 and y<=((Yscreen/MenuY)*2)+(Yscreen/MenuY) then
        State("PlayState")
        end
        --love.graphics.rectangle("fill",(Xscreen/2)-(CreditOptionSize/2),(Yscreen/MenuY)*4,CreditOptionSize,(Yscreen/MenuY))   
        if x>=((Xscreen/2)-(CreditOptionSize/2)) and x<=((Xscreen/2)+CreditOptionSize) and y>=(Yscreen/MenuY)*4 and y<=((Yscreen/MenuY)*4)+(Yscreen/MenuY) then
        State("CreditState")
        end
        --love.graphics.rectangle("fill",(Xscreen/2)-ManipulateOptionSize,(Yscreen/MenuY)*6,ManipulateOptionSize,(Yscreen/MenuY))
        if x>=((Xscreen/2)-ManipulateOptionSize) and x<=(Xscreen/2)-2 and y>=(Yscreen/MenuY)*6 and y<=((Yscreen/MenuY)*6)+(Yscreen/MenuY) then
        State("Settings")
        end
    end
    end
    if CurrentState=="PlayState" or CurrentState=="CreditState" then
        if button=="m" then
            if y>=(Yscreen-(Yscreen/20)) then
            State("LoginState")
            end
        end
    end
    print("MOUSE PRESSED",button,"X:",x,"Y:",y)
end



function love.mousereleased( x, y, button )
local CurrentFunction="mousereleased"
    Mouse_Release=button
    print("MOUSE RELEASED",button,"X:",x,"Y:",y)
end



function love.quit()
end

Thank you for your time! :D

Comments (2)

  1. Log in to comment