What happens when you just use Lua's os?Jasoco wrote: Edit: I can't get this code to work...I get an error saying execute is a nil value. Am I using it wrong?Code: Select all
local os = love._os if os == "OS X" then os.execute("open http://www.love2d.org") elseif os == "Windows" then os.execute("start http://www.love2d.org") elseif os == "Linux" then os.execute("xdg-open http://www.love2d.org") else error("OS not detected as OS X, Windows or Linux!") end
does lua support a run command?
- substitute541
- Party member
- Posts: 484
- Joined: Fri Aug 24, 2012 9:04 am
- Location: Southern Leyte, Visayas, Philippines
- Contact:
Re: does lua support a run command?
Currently designing themes for WordPress.
Sometimes lurks around the forum.
Sometimes lurks around the forum.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: does lua support a run command?
Hey. Guess what. Guess what. I did that stupid thing newbies do where they accidentally overwrite important functions. It works when I type it correctly...substitute541 wrote: What happens when you just use Lua's os?
Code: Select all
function openURL(url)
local os1 = love._os
if os1 == "OS X" then
os.execute("open "..url)
elseif os1 == "Windows" then
os.execute("start "..url)
elseif os1 == "Linux" then
os.execute("xdg-open "..url)
else
error("OS not detected as OS X, Windows or Linux!")
-- Replace error with print or remove completely for released games to prevent accidental termination
end
end
This code should work on all OS'. If it doesn't, let me know what happens.
Who is online
Users browsing this forum: varpeti and 6 guests