Lineguide.lua (Layer Attachment Now Works!)

This is the place for discussion and support for LunaLua and related modifications and libraries.

Moderator: Userbase Moderators

Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
ElectriKong
Bowser
Bowser
Posts: 4652
Joined: Mon Jun 06, 2016 4:32 pm
Pronouns: he/him
Contact:

Re: Lineguide.lua (Alternate Graphics Added)

Postby ElectriKong » Sat Apr 08, 2017 3:59 pm

Sambo wrote:Clearly, if it isn't working. I can't help you if you don't show me your code.
It is the same code that was on the PGE wiki

local lineguide = API.load("lineguide")

Is there anything else I am supposed to add. I made sure the line BGOs are the default ones (same ID as from the included GFX pack).

Sambo
Snifit
Snifit
Posts: 211
Joined: Fri Jan 24, 2014 6:43 pm

Re: Lineguide.lua (Alternate Graphics Added)

Postby Sambo » Sat Apr 08, 2017 4:01 pm

King of Eterity wrote:
Sambo wrote:Clearly, if it isn't working. I can't help you if you don't show me your code.
It is the same code that was on the PGE wiki

local lineguide = API.load("lineguide")

Is there anything else I am supposed to add. I made sure the line BGOs are the default ones (same ID as from the included GFX pack).
Nope, that should be all you need.
RudeGuy07 wrote:hey, sorry for bumping this topic, but i don't understand what to put in the lua file when you rename some bgos, and the page in the wiki doesn't say much about this. i've tried writing something like this:

Code: Select all

local lineHorizontal = 95;
but it doesn't work.

Code: Select all

lineguide.lineHorizontal = 95
Sorry, I missed your post. Whenever using a function or accessing a variable in an API, you generally put the name of it before that variable/function.

ElectriKong
Bowser
Bowser
Posts: 4652
Joined: Mon Jun 06, 2016 4:32 pm
Pronouns: he/him
Contact:

Re: Lineguide.lua (Alternate Graphics Added)

Postby ElectriKong » Sat Apr 08, 2017 4:04 pm

Sambo wrote:
King of Eterity wrote:
Sambo wrote:Clearly, if it isn't working. I can't help you if you don't show me your code.
It is the same code that was on the PGE wiki

local lineguide = API.load("lineguide")

Is there anything else I am supposed to add. I made sure the line BGOs are the default ones (same ID as from the included GFX pack).
Nope, that should be all you need.
Is there anything else that I could have done wrong outside the code? Are SMB3 platforms linked by default (which I thought they should be)

Westretroman
Eerie
Eerie
Posts: 704
Joined: Tue Mar 29, 2016 6:50 pm

Re: Lineguide.lua

Postby Westretroman » Sun Apr 09, 2017 9:57 am

King of Eterity wrote:
Westretroman wrote:
Sambo wrote: It is. Horikawa is adding it.

No problem. I enjoyed making this (except for the occasional hard-to-fix bug).

Added white and dotted lines to the graphics folder (the black ones are still included).
It went from just a cool experiment to being put in 2.0, this will be really useful for my episode!
You can already download it if you weren't aware of that already.
Actually​ I was aware of that, I just said it was a cool experiment because of how unique it was compared to the basic lines that SMBX had.

ElectriKong
Bowser
Bowser
Posts: 4652
Joined: Mon Jun 06, 2016 4:32 pm
Pronouns: he/him
Contact:

Re: Lineguide.lua (Alternate Graphics Added)

Postby ElectriKong » Sun Apr 09, 2017 11:29 am

OK, I have got the thing working. Realized that I incorrectly named the .lua file. But there is a bug:
Image
When the platform moves upwards an into this curve, instead of continuing around the curve, it just stops and freaks out.

Going up with these is also buggy:
Image
The platform falls to the right instead of going up and left like it should

And this:
Image
Basically a combination of the above 2. Stops, causes Mario to fall through, platform freaks out and then falls to the right.

The smaller curve, gentle slope and 90 angle works fine going up but the platform stops and freaks out when going the other way.

timocomsmbx2345
Foo
Foo
Posts: 853
Joined: Sat Feb 06, 2016 1:44 pm
Contact:

Re: Lineguide.lua (Alternate Graphics Added)

Postby timocomsmbx2345 » Fri Apr 14, 2017 4:58 pm

how do you get npcs to attach to the lines?

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Lineguide.lua (Alternate Graphics Added)

Postby PixelPest » Fri Apr 14, 2017 5:05 pm

timocomsmbx2345 wrote:how do you get npcs to attach to the lines?
Did you read the documentation? It's linked in the OP

timocomsmbx2345
Foo
Foo
Posts: 853
Joined: Sat Feb 06, 2016 1:44 pm
Contact:

Re: Lineguide.lua (Alternate Graphics Added)

Postby timocomsmbx2345 » Fri Apr 14, 2017 6:35 pm

PixelPest wrote:
timocomsmbx2345 wrote:how do you get npcs to attach to the lines?
Did you read the documentation? It's linked in the OP
well, can i at least have an example?
never mind, i got the skull rafts to attach to the lines. jk, i need an example
come on i need an example so i cn do anything besised the colored blocks, because when i tried, i get a dumb error 9in retirurn!
and no one even respnded
Sambo wrote:Clearly, if it isn't working. I can't help you if you don't show me your code.
Well, All i did was insert the id of the skull raft, and nothing happened. . . .
Last edited by JupiHornet on Thu Apr 20, 2017 3:31 pm, edited 1 time in total.
Reason: merged quadruple post ;-;

kr4k1n
Reznor
Reznor
Posts: 2926
Joined: Sun Dec 11, 2016 8:02 pm
Flair: cats are cool
Pronouns: he/him/his
Contact:

Re: Lineguide.lua (Alternate Graphics Added)

Postby kr4k1n » Fri Apr 14, 2017 9:37 pm

timocomsmbx2345 wrote:and no one even respnded
People have other things to do rn, give them some time and somebody who knows how to fix your problem might come and help.

Sambo
Snifit
Snifit
Posts: 211
Joined: Fri Jan 24, 2014 6:43 pm

Re: Lineguide.lua (Alternate Graphics Added)

Postby Sambo » Thu Apr 20, 2017 12:33 am

timocomsmbx2345 wrote:
Sambo wrote:Clearly, if it isn't working. I can't help you if you don't show me your code.
Well, All i did was insert the id of the skull raft, and nothing happened. . . .
When did you do it? You have to add the ID outside of all your functions, or in onStart.
Can I see your code?

BTW, skull rafts will attach automatically in 2.0.
King of Eterity wrote: ... bugs ...
I can't reproduce this. I tested all the curves you showed me and they worked. Are you doing something weird like overlapping them?

PersonNamedUser
Reznor
Reznor
Posts: 2882
Joined: Fri Feb 27, 2015 8:07 pm

Re: Lineguide.lua (Alternate Graphics Added)

Postby PersonNamedUser » Tue May 09, 2017 10:29 pm

Excuse me, but what code do you put in to allow other things to be attached to the lines?

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Lineguide.lua (Alternate Graphics Added)

Postby PixelPest » Tue May 09, 2017 10:31 pm

"Other things" is pretty vague. If you mean NPCs it explains on the documentation.

Also btw Bubbles don't work with lineguides

PersonNamedUser
Reznor
Reznor
Posts: 2882
Joined: Fri Feb 27, 2015 8:07 pm

Re: Lineguide.lua (Alternate Graphics Added)

Postby PersonNamedUser » Tue May 09, 2017 10:37 pm

I meant the npcs, yeah it explains, but is this correct?

Code: Select all

local lineguide = API.load("lineguide")
timerApi = loadAPI("leveltimer");
lineguide.lineNpcs[209]

function onLoad()
     timerApi.setSecondsLeft(600);
     timerApi.setTimerState(true);
end

HenryRichard
Reznor
Reznor
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: Lineguide.lua (Alternate Graphics Added)

Postby HenryRichard » Wed May 10, 2017 11:38 am

I'm not to familiar with how this works but if you don't set lineguide.lineNpcs[209] equal to something nothing will happen. In fact, I don't think that's how it works at all - you'd do something more like lineguide.lineNpcs = {209}.

Kira Yoshikage
Shy Guy
Shy Guy
Posts: 6
Joined: Fri May 12, 2017 8:45 am

Re: Lineguide.lua (Alternate Graphics Added)

Postby Kira Yoshikage » Sat May 27, 2017 4:19 am

Nice and very usefull Api! Everything works fine,except one thing that i can't make work.I'm trying to make Green Cheep Cheep's jump speed be 10,but i keep getting "attempt to index a nil value" error
Do i have any errors in my code?'Couse im bad at programming,maybe i don't see a simple error there:

Code: Select all

local lineguide = API.load("lineguide")

lineguide.lineNpcs = {229}

lineguide.properties[229].jumpSpeed = 10

TDK
Phanto
Phanto
Posts: 1440
Joined: Wed Nov 11, 2015 12:26 pm
Flair: Retired

Re: Lineguide.lua (Alternate Graphics Added)

Postby TDK » Sun May 28, 2017 3:13 pm

I was using lineguide.lua, and there's 2 errors I found. The first one is the motherbrain doesn't work with lineguides. The second is that, if you have goombas on the lineguides and you stomp on 2 at once, it causes an error. It says "Invalid access of pNPC reference"

PersonNamedUser
Reznor
Reznor
Posts: 2882
Joined: Fri Feb 27, 2015 8:07 pm

Re: Lineguide.lua (Alternate Graphics Added)

Postby PersonNamedUser » Tue Jun 06, 2017 11:57 am

I have another problem, i tried to attach dount blocks to lines, and i actually put the code in, but it doesn't work, how do i fix it?

Code: Select all

local lineguide = API.load("lineguide")
local hasGenerated = false;
local hasTransformed = false; --if we've transformed an egg or not
local ran;
local frameCount = 0;
local pnpc = API.load("pnpc"); --init pnpc.lua API

timerApi = loadAPI("leveltimer");
lineguide.lineNpcs = {212}

function OnStart()
lineguide.registerNpcs({212})
end

function onLoad()
     timerApi.setSecondsLeft(600);
     timerApi.setTimerState(true);
end

function onTick()
      for _, n in pairs(NPC.get(40, -1)) do
            n.id = 172
      end
end

function onTick() --run the code every tick (a unit of time); most logic for NPCs, etc. is performed in this event
   for _, v in pairs(NPC.get(39)) do
      local birdo = pnpc.wrap(v);
   
      for _, w in pairs(NPC.getIntersecting(v.x, v.y, v.x + v.width, v.y + v.height)) do --iterate over all NPCs that are intersecting with its hitbox
         if w.id == 40 then --if the NPC is a hammer
            birdo.data.megg = pnpc.wrap(w).uid; --get the unique identifier of the hammer and save it to the Hammer Bro's data table
            w.friendly = true;
            w:transform(172);
         end
      end
   end
   
   for _, x in pairs(NPC.get(172)) do --iterate over all SMB1 green shells
      local shellID = pnpc.wrap(x).uid; --get the unique identifier of the shell
      local intersects = false; --a variable that will be set to true if the shell is still intersecting with the Hammer Bro that threw it
      
      for _, y in pairs(NPC.getIntersecting(x.x, x.y, x.x + x.width, x.y + x.height)) do --iterate over all NPCs that are intersecting with the shell
         if (y.id == 40) and (pnpc.wrap(y).data.megg == shellID) then --if the NPC is a Hammer Bro and its data table reference for "mHammer" is the shell's uid
            intersects = true; --the shell intersects still with the Hammer Bro that threw it, so this variable is set to true
         end
      end
      
      if not intersects then --if the variable intersects is false
         x.friendly = false; --make the shell not be friendly
      else --if the variable intersects is true
         x.friendly = true; --make the shell be friendly
      end
   end
end

function onNPCKill(eventObj, killedNPC, killReason) --an event run every time an NPC is killed; makes sure that if a Hammer Bro is killed before the shell it threw is set to not friendly (the shell was intersecting with the bro when it was killed still) that the shell is set to not friendly
   if killedNPC.id == 40 then --if the killed NPC is a Hammer Bro
      for _, v in pairs(NPC.get(172)) do --iterate over all shells
         if pnpc.wrap(killedNPC).data.megg == pnpc.wrap(v).uid then
            v.friendly = false;
         end
      end
   end
end
EDIT:
Nvm, it works, however, it still acts a bit glitchy

Kira Yoshikage
Shy Guy
Shy Guy
Posts: 6
Joined: Fri May 12, 2017 8:45 am

Re: Lineguide.lua (Alternate Graphics Added)

Postby Kira Yoshikage » Mon Jun 12, 2017 12:29 am

I found another error.If you attach some npc to lineguide,then attach something to that npc,attached npc,block,or background will not follow npc on lineguide.

Cetus808
Tweeter
Tweeter
Posts: 135
Joined: Wed Jul 06, 2016 1:45 am
Contact:

Re: Lineguide.lua (Alternate Graphics Added)

Postby Cetus808 » Fri Aug 04, 2017 9:48 pm

I love this, but it sucks that the background tiles seem to interfere with the line guides, because anything that's attached to them either falls through or get stuck in mid-air. Everything seemed to worked just fine when I got rid of the background tiles, though.

Sambo
Snifit
Snifit
Posts: 211
Joined: Fri Jan 24, 2014 6:43 pm

Re: Lineguide.lua (Alternate Graphics Added)

Postby Sambo » Thu Nov 16, 2017 10:18 pm

Kira Yoshikage wrote:I found another error.If you attach some npc to lineguide,then attach something to that npc,attached npc,block,or background will not follow npc on lineguide.
I just made a patch to fix this
Cetus808 wrote:I love this, but it sucks that the background tiles seem to interfere with the line guides, because anything that's attached to them either falls through or get stuck in mid-air. Everything seemed to worked just fine when I got rid of the background tiles, though.
Do those BGOs happen to be vanilla line guides? Those break this API. I don't have this problem with regular BGOs.

And no, Mother Brain doesn't work with lineguides. It seems to have some sort of stupid hardcoded positioning, so it probably won't be possible to attach directly in the forseeable future. However, with the update I just made, you can place another NPC on the lineguide, then attach that NPC to a layer with Mother Brain on it.

Sorry about the late response. You may have noticed that I'm never around anymore. I can be reached in the discodehaus discord.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari