Author Topic: Need help please with Messages  (Read 10133 times)

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Need help please with Messages
« on: May 05, 2012, 11:11:39 AM »
Okay, So i'm trying to figure out how this is going to work, this is my code...

Code: [Select]
function LevelLogic()
StartLevelLogic()

MessageA()

end

function MessageA()
Message("-Dark Days-~Things have changed little seedlings", true, 1.0, "Top")
MassageB()
end

function MessageB()
Message("The Mother Tree failed to take you places I can~But first, you need to be ready", true, 1.0, "Bottom")
WaitDialog()
end

That's the shortened down version of my problem,

Basically I want MessageA() to be shown first, then when MessageA() is complete I want it to trigger MessageB() and so forth, but I can't understand how to work it?

the full code can be viewed here...

(click to show/hide)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Need help please with Messages
« Reply #1 on: May 05, 2012, 06:29:34 PM »
Have a WaitDialog in MessageA, you should put it afte rthe message has been delivered, but before MessageB is executed.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #2 on: May 05, 2012, 08:35:26 PM »
Have a WaitDialog in MessageA, you should put it afte rthe message has been delivered, but before MessageB is executed.

Hey Aino, i've done that, but it still doesn't display the second message?

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #3 on: May 05, 2012, 09:42:45 PM »
I've changed it a bit more Aino.

Code: [Select]
function LevelLogic()
StartLevelLogic()

First = 1
Second = 0

while GameRunning() do

if (First == 1) then
MessageA()
end

if (Second == 1) then
MessageB()
end

if GetEmpire(1):GetNumOwnedAsteroids() == 5 then
Pause()
MessageBox("You have won")
WaitDialog()
Unpause()
Quit(true)
end

if GetEmpire(1):GetNumOwnedAsteroids() == 0 then
Pause()
MessageBox("You have lost")
WaitDialog()
Unpause()
Quit(false)
end

coroutine.yield()
end
end

function MessageA()
Message("-Dark Days-~Things have changed little seedlings", true, 1.0, "Top")
WaitDialog()
First = 0
Second = 1
end

function MessageB()
Message("The Mother Tree failed to take you places I can~But first, you need to be ready", true, 1.0, "Bottom")
WaitDialog()
Second = 0
end

As you can see i've made the bits resembling the messages in are there, but doesn't this code

Code: [Select]
First = 1
Second = 0

state that First is a statment saying First is 1 and Second is 0 and then this peice of code

Code: [Select]
if (First == 1) then
MessageA()
end

if (Second == 1) then
MessageB()
end

finds wether First equals 1 function MessageA() will start and wether Second equals 1 then function MessageB() will start and then this...

Code: [Select]
function MessageA()
First = 0
Message("-Dark Days-~Things have changed little seedlings", true, 1.0, "Top")
WaitDialog()
Second = 1
end

function MessageB()
Second = 0
Message("The Mother Tree failed to take you places I can~But first, you need to be ready", true, 1.0, "Bottom")
WaitDialog()
end

In bold says when funcation MessageA() is run First will change to equal 0, Message will play, then when the dialog is finished Second = value will change to 1 and so forth for funcation MessageB()

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Need help please with Messages
« Reply #4 on: May 05, 2012, 10:25:02 PM »
You know, you can use boolean instead of integer, if you use integer you can use one variable instead of two. I'm only sayin' because keeping a low memory waste is good, not that two ints do very much though :)

And when I do messages in Eufloria(long time ago now :() I do a pause, messsage, waitdialog and unpause in that order. You should do this for each message...

Add this in the bottom of your code:
Code: [Select]
function TellPlayer(message)
Pause()
MessageBox(message)
WaitDialog()
Unpause()
end

function TellPlayer(message, var1Bool, var2Double, var3String)
Pause()
MessageBox(message, var1Bool, var2Double, var3String)
WaitDialog()
Unpause()
end

and then replace:
Code: [Select]
if (First == 1) then
MessageA()
end

if (Second == 1) then
MessageB()
end

with

Code: [Select]
TellPlayer("-Dark Days-~Things have changed little seedlings", true, 1.0, "Top")
TellPlayer("The Mother Tree failed to take you places I can~But first, you need to be ready", true, 1.0, "Bottom")


Hope it helps :)

P.S: remember to delete dead code, after this change your MessageA() and MessageB() functions will be dead codes...
« Last Edit: May 05, 2012, 10:31:29 PM by Aino »

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #5 on: May 05, 2012, 11:49:40 PM »
You see Aino, the reason why I don't use Pause or MessageBox is because on the iPad the graphics are much more appealing that the PC version, and also, when you use MessageBox, you'll see how unproffessional it is, I will prove this to you in pictures...

The pictures are big, so I'll spoiler them.
(click to show/hide)

The Annoying thing is though, still with your code edited to

Code: [Select]
function TellPlayer(message)
Message(message)
WaitDialog()
end

function TellPlayer(message, var1Bool, var2Double, var3String)
Message(message, var1Bool, var2Double, var3String)
WaitDialog()
end

It still doesn't do the messages in order, but jumps straight to the second TellPlayer(message) and misses the first one out completely...

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Need help please with Messages
« Reply #6 on: May 06, 2012, 12:10:58 AM »
What happened when you used pause/unpause?

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #7 on: May 06, 2012, 12:24:21 AM »
Oh, the game pauses, and never unpauses, but i can move around, but nothing it touchable, seedlings don't move at all, Pause/Unpause is annoying with the iPad.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #8 on: May 06, 2012, 12:28:18 AM »
What do you think to this? Would this work?

Code: [Select]
-- TellPlayer = 0

-- while TellPlayer == 0 do

-- coroutine.yield()
-- end

-- if TellPlayer == 1 then

-- Message("-Dark Days-~Things have changed little seedlings", true, 1.0, "Top")
-- WaitDialog()
-- end

-- if TellPlayer == 2 then

-- Message("The Mother Tree failed to take you places I can~But first, you need to be ready", true, 1.0, "Bottom")
-- WaitDialog()
-- end

but then again, how would I make TellPlayer = 1 then when 1's done change it to TellPlayer = 2

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Need help please with Messages
« Reply #9 on: May 06, 2012, 01:02:12 AM »
Do you have ScreenDraw() and LevelDraw() on the iPad?

Just write this into your map:
Code: [Select]
function ScreenDraw()
DrawSprite(1, 200, 200, 1,1,1,1, 50)
end

And tell me the results(don't worry, it's related to the topic) :)

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #10 on: May 06, 2012, 01:16:24 AM »
I've added it in the end after LevelLogic end yes?

And it doesn't do anything, what am I looking for?

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #11 on: May 06, 2012, 01:41:51 AM »
Aino, Check this out, I did some searching through the support.lua in the Eufloria.app file and found this

Code: [Select]
function WaitReal(t)
t = t + GetRealTime()
while GetRealTime() < t do
CheckConditions()
coroutine.yield()
end
end

So is that saying if I used WaitReal(1) like this...

Code: [Select]
if TellPlayer == 1 then
Message("-Dark Days-~Things have changed little seedlings", true, 1.0, "Top")
        WaitDialog()
WaitReal(1)
TellPlayer = 2
end

Then it would mean that after the message is done, it will wait 1 second (where the game time is in) and then TellPlayer = 1 will change to TellPlayer = 2

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #12 on: May 06, 2012, 01:43:50 AM »
It doesn't matter what it says above there, it still doesn't work haha.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Need help please with Messages
« Reply #13 on: May 06, 2012, 02:45:44 AM »
Since ScreenDraw doesn't work, I got no idea what to do :(

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #14 on: May 06, 2012, 02:59:08 AM »
Well what I've done, is decided to do it by GameTime, and I'll have a code ready for you before you reply :P haha!

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #15 on: May 06, 2012, 03:10:41 AM »
This is what I'm using now...

Code: [Select]
Timer = GetGameTime() + 0
while GetGameTime() < Timer do
coroutine.yield()
end
MessageA()

Timer = GetGameTime() + 7
while GetGameTime() < Timer do
coroutine.yield()
end
MessageB()

Timer = GetGameTime() + 9
while GetGameTime() < Timer do
coroutine.yield()
end
MessageC()

Timer = GetGameTime() + 11
while GetGameTime() < Timer do
coroutine.yield()
end
MessageD()

Timer = GetGameTime() + 13
while GetGameTime() < Timer do
coroutine.yield()
end
MessageE()



like always, I can't do something -.-, can you tell me why this isn't working?

Code: [Select]
if GetAsteroid(1).NumDysonTrees == 4 then
MessageF()
end

It doesn't crash my game or anything, I can play it but when Asteroid 1 gets 4 DysonTrees the messagef doesn't pop up

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Need help please with Messages
« Reply #16 on: May 06, 2012, 03:17:08 AM »
Having chained while loops isn't a good idea. Try keep everything in one while loop and use if statements, that way multiple things can happen :)

Also, the stopper might be because something crashed the LevelLogic, it tends to get crappy after a fail that isn't lethal to the game. Although this might be it, don't waste your time searching for fault too much as we don't really know what we're digging in. Maybe you should take a closer look to what WaitDialog() really does? Try make an asteroid get a lot of seedlings after the WaitDialog function in any message and see when things happen(before/after skipping message)

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #17 on: May 06, 2012, 03:38:19 AM »
So is this what your saying?

Code: [Select]
Timer = GetGameTime() + 0
end
MessageA()

Timer = GetGameTime() + 7
end
MessageB()

Timer = GetGameTime() + 9
end
MessageC()

Timer = GetGameTime() + 11
end
MessageD()

Timer = GetGameTime() + 13
end
MessageE()

while GetGameTime() < Timer do
coroutine.yield()
end

Also this is WaitDialog()

Code: [Select]
function WaitDialog()
while GetDialogActive() do
coroutine.yield()
end
end

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Need help please with Messages
« Reply #18 on: May 06, 2012, 04:11:35 AM »
Code: [Select]
message = 0;
while GameRunning() do

if (GetDialogActive() ~= true) then
if (message == 0) then
MessageA();
elseif (message == 1) then
MessageB();
end
else
if (message < 2) then
message = message + 1;
end
end
end

Hope it works :)

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #19 on: May 06, 2012, 04:24:56 AM »
I was hoping it did, but it didn't do anything when I loaded the game up?

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #20 on: May 06, 2012, 10:43:17 PM »
Hey Aino, this is how the messages are run in other levels of the iPad, so I decided to use it, and it's worked for messages...

Code: [Select]
if IsiOS() then
SelectionClear()
WaitReal(2)
SetLevelDim(true)
Message("01_DARK", true, 1.0, "Top")
WaitMessage(true)
SetLevelDim(false)
SetCameraPosition(-800,0)
SetCameraZoom(1000)
else
MessageBox("01_01")
WaitDialog()
end

--
-- Mission text
--
if IsiOS() then
WaitReal(2)
Message("01_SPRAWL", true, 1.0, "Left")
WaitMessage(true)
SetEnemyInfoAvailable(true)
SetCoreInfoAvailable(true)
SetAttribsInfoAvailable(true)
SetTreeInfoAvailable(true)
else
MessageBox("01_02")
WaitDialog()
end

if IsiOS() then
WaitReal(2)
Message("01_SEEDLING", true, 1.0, "Left")
WaitMessage(true)
SetCameraZoom(2000)
SetCameraPosition(300,0)
else
MessageBox("01_02")
WaitDialog()
end

if IsiOS() then
SetDysonTreeButtonAvailable(true)
WaitReal(2)
Message("01_DYSON", true, 1.0, "Right")
WaitMessage(true)
else
MessageBox("01_02")
WaitDialog()
end

For example were it says       Message("01_DYSON", true, 1.0, "Right")

it's refering to another file called lang.csv which is full of text, which literally relates to all the text, I could change every text I wanted to.

Code: [Select]
01_DYSON Click the Asteroid,~Plant four Dyson Trees.

Taken from the land.csv file

The only problem now I face is that I wanted the user to plant 4 dyson tree's and then when the 4 dyson trees are planted a message pops up

e.g
Code: [Select]
Message("01_DYSON", true, 1.0, "Right")
Do i need to add something at the start of LevelLogic() like GetEmpire(1):UpdateNumDysonTrees

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #21 on: May 07, 2012, 12:27:49 AM »
Just figured it out -.- so annoying how easy it is to figure it out, but it took a while...

Code: [Select]
while GetEmpire(1).NumTrees < 1 do
coroutine.yield()
end

if IsiOS() then
SetSpeedSwitchAvailable(true)
WaitReal(2)
Message("01_SPEED", true, 1.0, "Right")
WaitMessage(true)
end

Never knew the while part had to be before the bottom bit -.-

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Need help please with Messages
« Reply #22 on: May 07, 2012, 09:19:42 PM »
If you use those texts, the changes will only be visible for you, you should keep the text as you had it in the messageboxes :)

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Need help please with Messages
« Reply #23 on: May 07, 2012, 09:37:36 PM »
Hey Aino, I changed it yesterday, because it was getting annoying for me so it now looks like...

Code: [Select]
if IsiOS() then -- This asteroid
WaitReal(0)
Message("This Unknown Asteroid...", true, 1.0, "Right")
WaitMessage(true)
else
MessageBox("01_01")
WaitDialog()
end

My previous approach for the iPad users was to upload the lang.csv and that...