Page 1 of 1

Where to place AI-lua files?

Posted: Sun Feb 09, 2020 9:04 am
by Sednaiur
Hello again.

I like to change some details about the giant colorswitches, like the amount of frames, the amount of bursts and the time inbetween each burst.
So I copied the palaceswitch file from the NPCs/AI-folder over to my level's folder and edited the corresponding values. But it seems that the file either isn't getting read or the edits I made are not sufficient to work out.

This is what I edited in the palaceswitch-AI file:

frames = 1 changed to frames = 4
bursts = 11 changed to bursts = 12
burstinterval = 50 changed to burstinterval = 30

I also tried to create an AI-folder in my level's folder and put the palaceswitch file in there, but no results whatsoever.

So, where do I actually have to put the AI-files for them to work, or what else do I need to edit to make the changes apply?

Re: Where to place AI-lua files?

Posted: Sun Feb 09, 2020 11:05 am
by MrDoubleA
You may have to place it in a folder called "ai", which itself is in a folder called "npcs".

Re: Where to place AI-lua files?

Posted: Sun Feb 09, 2020 1:53 pm
by Sednaiur
Well, shortly after I made the post, I figured that it could not harm to test exactly that, but unfortunately to no avail. I even have edited this code to further test things out:

function bigSwitch.onDrawNPC(npc)
if not npc.isHidden then
local data = npc.data._basegame
local pressed = isPressed(NPC.config[npc.id], npc)

if pressed and data.effect ~= nil then
data.effect:Draw(-36)
npc.animationFrame = 1 >>> npc.animationFrame = 3
elseif pressed then
npc.animationFrame = 1 >>> npc.animationFrame = 3
else
npc.animationFrame = 0
end
end
end

But that leads me to think even more that the file just isn't read at all where I have placed it.

Re: Where to place AI-lua files?

Posted: Sun Feb 09, 2020 2:30 pm
by Hoeloe
Why the heck did you edit the ai file? You know all those changes can just be done with npc.txt files right?

Re: Where to place AI-lua files?

Posted: Mon Feb 10, 2020 12:52 pm
by Sednaiur
Hoeloe wrote:
Sun Feb 09, 2020 2:30 pm
Well, I tried that first but to no avail. Here is what I have put in the TXT-file:
frames=3
framestyle=0
framespeed=8
What I want to do is having the "unpressed"-state being animated with 3 frames, while the "pressed"-state is supposed to not have more than one frame. But the TXT-file does not work and the INI-file also does not work for that, so I tried to edit the AI-file to reflect that, but it also is not working.

Is it even possible to animate the colorswitches at all? Obviously, in PGE it works fine, just not ingame.

Edit: Also, these settings are not a given thing in TXT-files, just in the AI-files, or is it?:
pressedheight = 32,
synchronize = true, --Whether the switches of this type should be synced
switchon = true, --Whether the switch transforms "off" blocks into "on" blocks.
switchoff = true, --Whether the switch transforms existing "on" blocks into off blocks.
blockon = 1, --The ID of the switch's "on" blocks.
blockoff = 2, --The ID of the switch's "off" blocks.
exitlevel = true, --Whether or not the switch will work as a level exit.
save = true, --Whether or not the switch will actually save, or only work for the level. Best changed in conjunction with exitlevel.
bursts = 11, --number of switch bursts. Works best as 11 with exitlevel, and 1 without. >>> is supposed to be 12 for my settings
burstinterval = 50 --yeah >>> is supposed to be 30 for my settings

Re: Where to place AI-lua files?

Posted: Mon Feb 10, 2020 4:43 pm
by Hoeloe
Anything that is inside the "setNPCSettings" call can be adjusted with npc.txt files.

Re: Where to place AI-lua files?

Posted: Mon Feb 10, 2020 7:03 pm
by Sednaiur
Hoeloe wrote: Anything that is inside the "setNPCSettings" call can be adjusted with npc.txt files.
This code is from the red palace switch:
local bigSwitch = {}

local npcManager = require("npcManager")
local palaceSwitch = require("npcs/ai/palaceswitch")

local npcID = NPC_ID

local settings = {id=npcID, color="red", blockon=730, blockoff=731, iscustomswitch = true}

palaceSwitch.registerSwitch(settings)
return bigSwitch


I do not see a "setNPCSettings" call in there. The only settings close to the ones usually used in the normal TXT-files are in the "palaceswitch.lua", which are:
bigSwitch.sharedSettings = {
gfxwidth = 64,
gfxheight = 64,
width = 64,
height = 64,
nogravity = false,
frames = 2,
framestyle = 0,
framespeed = 8,
noblockcollision = false,
playerblock = true,
playerblocktop = true,
npcblock = true,
npcblocktop = true,
speed = 0,
jumphurt = true,
nohurt = true,
score = 0,
noiceball = true,
nowaterphysics = true,
foreground = true,
noyoshi = true,
notcointransformable = true,

--lua settings
pressedheight = 32,
synchronize = true, --Whether the switches of this type should be synced
switchon = true, --Whether the switch transforms "off" blocks into "on" blocks.
switchoff = true, --Whether the switch transforms existing "on" blocks into off blocks.
blockon = 1, --The ID of the switch's "on" blocks.
blockoff = 2, --The ID of the switch's "off" blocks.
exitlevel = true, --Whether or not the switch will work as a level exit.
save = true, --Whether or not the switch will actually save, or only work for the level. Best changed in conjunction with exitlevel.
bursts = 11, --number of switch bursts. Works best as 11 with exitlevel, and 1 without.
burstinterval = 50 --yeah
}

local switchColorFunctions = {}

I tried to edit that but without luck.

Re: Where to place AI-lua files?

Posted: Mon Feb 10, 2020 10:02 pm
by Hoeloe
Those are all settings you can modify with npc.txt, yes.