Page 27 of 76

Re: Need help with lua? - LunaLua General Help

Posted: Sat Jun 18, 2016 8:00 am
by RhysOwens
PixelPest wrote:
RhysOwens wrote:Okay, I've loaded the Level Timer API into my level but the new UI graphics don't appear. I've tried putting those graphics into my level's folder but nothing happened.
Have you actually set the timer using setSecondsLeft() and setTimerState() ?
It has been set, but the graphics still don't appear excluding the numbers, but at least the sounds play.

Re: Need help with lua? - LunaLua General Help

Posted: Sat Jun 18, 2016 8:36 am
by PixelPest
RhysOwens wrote:
PixelPest wrote:
RhysOwens wrote:Okay, I've loaded the Level Timer API into my level but the new UI graphics don't appear. I've tried putting those graphics into my level's folder but nothing happened.
Have you actually set the timer using setSecondsLeft() and setTimerState() ?
It has been set, but the graphics still don't appear excluding the numbers, but at least the sounds play.
I actually have the same issue then. Funny thing is, if the game is paused by talking to an NPC, the icon will show and the counter will disappear (in my case at least)

Re: Need help with lua? - LunaLua General Help

Posted: Sat Jun 18, 2016 8:40 am
by RhysOwens
PixelPest wrote:I actually have the same issue then. Funny thing is, if the game is paused by talking to an NPC, the icon will show and the counter will disappear (in my case at least)
I guess my LunaLua version is too new. Is anybody having the same issue as us?

Re: Need help with lua? - LunaLua General Help

Posted: Sat Jun 18, 2016 11:12 am
by underFlo
Looks like a fault on the API. Wind reported a similar problem on the irc, and the problem seems to be that it uses Graphics.placeSprite instead of Graphics.drawImage. You could probably update it on your end, but the API should hopefully be updated soon.

Re: Need help with lua? - LunaLua General Help

Posted: Sun Jun 26, 2016 9:57 pm
by mariogeek2
Hey, guys, does anybody know how to implement autoscrolling in a level using LunaLua?

Re: Need help with lua? - LunaLua General Help

Posted: Sun Jun 26, 2016 10:01 pm
by PixelPest
mariogeek2 wrote:Hey, guys, does anybody know how to implement autoscrolling in a level using LunaLua?
Create a RECTd object (http://wohlsoft.ru/pgewiki/RECTd_(class)) and then set at as the section boundary (http://wohlsoft.ru/pgewiki/Section_(class)). You can then modify the elements of the RECTd object as often as you wish to change the section boundaries

Re: Need help with lua? - LunaLua General Help

Posted: Sun Jun 26, 2016 10:13 pm
by mariogeek2
PixelPest wrote:
mariogeek2 wrote:Hey, guys, does anybody know how to implement autoscrolling in a level using LunaLua?
Create a RECTd object (http://wohlsoft.ru/pgewiki/RECTd_(class)) and then set at as the section boundary (http://wohlsoft.ru/pgewiki/Section_(class)). You can then modify the elements of the RECTd object as often as you wish to change the section boundaries
Wow! That is incredibly confusing. I was trying to use the SMW Camera method:http://wohlsoft.ru/pgewiki/SMWcamera.lua. I'd gotten it to work, but how can I get the Passive Functionality of Camera Motion to deactive? I tried using deactive() to get it to stop, but now the autoscrolling doesn't work. Here is my code:
Spoiler: show
local SMWCam = loadAPI("SMWcamera")
local t = 0

function onEvent(eventname)
if eventname == "Grab Axe" then
SMWCam.BeginAutoScroll(0,-1)

t = t + 1
end
end

function onLoop()
deactive()
end

Re: Need help with lua? - LunaLua General Help

Posted: Sun Jun 26, 2016 10:26 pm
by PixelPest
mariogeek2 wrote:
PixelPest wrote:
mariogeek2 wrote:Hey, guys, does anybody know how to implement autoscrolling in a level using LunaLua?
Create a RECTd object (http://wohlsoft.ru/pgewiki/RECTd_(class)) and then set at as the section boundary (http://wohlsoft.ru/pgewiki/Section_(class)). You can then modify the elements of the RECTd object as often as you wish to change the section boundaries
Wow! That is incredibly confusing. I was trying to use the SMW Camera method:http://wohlsoft.ru/pgewiki/SMWcamera.lua. I'd gotten it to work, but how can I get the Passive Functionality of Camera Motion to deactive? I tried using deactive() to get it to stop, but now the autoscrolling doesn't work. Here is my code:
Spoiler: show
local SMWCam = loadAPI("SMWcamera")
local t = 0

function onEvent(eventname)
if eventname == "Grab Axe" then
SMWCam.BeginAutoScroll(0,-1)

t = t + 1
end
end

function onLoop()
deactive()
end
If you look at the documentation for this API, you're never actually incorporating t into the beginAutoScroll function, as is done in the wiki example. You also need to do SMWcam.deactivate() and should also be using API.load since loadAPI is deprecated

Re: Need help with lua? - LunaLua General Help

Posted: Sun Jun 26, 2016 10:34 pm
by mariogeek2
PixelPest wrote:If you look at the documentation for this API, you're never actually incorporating t into the beginAutoScroll function, as is done in the wiki example. You also need to do SMWcam.deactivate() and should also be using API.load since loadAPI is deprecated
Allrighty, I wrote my new code using your recommendations:
Spoiler: show
local SMWCam = API.load("SMWcamera")

function onEvent(eventname)
if eventname == "Grab Axe" then
SMWCam.BeginAutoScroll(0,-1)
end
end

function onLoop()
SMWCam.deactive()
end
It still doesn't activate the autoscrolling when I activate the "Grab Axe" event.

Will I have to have SMWCam deactivated until I reach the portion that needs autoscrolling, and then activate it using SMWCam.activate()?

Re: Need help with lua? - LunaLua General Help

Posted: Sun Jun 26, 2016 10:37 pm
by PixelPest
mariogeek2 wrote:
PixelPest wrote:If you look at the documentation for this API, you're never actually incorporating t into the beginAutoScroll function, as is done in the wiki example. You also need to do SMWcam.deactivate() and should also be using API.load since loadAPI is deprecated
Allrighty, I wrote my new code using your recommendations:
Spoiler: show
local SMWCam = API.load("SMWcamera")

function onEvent(eventname)
if eventname == "Grab Axe" then
SMWCam.BeginAutoScroll(0,-1)
end
end

function onLoop()
SMWCam.deactive()
end
It still doesn't activate the autoscrolling when I activate the "Grab Axe" event.

Will I have to have SMWCam deactivated until I reach the portion that needs autoscrolling, and then activate it using SMWCam.activate()?
Why did you remove the counter? That's actually what makes it autoscroll. READ THE DOCUMENTATION

Re: Need help with lua? - LunaLua General Help

Posted: Sun Jun 26, 2016 10:45 pm
by mariogeek2
PixelPest wrote:
mariogeek2 wrote:
PixelPest wrote:If you look at the documentation for this API, you're never actually incorporating t into the beginAutoScroll function, as is done in the wiki example. You also need to do SMWcam.deactivate() and should also be using API.load since loadAPI is deprecated
Allrighty, I wrote my new code using your recommendations:
Spoiler: show
local SMWCam = API.load("SMWcamera")

function onEvent(eventname)
if eventname == "Grab Axe" then
SMWCam.BeginAutoScroll(0,-1)
end
end

function onLoop()
SMWCam.deactive()
end
It still doesn't activate the autoscrolling when I activate the "Grab Axe" event.

Will I have to have SMWCam deactivated until I reach the portion that needs autoscrolling, and then activate it using SMWCam.activate()?
Why did you remove the counter? That's actually what makes it autoscroll. READ THE DOCUMENTATION
Whoops. I wrote the new code on how I think it should be done. I added the counter back in:
Spoiler: show
local SMWCam = API.load("SMWcamera")
local t = 0

function onEvent(eventname)
if eventname == "Level - Start" then
SMWCam.function deactive()
end
end

function onEvent(eventname)
if eventname == "Grab Axe" then
SMWCam.function activate()
end
end

function onEvent(eventname)
if eventname == "Active AutoScrolling" then
SMWCam.BeginAutoScroll(0,-1)
end
end
I have the "Grab Axe" event set to activate the "AutoScroll" event 0.1 seconds from now.

Re: Need help with lua? - LunaLua General Help

Posted: Sun Jun 26, 2016 10:50 pm
by PixelPest
mariogeek2 wrote:
PixelPest wrote:
mariogeek2 wrote: Allrighty, I wrote my new code using your recommendations:
Spoiler: show
local SMWCam = API.load("SMWcamera")

function onEvent(eventname)
if eventname == "Grab Axe" then
SMWCam.BeginAutoScroll(0,-1)
end
end

function onLoop()
SMWCam.deactive()
end
It still doesn't activate the autoscrolling when I activate the "Grab Axe" event.

Will I have to have SMWCam deactivated until I reach the portion that needs autoscrolling, and then activate it using SMWCam.activate()?
Why did you remove the counter? That's actually what makes it autoscroll. READ THE DOCUMENTATION
Whoops. I wrote the new code on how I think it should be done. I added the counter back in:
Spoiler: show
local SMWCam = API.load("SMWcamera")
local t = 0

function onEvent(eventname)
if eventname == "Level - Start" then
SMWCam.function deactive()
end
end

function onEvent(eventname)
if eventname == "Grab Axe" then
SMWCam.function activate()
end
end

function onEvent(eventname)
if eventname == "Active AutoScrolling" then
SMWCam.BeginAutoScroll(0,-1)
end
end
I have the "Grab Axe" event set to activate the "AutoScroll" event 0.1 seconds from now.
Why do you have three onEvent functions? Use one and elseif instead. You seem to be just guessing now; this is your worst try yet.
PixelPest wrote:READ THE DOCUMENTATION
And follow the example since no offense, but you obviously have no idea what you're doing and not even the essential knowledge of how Lua works and how to use it

Re: Need help with lua? - LunaLua General Help

Posted: Sun Jun 26, 2016 10:56 pm
by mariogeek2
Why do you have three onEvent functions? Use one and elseif instead. You seem to be just guessing now; this is your worst try yet.
PixelPest wrote:READ THE DOCUMENTATION
And follow the example since no offense, but you obviously have no idea what you're doing and not even the essential knowledge of how Lua works and how to use it
You are perfectly, absolutely, 100% right. I have no idea what I'm doing. I have little experience with LunaLua.

The reason I have three onEvent functions is because loading the SMW cam does wacky things with the camera until I get until the AutoScroll part, but deactivating it apparentally makes autoscroll not work. So I was trying to have it setup to where it's deactivated until I need for it to be AutoScrolling. The first event was to deactivate SMW cam, the second to active it, and the third to set the AutoScroll in motion.

I'm sorry for being such a bother. Just one question, though: what is elseif?

EDIT: I'm going to bed now, so it'll probably 10 hours before I respond.

Re: Need help with lua? - LunaLua General Help

Posted: Sun Jun 26, 2016 11:10 pm
by PixelPest
Mariogeek2 wrote:
There's really no reason almost EVER to use more than one of a function in a script.

"elseif" is used to make further comparisons if the first criterion/criteria made does/do not fit the statement. For example:

Code: Select all

local lemur = "tree hugger";

if lemur == "fish" then
   print("Lol. A lemur isn't a fish");
elseif lemur == "bird" then
   print("No.");
elseif lemur == "tree hugger" then
   print("Sure.");
end
Not a great explanation but you can always do an Internet search

Re: Need help with lua? - LunaLua General Help

Posted: Sun Jun 26, 2016 11:14 pm
by mariogeek2
PixelPest wrote:
Mariogeek2 wrote:
There's really no reason almost EVER to use more than one of a function in a script.

"elseif" is used to make further comparisons if the first criterion/criteria made does/do not fit the statement. For example:

Code: Select all

local lemur = "tree hugger";

if lemur == "fish" then
   print("Lol. A lemur isn't a fish");
elseif lemur == "bird" then
   print("No.");
elseif lemur == "tree hugger" then
   print("Sure.");
end
Not a great explanation but you can always do an Internet search
Ok, great. Thanks. I did not know you could do that.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Jun 27, 2016 1:39 am
by MECHDRAGON777
PixelPest wrote:
mariogeek2 wrote:
PixelPest wrote: Why did you remove the counter? That's actually what makes it autoscroll. READ THE DOCUMENTATION
Whoops. I wrote the new code on how I think it should be done. I added the counter back in:
Spoiler: show
local SMWCam = API.load("SMWcamera")
local t = 0

function onEvent(eventname)
if eventname == "Level - Start" then
SMWCam.function deactive()
end
end

function onEvent(eventname)
if eventname == "Grab Axe" then
SMWCam.function activate()
end
end

function onEvent(eventname)
if eventname == "Active AutoScrolling" then
SMWCam.BeginAutoScroll(0,-1)
end
end
I have the "Grab Axe" event set to activate the "AutoScroll" event 0.1 seconds from now.
Why do you have three onEvent functions? Use one and elseif instead. You seem to be just guessing now; this is your worst try yet.
PixelPest wrote:READ THE DOCUMENTATION
And follow the example since no offense, but you obviously have no idea what you're doing and not even the essential knowledge of how Lua works and how to use it
Based on what I see, should it not be:

Code: Select all

local SMWCam = API.load("SMWcamera")
local t = 0

function onEvent(eventname)
    if eventname == "Level - Start" then
        SMWCam.function deactive()
    end
    if eventname == "Grab Axe" then
        SMWCam.function activate()
    end
    if eventname == "Active AutoScrolling" then
        SMWCam.BeginAutoScroll(0,-1)
    end
end
Or you can do it as:

Code: Select all

local SMWCam = API.load("SMWcamera")
local t = 0

function onEvent(eventname)
    if eventname == "Level - Start" then
        SMWCam.function deactive()
    elseif eventname == "Grab Axe" then
        SMWCam.function activate()
    elseif eventname == "Active AutoScrolling" then
        SMWCam.BeginAutoScroll(0,-1)
    end
end
??? Just trying to help, but I am not sure if the 1st or second is better. I tend to go for the first set-up.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Jun 27, 2016 4:41 am
by Hoeloe
MECHDRAGON777 wrote: ??? Just trying to help, but I am not sure if the 1st or second is better. I tend to go for the first set-up.
Both of those are incorrect. This doesn't make sense:

Code: Select all

 SMWCam.function activate()
Though you are correct that you can't have multiple onEvent functions.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Jun 27, 2016 5:07 am
by Creepermon
Hi. I'm trying to use a lunalua script for the whole episode. I'm curious that if I was using, for example, PixelPest's SMGModder script (since it comes as lunadll.lua in the demo) if it goes in lunaworld.lua or lunadll.lua? If it is in lunaworld.lua, then does it just go at the end of what's already there, or with a paragraph or other formatting between. This is probably a really obvious answer, but I have little to no experience with lua and I don't want to ruin it.
Thanks, and have a good day, night or other time period!

Re: Need help with lua? - LunaLua General Help

Posted: Mon Jun 27, 2016 6:48 am
by PixelPest
Creepermon wrote:Hi. I'm trying to use a lunalua script for the whole episode. I'm curious that if I was using, for example, PixelPest's SMGModder script (since it comes as lunadll.lua in the demo) if it goes in lunaworld.lua or lunadll.lua? If it is in lunaworld.lua, then does it just go at the end of what's already there, or with a paragraph or other formatting between. This is probably a really obvious answer, but I have little to no experience with lua and I don't want to ruin it.
Thanks, and have a good day, night or other time period!
It goes into lunaworld.lua. You don't want to have more than one of each main event (onTick, onEvent, etc.) so you would put the could you already have at the end (or beginning) of the code already used, in their respective events. For example, part of the code from my demo level is:

Code: Select all

local smgModder = API.load("smgModder");

function onStart()
    smgModder.daredevilActivate();
end 
If I already had the following code in my lunaworld.lua for example:

Code: Select all

local answer = 42;
local parakeet = "I'm a pretty bird.";

function onStart()
    if answer < 0 then
        parakeet = "I'm an ugly bird.";
    end
end 
To add the other code in:

Code: Select all

local smgModder = API.load("smgModder");
local answer = 42;
local parakeet = "I'm a pretty bird.";

function onStart()
    smgModder.daredevilActivate();
    
    if answer < 0 then
        parakeet = "I'm an ugly bird.";
    end
end 
MECHDRAGON777 wrote:
PixelPest wrote:
mariogeek2 wrote: Whoops. I wrote the new code on how I think it should be done. I added the counter back in:
Spoiler: show
local SMWCam = API.load("SMWcamera")
local t = 0

function onEvent(eventname)
if eventname == "Level - Start" then
SMWCam.function deactive()
end
end

function onEvent(eventname)
if eventname == "Grab Axe" then
SMWCam.function activate()
end
end

function onEvent(eventname)
if eventname == "Active AutoScrolling" then
SMWCam.BeginAutoScroll(0,-1)
end
end
I have the "Grab Axe" event set to activate the "AutoScroll" event 0.1 seconds from now.
Why do you have three onEvent functions? Use one and elseif instead. You seem to be just guessing now; this is your worst try yet.
PixelPest wrote:READ THE DOCUMENTATION
And follow the example since no offense, but you obviously have no idea what you're doing and not even the essential knowledge of how Lua works and how to use it
Based on what I see, should it not be:

Code: Select all

local SMWCam = API.load("SMWcamera")
local t = 0

function onEvent(eventname)
    if eventname == "Level - Start" then
        SMWCam.function deactive()
    end
    if eventname == "Grab Axe" then
        SMWCam.function activate()
    end
    if eventname == "Active AutoScrolling" then
        SMWCam.BeginAutoScroll(0,-1)
    end
end
Or you can do it as:

Code: Select all

local SMWCam = API.load("SMWcamera")
local t = 0

function onEvent(eventname)
    if eventname == "Level - Start" then
        SMWCam.function deactive()
    elseif eventname == "Grab Axe" then
        SMWCam.function activate()
    elseif eventname == "Active AutoScrolling" then
        SMWCam.BeginAutoScroll(0,-1)
    end
end
??? Just trying to help, but I am not sure if the 1st or second is better. I tend to go for the first set-up.
No. None of those are correct. The first set up is much less efficient then the second, however neither will work. You aren't increasing the counter and incorporating it into the function beginAutoScroll, which isn't even spelled correctly since Lua is case sensitive. And also, what in the world is SMWcam.function deactivate() and SMWcam.function activate()? This isn't anywhere close and you appear to be missing even basic knowledge of Lua. Also, read the documentation on SMWcamera.lua on the PGE wiki; it shows you an example of exactly what you're trying to do.

And also, everyone who's using this thread should also first read this so that you're not wasting people's time to correct basic mistakes that are easily preventable: http://lua-users.org/wiki/TutorialDirectory. If you read up to Metamethods you'll be much better off

Re: Need help with lua? - LunaLua General Help

Posted: Mon Jun 27, 2016 7:47 am
by h2643
Creepermon wrote:lunaworld.lua or lunadll.lua?
Here you can see the difference between lunadll.lua and lunaworld.lua: http://wohlsoft.ru/pgewiki/Lua_Files
lunadll.lua only affects the level it's in, lunaworld.lua affects all the levels that are in your game/episode.