#lua npc code not working

120 messages · Page 1 of 1 (latest)

thick raft
#

I have tried to add theo but it doesnt work and i dont know why

#

this is the code

#

i have read the articles but i still dont really understand what im doing wrong

regal grove
#

all you did was define the functions

#

they're never called

thick raft
#

And uhh

#

How do I call them

#

Is it just walk?

#

Or Theo walk

regal grove
#
function onBegin()
  summonTheo()
  moveTheo(4*8, 0) -- move theo 4 tiles right
end
thick raft
#

Thanks a lot
If I need anymore help can I ask on this thread?

#

it still doesnt work
i know im doing something wrong

regal grove
#

is the onbegin at the end

thick raft
#

like this?

regal grove
#

yeah

#

did you save

thick raft
#

yea

regal grove
#

ah position

#

you need to give the position to summonTheo

#

give it a vector2(..., ...)

thick raft
#

like the x and y coordinates

regal grove
#

yes

thick raft
#

how do i see them in lonn

regal grove
#

do you have celestetas installed

thick raft
#

no

#

should i do that

regal grove
#

id advise you do

thick raft
#

ok 1 moment

regal grove
#

then press left ctrl twice in-game to see your current position

#

and other stuff

#

initially its a bit confusing to navigate but its rather intuitive

#

(you can drag the menu around by holding left ctrl and dragging the menu with your mouse)

thick raft
#

so do i put the posion of where my lua cutscene trigger is?

regal grove
#

it can be wherever

thick raft
#

oh ok

regal grove
#

which is why it needs a position argument

#

you need to tell it where to spawn theo

thick raft
#

local function summonTheo(211,144)

#

is that right?

regal grove
#

...no

thick raft
#

uh

regal grove
#

you don't change the definition

thick raft
#

o

regal grove
#

you change the call

thick raft
#

ooh

regal grove
#
summonTheo(vector2(211,144))
thick raft
#

dude that works

#

what would i of done without you

#

also

#

moveTheo(4*8, 0)
if i want him to move more

#

do i do moveTheo(10*20, 0)

#

why am i asking i can just try it

regal grove
#

the units are in pixels

#

there's 8 pixels in a tile

#

hence the 4*8

#

this moves theo right 4 tiles

thick raft
#

ohhhh

#

and if i put -4*8 he will go left?

regal grove
#

yes

thick raft
#

ok

regal grove
#

similarly if you put it in the y coordinate
+y is down, -y is up

thick raft
#

if i want granny do i switch theo with granny

#

no
hmmmm

regal grove
#

thatll be a bit complicated

#

open vanilla's Sprites.xml that can be found in content/graphics

#

then look for a line that resembles granny

thick raft
#

alr

#

can you play custom animation for them?

regal grove
#

yes

thick raft
#

like the one of granny laughing

#

i think i found granny

#

<granny path="characters/oldlady/" start="idle">

#

still nothing

regal grove
thick raft
#

is it granny or oldlady?

regal grove
#

granny

thick raft
#

oh alr

regal grove
#

we go by the xml name

thick raft
#

yea it works

#

if i want to play her laught do i do
granny.laughAnim = "laugh"

#

that seems to break the code though

regal grove
#

put shortly: this is a nono

#

do you want her to laugh as her idle animation

thick raft
#

how do i see the NPC class

regal grove
#

decompiling the game

thick raft
#

can i not make her idle and then light?

#

laugh*

regal grove
#

you can but it's more involved

thick raft
#

do i have to change the idle anim of hers after i use it

regal grove
#

nno i dont think so

#

you can just say("abc") then theo.Sprite:Play("laugh")
(the npc is still labeled theo in lua)

thick raft
#

oh yea

#

i though that when she laughs the HA-HA in the air would also appear

regal grove
#

does it not?

thick raft
#

no

regal grove
#

huh

thick raft
#

maybe its a diffrent sprite

regal grove
#

oh wait "appear"

#

yeah its a different sprite

thick raft
#

dam

#

sorry for asking for so much but

#

how do i add them

regal grove
#

i'm on phone and id need to look at the decompilation

#

and even then this sounds kinda complicated

thick raft
#

oh its alr then

#

i did find a problem though

#

if i skip the cutscene theo will be walking in place instead of sitting down

regal grove
#

because you interrupted the cutscene while it's doing its thing
you need to tell it what to do if the cutscene ends and was skipped

thick raft
#

i hate that youre just giving me the code
i want to be able to do this on my own but its so hard sobeline

thick raft
#

ive been looking at them from the start

#

function onEnd (room, wasSkipped)
moveTheo(5*10, 0)
theo.Sprite:Play("sitDown")
end

#

i though i did something with this

#

but i was wrong

thick raft
#

i think i figured something out, for the most part

#

i just want some help on a tiny bit if thats ok

#

NEVERMIND I FIGURED IT OUT ON MY OWN I AM A GENIUSE