Page 1 of 1

Importing an AI

Posted: Fri Feb 05, 2021 4:52 am
by DrMekar
I'd like to import the Scuttlebug A.I for my Bulbul NPC, since it's reflects his agressive 3D-Enviroment Attacking Style the best, though I'm not sure how to do this.

Help would great.

Re: Importing an AI

Posted: Fri Feb 05, 2021 5:45 am
by Emral
copy and rename the npc-n.lua file for the scuttlebug (dunno scuttlebug id off the top of my head)

Re: Importing an AI

Posted: Fri Feb 05, 2021 6:33 am
by DrMekar
Enjl wrote:
Fri Feb 05, 2021 5:45 am
copy and rename the npc-n.lua file for the scuttlebug (dunno scuttlebug id off the top of my head)
Hmm.. okay, though isen't there a Way to import it? My Bulbul NPC already has set Lives.

Re: Importing an AI

Posted: Fri Feb 05, 2021 7:07 am
by Emral
DrMekar wrote:
Fri Feb 05, 2021 6:33 am
Enjl wrote:
Fri Feb 05, 2021 5:45 am
copy and rename the npc-n.lua file for the scuttlebug (dunno scuttlebug id off the top of my head)
Hmm.. okay, though isen't there a Way to import it? My Bulbul NPC already has set Lives.
If scuttlebugs have an ai file you can read the npc-n file to see how it uses it and just do that.

Re: Importing an AI

Posted: Fri Feb 05, 2021 7:41 am
by DrMekar
Enjl wrote:
Fri Feb 05, 2021 7:07 am
DrMekar wrote:
Fri Feb 05, 2021 6:33 am
Enjl wrote:
Fri Feb 05, 2021 5:45 am
copy and rename the npc-n.lua file for the scuttlebug (dunno scuttlebug id off the top of my head)
Hmm.. okay, though isen't there a Way to import it? My Bulbul NPC already has set Lives.
If scuttlebugs have an ai file you can read the npc-n file to see how it uses it and just do that.
I reconsidered to use the Snailcorn AI and added this line: local = require("npcs/ai/snailicorn") to it like the Snailcorn NPC did it too.
I'm however receiving this Error:

Image

Re: Importing an AI

Posted: Fri Feb 05, 2021 9:01 am
by Emral
Either read line 3 for your npc-n.lua and find this error yourself or post line 3 and I'll show you how ridiculously simple it is to find.

Image

Re: Importing an AI

Posted: Fri Feb 05, 2021 9:17 am
by DrMekar
Enjl wrote:
Fri Feb 05, 2021 9:01 am
Either read line 3 for your npc-n.lua and find this error yourself or post line 3 and I'll show you how ridiculously simple it is to find.

Image
This is Line 3.

Code: Select all

local = require("npcs/ai/snailicorn")
I've got AI Folder in my Episode Folder aswell.

Re: Importing an AI

Posted: Fri Feb 05, 2021 9:51 am
by Emral
DrMekar wrote:
Fri Feb 05, 2021 9:17 am

This is Line 3.

Code: Select all

local = require("npcs/ai/snailicorn")
The error message says "<name> expected near =", meaning the code read a = when it expected there to be a variable name.
Look at your line. Look at other require calls for comparison (for example the one snailicorns use). I think you will be able to find the issue within seconds.

Re: Importing an AI

Posted: Fri Feb 05, 2021 9:59 am
by DrMekar
Enjl wrote:
Fri Feb 05, 2021 9:51 am
DrMekar wrote:
Fri Feb 05, 2021 9:17 am

This is Line 3.

Code: Select all

local = require("npcs/ai/snailicorn")
The error message says "<name> expected near =", meaning the code read a = when it expected there to be a variable name.
Look at your line. Look at other require calls for comparison (for example the one snailicorns use). I think you will be able to find the issue within seconds.
Okay, I found the issue and removed the former Main AI of my NPC, though now he just stands there. Do you mind taking a look at it?
https://pastebin.com/E6BsK2db

Re: Importing an AI

Posted: Fri Feb 05, 2021 10:25 am
by Hoeloe

Code: Select all

local bulbulNPC = require("npcs/ai/snailicorn")
 
--Create the library table
local bulbulNPC = {}
Don't do this. You're loading the snailicorn AI file, and then immediately overwriting it with your own table. Make sure variable names are unique.

Re: Importing an AI

Posted: Fri Feb 05, 2021 10:30 am
by DrMekar
Hoeloe wrote:
Fri Feb 05, 2021 10:25 am

Code: Select all

local bulbulNPC = require("npcs/ai/snailicorn")
 
--Create the library table
local bulbulNPC = {}
Don't do this. You're loading the snailicorn AI file, and then immediately overwriting it with your own table. Make sure variable names are unique.
Okay, so what do I have to remove now? I removed the this

Code: Select all

local bulbulNPC = {}
so it didn't changed anything.

Re: Importing an AI

Posted: Fri Feb 05, 2021 10:47 am
by Hoeloe
No, you don't remove that, you call the snailicorn library something else, so that you can reference it and then actually register your NPC with it.

I suggest you actually look at how the snailicorns themselves are doing it, rather than guessing randomly.

Re: Importing an AI

Posted: Fri Feb 05, 2021 10:52 am
by DrMekar
Hoeloe wrote:
Fri Feb 05, 2021 10:47 am
No, you don't remove that, you call the snailicorn library something else, so that you can reference it and then actually register your NPC with it.

I suggest you actually look at how the snailicorns themselves are doing it, rather than guessing randomly.
Okay, I did that. It still doesn't work:

Code: Select all

local npcManager = require("npcManager")
local bulbulNPC = require("AI/bulbul")

Re: Importing an AI

Posted: Fri Feb 05, 2021 1:02 pm
by DrMekar
I took a close look at everything and can't figure what to do diffrent. I'd really apperiate the help and I'm not going to learn it by being ignored, so I'd be really thankful if that didn't happend.

Re: Importing an AI

Posted: Fri Feb 05, 2021 1:45 pm
by Hoeloe
DrMekar wrote:
Fri Feb 05, 2021 10:52 am
Hoeloe wrote:
Fri Feb 05, 2021 10:47 am
No, you don't remove that, you call the snailicorn library something else, so that you can reference it and then actually register your NPC with it.

I suggest you actually look at how the snailicorns themselves are doing it, rather than guessing randomly.
Okay, I did that. It still doesn't work:

Code: Select all

local npcManager = require("npcManager")
local bulbulNPC = require("AI/bulbul")
AI/bulbul doesn't exist. You changed something completely different to what I told you to. Let's take a look at what the snailicorns do:

Code: Select all

local npcManager = require("npcManager")
local snailai = require("npcs/ai/snailicorn")

local snailicorn = {}
They load the ai file into a separate variable, and then make their own table. From there, they use a number of functions that interact with the snailai variable.

You'd be best off just copying the npc-623 file and using that as a base, rather than trying to make your own from scratch.

Re: Importing an AI

Posted: Sat Feb 06, 2021 10:55 am
by DrMekar
Hoeloe wrote:
Fri Feb 05, 2021 1:45 pm
DrMekar wrote:
Fri Feb 05, 2021 10:52 am
Hoeloe wrote:
Fri Feb 05, 2021 10:47 am
No, you don't remove that, you call the snailicorn library something else, so that you can reference it and then actually register your NPC with it.

I suggest you actually look at how the snailicorns themselves are doing it, rather than guessing randomly.
Okay, I did that. It still doesn't work:

Code: Select all

local npcManager = require("npcManager")
local bulbulNPC = require("AI/bulbul")
AI/bulbul doesn't exist. You changed something completely different to what I told you to. Let's take a look at what the snailicorns do:

Code: Select all

local npcManager = require("npcManager")
local snailai = require("npcs/ai/snailicorn")

local snailicorn = {}
They load the ai file into a separate variable, and then make their own table. From there, they use a number of functions that interact with the snailai variable.

You'd be best off just copying the npc-623 file and using that as a base, rather than trying to make your own from scratch.
You told me to change the Snailcorn to something else, so that's what I did.

After that I do the except same thing in the beginning. I did not know that I have to mention it during the Code, which is why this Topic exists.

I'm not. I already made the compromise to import the AI, instead of doing my own, since the Bulbul practically does the same thing as the Snailcorn. It exists on its own, until it sees the Player. Upon doing that, it chases him.

Re: Importing an AI

Posted: Sat Feb 06, 2021 1:02 pm
by Hoeloe
I feel like you don't understand what you're doing in the slightest, or what I'm trying to explain to you, and it's really hampering your ability to get this done. I strongly suggest learning some basic Lua before tackling this, because you're effectively guessing at random and you will not make progress like that.

Re: Importing an AI

Posted: Sat Feb 06, 2021 2:46 pm
by DrMekar
Hoeloe wrote:
Sat Feb 06, 2021 1:02 pm
I feel like you don't understand what you're doing in the slightest, or what I'm trying to explain to you, and it's really hampering your ability to get this done. I strongly suggest learning some basic Lua before tackling this, because you're effectively guessing at random and you will not make progress like that.
I do understand some of it, though far from everything, which is why I asked. I did already gave my NPC the Health of 4 and made him behave like a Goomba, which is not much, but still something. I'm not planning on starting to do NPC Packs all the time, I just want to do this one NPC and then some simple Bosses, like a Porcu Puffer who behaves like one, just with Jumps and multiple Lives, only able to be deducted via Spinjump.

There are just almost no Lua Bosses right now and my one request I made got ignored on the forum and Discord, so what should I do? I'm drifting away though. My Question would just be how do I simply import an AI to an NPC? I looked at the Sledge Bro NPC and there were barely any lines written in it and then theres the Snailcorn.

Re: Importing an AI

Posted: Sat Feb 06, 2021 3:26 pm
by Hoeloe
You've been told multiple times. You import the library into a variable (which you still don't seem to understand how to do, even though it's literally been written out for you multiple times), then call functions on that table to execute certain behaviours. Some behaviour libraries just require registering, some are more general-purpose, and require a lot more work, such as snailicorn, which is why I suggested working from a copy of the snailicorn code, since you want the same behaviour with some slight tweaks. It's easier to take that behaviour and modify it than to built it up again.

Re: Importing an AI

Posted: Sat Feb 06, 2021 3:33 pm
by DrMekar
Hoeloe wrote:
Sat Feb 06, 2021 3:26 pm
It's easier to take that behaviour and modify it than to built it up again.
Okay, got that. The First Time it sounded more like a less Advanced Method, though if it works diffrent per NPC, it makes alot of sense.

I did of course read everything else and will try to get behind it far better. Thanks.