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

0 Members and 1 Guest are viewing this topic.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
  • First iOS modder :D
Need help please with Messages
« on: May 05, 2012, 03: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: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Need help please with Messages
« Reply #1 on: May 05, 2012, 10:29:34 AM »
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
  • First iOS modder :D
Re: Need help please with Messages
« Reply #2 on: May 05, 2012, 12: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
  • First iOS modder :D
Re: Need help please with Messages
« Reply #3 on: May 05, 2012, 01: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: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Need help please with Messages
« Reply #4 on: May 05, 2012, 02: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, 02:31:29 PM by Aino »

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
  • First iOS modder :D
Re: Need help please with Messages
« Reply #5 on: May 05, 2012, 03: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: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Need help please with Messages
« Reply #6 on: May 05, 2012, 04:10:58 PM »
What happened when you used pause/unpause?

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
  • First iOS modder :D
Re: Need help please with Messages
« Reply #7 on: May 05, 2012, 04:24:21 PM »
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
  • First iOS modder :D
Re: Need help please with Messages
« Reply #8 on: May 05, 2012, 04:28:18 PM »
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: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Need help please with Messages
« Reply #9 on: May 05, 2012, 05:02:12 PM »
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
  • First iOS modder :D
Re: Need help please with Messages
« Reply #10 on: May 05, 2012, 05:16:24 PM »
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
  • First iOS modder :D
Re: Need help please with Messages
« Reply #11 on: May 05, 2012, 05:41:51 PM »
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
  • First iOS modder :D
Re: Need help please with Messages
« Reply #12 on: May 05, 2012, 05:43:50 PM »
It doesn't matter what it says above there, it still doesn't work haha.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Need help please with Messages
« Reply #13 on: May 05, 2012, 06:45:44 PM »
Since ScreenDraw doesn't work, I got no idea what to do :(

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
  • First iOS modder :D
Re: Need help please with Messages
« Reply #14 on: May 05, 2012, 06:59:08 PM »
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!