Post here for help and support regarding LunaLua and SMBX2's libraries and features.
Moderator: Userbase Moderators
|
|
|
|
-
Bulby_VR
- Fighter Fly

- Posts: 33
- Joined: Wed Aug 07, 2019 11:18 am
Postby Bulby_VR » Sat Aug 17, 2019 11:52 am
Enjl wrote:Player runspeed is capped. Walkspeed isn't.
If Walk speed isn't capped, then could I force the player to use walkspeed?
Also, isn't player.get() static? Wouldn't that mean an error would be brought up if I did this?Code: Select all playerTable = player.get;
playerTable[1].spinJumpKeyPressing = false;
Edit, i tested it and it did nothing, so either it ignores it or sets it properly
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Sat Aug 17, 2019 12:34 pm
Bulby_VR wrote: ↑Sat Aug 17, 2019 11:52 am
If Walk speed isn't capped, then could I force the player to use walkspeed?
walkspeed is used when the run key is not held, while runspeed is used when the run key is held. For solutions, refer to my previous post.
Bulby_VR wrote: ↑Sat Aug 17, 2019 11:52 am
Also, isn't player.get() static? Wouldn't that mean an error would be brought up if I did this?
Have you used NPC.get() before in order to loop over NPCs? It's used like that.
Code: Select all for k,p in ipairs(Player.get()) do
p.altJumpKeyPressing = false
end
Few notes on that code:
- it's altJumpKeyPressing, like seen on this page https://wohlsoft.ru/pgewiki/Player_(class)
- Player.get() is a method static to the player class, yes. This means that while Player.get() exists, player.get() does not.
|
|
|
|
|
|
|
|
|
-
Bulby_VR
- Fighter Fly

- Posts: 33
- Joined: Wed Aug 07, 2019 11:18 am
Postby Bulby_VR » Sat Aug 17, 2019 1:38 pm
Another question is, can we use different plugins like LuaSocket? I want to use a timer without a busy wait but you need something external to do that.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Sat Aug 17, 2019 1:49 pm
Bulby_VR wrote: ↑Sat Aug 17, 2019 1:38 pm
Another question is, can we use different plugins like LuaSocket? I want to use a timer without a busy wait but you need something external to do that.
... what is your goal?
A timer is just a variable you tick up in onTick.
A leveltimer can be implemented using timer.lua, for which there are instructions on the handbook.
What do you mean by "busy wait"?
|
|
|
|
|
|
|
|
|
-
Bulby_VR
- Fighter Fly

- Posts: 33
- Joined: Wed Aug 07, 2019 11:18 am
Postby Bulby_VR » Sun Aug 18, 2019 11:28 am
Enjl wrote:What do you mean by "busy wait"?
By busy wait I mean it stops everything, i.e. freeze the game, which I don't want.
Enjl wrote:A timer is just a variable you tick up in onTick.
How many ticks would be in a second? I don't want to have to use ticks because I'm not very familiar with that.
Added in 36 minutes 56 seconds:
It also looks like I can't use the command line to sleep because that raises an error when I use os.execute().
Added in 30 minutes 35 seconds:
Here is what I want to do:
https://pastebin.com/5AjP98XD
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Sun Aug 18, 2019 2:04 pm
64.12 frames in a second. That's how often onTick runs. 39/2500 seconds per frame, to be precise.
First of all, I recommend using the "keys" fields. Your player here is x so it'd be x.keys:
The below line is true only on the frame on which the alt jump key is pressed:
if x.keys.altJump == KEYS_PRESSED then
You can also use x.mount < 1 instead of the mem offset.
I don't know what c is in this context because of this heavily cut down code fragment, so I can't comment on that bit.
Next, I don't know why you would want to wait a frame in that situation. It sounds rather volatile/unresponsive. It looks like you're trying to make a long jump script, but long jumps have never been locked to an arbitrary 20 frame limit, or with a 1-frame delay.
Then again, very little context in this script so I cannot give more precisely targeted advice regarding the intended goal. Dunno the intended goal after all.
The easiest way to delay by 1 frame is by using a coroutine https://wohlsoft.ru/pgewiki/EventU.lua
You never have to use io or os functions when working with SMBX2's lunalua module.
|
|
|
|
|
|
|
|
|
-
Bulby_VR
- Fighter Fly

- Posts: 33
- Joined: Wed Aug 07, 2019 11:18 am
Postby Bulby_VR » Sun Aug 18, 2019 8:03 pm
I think my stuff is working with nothing really messed up, so I think I'm done with the help.
I'll probably post the file soon to the forum
|
|
|
|
|
|
|
|
|
-
FlyingGym
- Koopa

- Posts: 16
- Joined: Sat Aug 17, 2019 3:28 pm
- Flair: ok
Postby FlyingGym » Sun Aug 18, 2019 11:09 pm
|
|
|
|
|
|
|
|
|
-
MarioLover64
- Spike

- Posts: 259
- Joined: Fri Apr 26, 2019 6:09 pm
Postby MarioLover64 » Thu Aug 22, 2019 8:40 pm
is it possible to use my system's date to do stuff on specific days?
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Thu Aug 22, 2019 8:51 pm
MarioLover64 wrote: ↑Thu Aug 22, 2019 8:40 pm
is it possible to use my system's date to do stuff on specific days?
os.date is available, so yes.
|
|
|
|
|
|
|
|
|
-
MarioLover64
- Spike

- Posts: 259
- Joined: Fri Apr 26, 2019 6:09 pm
Postby MarioLover64 » Thu Aug 22, 2019 9:10 pm
ok so camLock refuses to work at all. it does absolutely nothing. There aren't even any errors.
Added in 36 seconds:
Oh yeah, here's my code
--------------------------------------------------
-- World map code
-- Created 12:47 2019-5-3
--------------------------------------------------
-- Run code on first frame of the world map
function onStart()
local camLock = require("camLock")
camLock.addZone(-64,0,25,20)
end
-- Run code every frame (~1/65 second)
-- (code will be executed before game logic will be processed)
function onTick()
--Your code here
end
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Thu Aug 22, 2019 9:15 pm
You're creating a camera zone at coordinates -64, 0 with scale 25, 20. That's 25 pixels wide and 20 pixels tall. You expect the camera to fit in there? The camera is 800x600 pixels...
|
|
|
|
|
|
|
|
|
-
MarioLover64
- Spike

- Posts: 259
- Joined: Fri Apr 26, 2019 6:09 pm
Postby MarioLover64 » Thu Aug 22, 2019 9:19 pm
i thought it was a per tile basis
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Thu Aug 22, 2019 9:23 pm
Struggling to think of a scenario where distance in lua libraries isn't measured in pixels.
|
|
|
|
|
|
|
|
|
-
MarioLover64
- Spike

- Posts: 259
- Joined: Fri Apr 26, 2019 6:09 pm
Postby MarioLover64 » Thu Aug 22, 2019 9:29 pm
me adjusts so it's big enough
Still doesn't work
Code: Select all --------------------------------------------------
-- World map code
-- Created 12:47 2019-5-3
--------------------------------------------------
-- Run code on first frame of the world map
function onStart()
local camLock = require("camLock")
camLock.addZone(-64,0,864,800,1)
end
-- Run code every frame (~1/65 second)
-- (code will be executed before game logic will be processed)
function onTick()
--Your code here
end
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Thu Aug 22, 2019 9:50 pm
Seems there is an issue with camlock on the PAL release, odd.
Try Beta 3. It should work there.
|
|
|
|
|
|
|
|
|
-
Daring Tombstone
- Blooper

- Posts: 160
- Joined: Mon Aug 28, 2017 10:57 pm
- Flair: What? Not 1000 posts? That means I suck right?
Postby Daring Tombstone » Sat Aug 24, 2019 3:07 pm
Been looking to figure out how to use the darkness.lua and attach a light to an npc (npc-102 to be precise) but can't figure it out for the life of me. I only figured out how to do so editing the darkness.lua script directly. NPC.get keeps giving me arithmetic errors.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Sat Aug 24, 2019 3:28 pm
Daring Tombstone wrote: ↑Sat Aug 24, 2019 3:07 pm
Been looking to figure out how to use the darkness.lua and attach a light to an npc (npc-102 to be precise) but can't figure it out for the life of me. I only figured out how to do so editing the darkness.lua script directly. NPC.get keeps giving me arithmetic errors.
Use the NPC config flags:
https://docs.google.com/spreadsheets/d/ ... edit#gid=0
|
|
|
|
|
|
|
|
|
-
MarioLover64
- Spike

- Posts: 259
- Joined: Fri Apr 26, 2019 6:09 pm
Postby MarioLover64 » Sun Aug 25, 2019 3:23 pm
How can I make it so that enemies thrown at a boss only damages the boss if it hits the top 32 pixels of the boss and just kills the thrown npc otherwise.
|
|
|
|
|
|
|
|
|
-
MarioLover64
- Spike

- Posts: 259
- Joined: Fri Apr 26, 2019 6:09 pm
Postby MarioLover64 » Mon Aug 26, 2019 8:28 pm
How do I make noteblocks bounce me higher (to a height of six blocks instead of five)
|
|
|
|
|
Return to “LunaLua Help”
Users browsing this forum: No registered users and 9 guests
|