Log In  
Follow
Cerb043_4
Follow

Nothing I try seems very active. I went through...slack...twitter.....here....stack exchange. And the time delay between getting any answers, if any, is excruciatingly ineffective. Are there more active communities I could get help from that I haven't tried?

Here and there I have little questions I need help with. Mainly syntax related, I don't need somsone to go through ALL my code or anything just 1 liners here and there. For small questions while writing your code, what is the best way to get answers asap? Was hoping for a chatbox or irs or something.

P#66018 2019-07-22 01:34

I'm having a really hard time with initiating if statements using multiple booleans. It seems I initiate one but then it stays and I can't figure out how to write them properly if I'm dealing with multiple.

In this example I'm trying to set 3 gamescreens with a timer for the 2nd.
The default screen is titlescreen; the initated one on button press is titlescreen1; and then i want gamescreen to happen automatically when the timer finishes.

Problem is gamescreen doesn't initiate and I don't understand why.

countdown=5
time_diff=0
titlescreen=true
titlescreen1=false
gamescreen=false

function _init()
end

function time_lapse()
if time() - time_diff > 1 and countdown > 0 then
countdown-=1
time_diff=time()
end
end

function _update()
if btn(4) then titlescreen1=true end
if titlescreen1==true then time_lapse()
if countdown==0 then gamescreen=true end
elseif gamescreen==true then
end
end

function _draw()
cls()
print("one is happening",33,33,14)
if titlescreen1==true then cls() print(countdown,15,15,14)
elseif gamescreen==true then
cls()
print("gamescreen is active",33,33,14)
end
end

P#65997 2019-07-21 08:43

Basic movement can be facilitated through:
if btn(0) then x-=1 end

But when I add sfx:

if btn(0) then x-=1 and sfx(0) end

It always generates an error as soon as that button 0 is pressed. Why is that? If x then y and z end. Is there something wrong with that syntax? Or is it related to sfx not working in this way?

And why is it when I clarify with brackets it doesn't even run!? Am I clarifying that my syntax is wrong before teh game starts? That's funny.
i.e.
if btn(0) then (x-=1 and sfx(0)) end

P#65973 2019-07-20 14:59 ( Edited 2019-07-20 15:01)

Edit: not sure how I'm expected to display multiplication using the syntax here, but assume there's a X or star or whatever between 15 and i etc.

I was trying to initiate this statement here, which I can do:
for i=1,4 do
print(i, 15i-14, 15i-14, 14)
end

But then I wanted to move the diagonal array of 4 numbers with the arrow keys around the screen. I tried the code below but keep getting errors. I'm guessing my argument is setup wrong and I can't call i as the same variable in all these statements and make it work...? Can someone help me understand the immediate problems with the code, and then afterwards if viable suggest an alternative method of doing so. I'm still learning so my immediate concern is figuring out what is wrong here specifically.

function _init()
j= {
x=15i-14,
y=15
i-14
}
end

function _update()
if btn(0) then j.x-=1 end
if btn(1) then j.x+=1 end
if btn(2) then j.y-=1 end
if btn(3) then j.y+=1 end
end

function _draw()
cls(0)
for i=1,4 do
print(i,j.x,j.y,14)
end
end

Even in the API demo I copy the code for the similar statment, but when i run it on its own it doesn't work. I don't understand why this here doesn't work on its own either:

cls()
for i=0,15 do
print(i,x,2,i)
x = x + 6 + flr(i/10)*4
end

P#65880 2019-07-16 08:50 ( Edited 2019-07-16 09:03)

Follow Lexaloffle:        
Generated 2020-03-31 23:55 | 0.072s | 4194k | Q:16