Jump to content

Can I display messages in the Author Script


Tequila

Recommended Posts

And if so, what does the command look like?

 

I would like to take my "emulator check", player name processing and a bunch of date/time checks and create a single Author Script to handle all of that.

 

I need to be able to display messages such as "You can't play this cartridge in the Emulator"

 

Is there a way to do that? Would really appreciate a code example.

 

Thanks.

Link to comment

And if so, what does the command look like?

 

I would like to take my "emulator check", player name processing and a bunch of date/time checks and create a single Author Script to handle all of that.

 

I need to be able to display messages such as "You can't play this cartridge in the Emulator"

 

Is there a way to do that? Would really appreciate a code example.

 

Thanks.

 

Author Script is identical to normal script, if you edit the lua file direct, you can move entire functions in there, however you would not then be able to access them through the normal builder interface, only through the author script.

 

When I started, I would tend to use the builder to create the basics of something, then edit the lua file to see what the syntax was and copy out the bits of interest i.e. in this example you want to display a message, so if you create a message with some text; a message box with a picture; a message box with a button; etc, you can see the differences and how each is done.

 

Refering back to the time question, if you paste the following code into the author script, then that will check the date is the 9th May 2009 and your not using the emulator, will do one thing otherwise do something else (in this case display two different messages). Just keep adding the ANDs for your other checks.

 

theCurrentTime = os.date('!*t')

if theCurrentTime.year == 2009 and month == 5 and day == 9 and Player.Name ~= "Builder" then

Wherigo.MessageBox{Text=[[its OK to play today]],Buttons={"OK",},}

else

Wherigo.MessageBox{Text=[[You cant play this cartridge in the Emulator]],Buttons={"OK",},}

end

 

After the second MessageBox, but before the end, you could put the code to end the cartridge, but I forget what that is just at the moment.

Note: identical comparison is a double equals; not equal to is a ~=

 

Hope thats what your asking for :laughing:

Link to comment

It is what I am looking for but it does not seem to work. If I paste that into Author Script and run it, nothing happens. I even stripped it down to just a message box and still no message box.

 

Would it be possible for you to post a source file here that works?

Link to comment

Here is an example .lua file. Appologies for a few missing bits of code in the previous example, but now fixed and tested :anicute: This can be viewed and editited in the normal builder, just highlight the date values and change them in the window that appears when you double click on When a cartridge is started

 

require "Wherigo"

ZonePoint = Wherigo.ZonePoint

Distance = Wherigo.Distance

Player = Wherigo.Player

 

-- #Author Directives Go Here# --

-- #End Author Directives# --

 

cartcheck = Wherigo.ZCartridge()

 

-- MessageBox Callback Functions Table used by the Builder --

cartcheck.MsgBoxCBFuncs = {}

 

-- Cartridge Info --

cartcheck.Id="8eacdb25-4bea-4dac-bb08-9dcefd610c60"

cartcheck.Name="check"

cartcheck.Description=[[]]

cartcheck.Visible=true

cartcheck.Activity="TourGuide"

cartcheck.StartingLocationDescription=[[]]

cartcheck.StartingLocation = ZonePoint(51,-2,0)

cartcheck.Version=""

cartcheck.Company=""

cartcheck.Author=""

cartcheck.BuilderVersion="2.0.5129.5086"

cartcheck.CreateDate="5/10/2009 7:24:58 AM"

cartcheck.PublishDate="1/1/0001 12:00:00 AM"

cartcheck.UpdateDate="5/10/2009 7:31:18 AM"

cartcheck.LastPlayedDate="1/1/0001 12:00:00 AM"

cartcheck.TargetDevice="PocketPC"

cartcheck.TargetDeviceVersion="0"

cartcheck.StateId="1"

cartcheck.CountryId="2"

cartcheck.Complete=false

cartcheck.UseLogging=false

 

-- Zones --

 

-- Characters --

 

-- Items --

 

-- Tasks --

 

-- Cartridge Variables --

-- Builder Variables (to be read by the builder only) --

buildervar = {}

-- ZTimers --

 

-- Inputs --

 

--

-- Events/Conditions/Actions --

--

 

-------------------------------------------------------------------------------

------Builder Generated functions, Do not Edit, this will be overwritten------

-------------------------------------------------------------------------------

 

function cartcheck:OnStart()

-- #GroupDescription=test --

theCurrentTime = os.date('!*t')

if theCurrentTime.year == 2009 and theCurrentTime.month == 5 and theCurrentTime.day == 10 and Player.Name ~= "Me" then

Wherigo.MessageBox{Text=[[its OK to play today]],Buttons={"OK",},}

else

Wherigo.MessageBox{Text=[[You cant play this cartridge in the Emulator]],Buttons={"OK",},}

end

-- #Comment=test Comment --

 

end

------End Builder Generated functions, Do not Edit, this will be overwritten------

-------------------------------------------------------------------------------

------Builder Generated callbacks, Do not Edit, this will be overwritten------

-------------------------------------------------------------------------------

--#LASTCALLBACKKEY=0#--

------End Builder Generated callbacks, Do not Edit, this will be overwritten------

-- #Author Functions Go Here# --

-- #End Author Functions# --

-- Nothing after this line --

return cartcheck

 

:laughing::anibad::blink:

 

 

 

Alternatively, you can move the function to the author code and used the author view

 

:anicute::anicute::anicute:

require "Wherigo"

ZonePoint = Wherigo.ZonePoint

Distance = Wherigo.Distance

Player = Wherigo.Player

 

-- #Author Directives Go Here# --

-- #End Author Directives# --

 

cartcheck = Wherigo.ZCartridge()

 

-- MessageBox Callback Functions Table used by the Builder --

cartcheck.MsgBoxCBFuncs = {}

 

-- Cartridge Info --

cartcheck.Id="8eacdb25-4bea-4dac-bb08-9dcefd610c60"

cartcheck.Name="check"

cartcheck.Description=[[]]

cartcheck.Visible=true

cartcheck.Activity="TourGuide"

cartcheck.StartingLocationDescription=[[]]

cartcheck.StartingLocation = ZonePoint(51,-2,0)

cartcheck.Version=""

cartcheck.Company=""

cartcheck.Author=""

cartcheck.BuilderVersion="2.0.5129.5086"

cartcheck.CreateDate="5/10/2009 7:24:58 AM"

cartcheck.PublishDate="1/1/0001 12:00:00 AM"

cartcheck.UpdateDate="5/10/2009 7:31:18 AM"

cartcheck.LastPlayedDate="1/1/0001 12:00:00 AM"

cartcheck.TargetDevice="PocketPC"

cartcheck.TargetDeviceVersion="0"

cartcheck.StateId="1"

cartcheck.CountryId="2"

cartcheck.Complete=false

cartcheck.UseLogging=false

 

-- Zones --

 

-- Characters --

 

-- Items --

 

-- Tasks --

 

-- Cartridge Variables --

-- Builder Variables (to be read by the builder only) --

buildervar = {}

-- ZTimers --

 

-- Inputs --

 

--

-- Events/Conditions/Actions --

--

 

-------------------------------------------------------------------------------

------Builder Generated functions, Do not Edit, this will be overwritten------

-------------------------------------------------------------------------------

 

------End Builder Generated functions, Do not Edit, this will be overwritten------

-------------------------------------------------------------------------------

------Builder Generated callbacks, Do not Edit, this will be overwritten------

-------------------------------------------------------------------------------

--#LASTCALLBACKKEY=0#--

------End Builder Generated callbacks, Do not Edit, this will be overwritten------

-- #Author Functions Go Here# --

function cartcheck:OnStart()

-- #GroupDescription=test --

theCurrentTime = os.date('!*t')

if theCurrentTime.year == 2009 and theCurrentTime.month == 5 and theCurrentTime.day == 10 and Player.Name ~= "Me" then

Wherigo.MessageBox{Text=[[its OK to play today]],Buttons={"OK",},}

else

Wherigo.MessageBox{Text=[[You cant play this cartridge in the Emulator]],Buttons={"OK",},}

end

end

 

-- #End Author Functions# --

-- Nothing after this line --

return cartcheck

:D:anicute::anicute:

 

or, you could put the new code in a function and call it from a different function, but its still going to be red in the normal builder and confuse it slightly.

Edited by a_snail
Link to comment

To answer R/F's question, I was able to finally get the first sample working by putting the code in a function. However, I had to use the OnStart for the cartridge which meant I could not have an OnStart function in the normal builder code.

 

I got both of the above samples to work the same way.

 

While this works, it is not quite what I was hoping to be able to use.

 

I was hoping to have a bunch of code in the Author Script that I could cut/paste into every cartridge that I develop without having to rewrite/modify the code each time. In the above case, the function OnStart has to be modified to account for the different cartridge name. Perhaps this is the best I can get.

 

As you can no doubt see, my programming skills are pretty limited. :laughing:

 

Back to R/F's comment: If I call the function something other than OnStart, how would I call it from the Builder?

 

Thanks for all your help AND patience. :anibad:

Edited by Tequila
Link to comment

To answer R/F's question, I was able to finally get the first sample working by putting the code in a function. However, I had to use the OnStart for the cartridge which meant I could not have an OnStart function in the normal builder code.

 

I got both of the above samples to work the same way.

 

While this works, it is not quite what I was hoping to be able to use.

 

I was hoping to have a bunch of code in the Author Script that I could cut/paste into every cartridge that I develop without having to rewrite/modify the code each time. In the above case, the function OnStart has to be modified to account for the different cartridge name. Perhaps this is the best I can get.

 

As you can no doubt see, my programming skills are pretty limited. :D

 

Back to R/F's comment: If I call the function something other than OnStart, how would I call it from the Builder?

 

Thanks for all your help AND patience. :anicute:

 

 

The example below might be what your after. If you want to just copy it to a load of cartridges, what you would do is copy the function in the author code, and then wherever you want to do a check, add in the line:

CheckCartridgeIsOKToPlay()

 

In the example below I've put it in OnStart, but it can go anywhere. The problem you are going to have is that the builder will not like any function with the CheckCartridgeIsOKToPlay() in it because its not something it knows about, so it will show it in author code. The best way to get round this I've found is to put it in a out of the way bit of Wherigo i.e the only thing that function is going to do is call CheckCartridgeIsOKToPlay e.g.

1. In response to a message box button been pressed (eg. as part of the welcome message)

2. as part of a timer event, although be careful about this one in case other things are happening and canel your message.

 

Example Lua:

 

:laughing::anibad::blink:

require "Wherigo"

ZonePoint = Wherigo.ZonePoint

Distance = Wherigo.Distance

Player = Wherigo.Player

 

-- #Author Directives Go Here# --

-- #End Author Directives# --

 

cartcheck = Wherigo.ZCartridge()

 

-- MessageBox Callback Functions Table used by the Builder --

cartcheck.MsgBoxCBFuncs = {}

 

-- Cartridge Info --

cartcheck.Id="8eacdb25-4bea-4dac-bb08-9dcefd610c60"

cartcheck.Name="check"

cartcheck.Description=[[]]

cartcheck.Visible=true

cartcheck.Activity="TourGuide"

cartcheck.StartingLocationDescription=[[]]

cartcheck.StartingLocation = ZonePoint(51,-2,0)

cartcheck.Version=""

cartcheck.Company=""

cartcheck.Author=""

cartcheck.BuilderVersion="2.0.5129.5086"

cartcheck.CreateDate="5/10/2009 7:24:58 AM"

cartcheck.PublishDate="1/1/0001 12:00:00 AM"

cartcheck.UpdateDate="5/10/2009 12:28:07 PM"

cartcheck.LastPlayedDate="1/1/0001 12:00:00 AM"

cartcheck.TargetDevice="PocketPC"

cartcheck.TargetDeviceVersion="0"

cartcheck.StateId="1"

cartcheck.CountryId="2"

cartcheck.Complete=false

cartcheck.UseLogging=false

 

-- Zones --

 

-- Characters --

 

-- Items --

 

-- Tasks --

 

-- Cartridge Variables --

-- Builder Variables (to be read by the builder only) --

buildervar = {}

-- ZTimers --

 

-- Inputs --

 

--

-- Events/Conditions/Actions --

--

 

-------------------------------------------------------------------------------

------Builder Generated functions, Do not Edit, this will be overwritten------

-------------------------------------------------------------------------------

 

function cartcheck:OnStart()

CheckCartridgeIsOKToPlay()

 

end

------End Builder Generated functions, Do not Edit, this will be overwritten------

-------------------------------------------------------------------------------

------Builder Generated callbacks, Do not Edit, this will be overwritten------

-------------------------------------------------------------------------------

--#LASTCALLBACKKEY=0#--

------End Builder Generated callbacks, Do not Edit, this will be overwritten------

-- #Author Functions Go Here# --

 

function CheckCartridgeIsOKToPlay()

-- #GroupDescription=test --

theCurrentTime = os.date('!*t')

if theCurrentTime.year == 2009 and theCurrentTime.month == 5 and theCurrentTime.day == 10 and Player.Name ~= "Me" then

Wherigo.MessageBox{Text=[[its OK to play today]],Buttons={"OK",},}

else

Wherigo.MessageBox{Text=[[You cant play this cartridge in the Emulator]],Buttons={"OK",},}

end

-- #Comment=test Comment --

end

-- #End Author Functions# --

-- Nothing after this line --

return cartcheck

 

:anicute::anicute::anicute:

Link to comment

Thank you. That is exactly what I want.

 

I assume you created the CheckCartridgeIsOKToPlay() call in the OnStart function with a text editor and not the Builder. Is that correct?

 

Also, once I open the source in the Builder, I am able to open the OnStart code (it appears in red). Can I add code to it in the Builder?

 

Thanks gain.

Link to comment

Thank you. That is exactly what I want.

 

I assume you created the CheckCartridgeIsOKToPlay() call in the OnStart function with a text editor and not the Builder. Is that correct?

 

Also, once I open the source in the Builder, I am able to open the OnStart code (it appears in red). Can I add code to it in the Builder?

 

Thanks gain.

 

Yes, I did use a text editor to add in the function into OnStart (I have to confess, I use the text editor for 95% of my building these days). Once the call to the function is in place, you will only be able to modify the source code directly (although you can do that in the builder), the builder will no longer help you construct the code, which is why I suggested putting that sort of call in a MessageBox button function earlier. Let me know if you need a demo of that.

Link to comment

Thank you. That is exactly what I want.

 

I assume you created the CheckCartridgeIsOKToPlay() call in the OnStart function with a text editor and not the Builder. Is that correct?

 

Also, once I open the source in the Builder, I am able to open the OnStart code (it appears in red). Can I add code to it in the Builder?

 

Thanks gain.

 

Yes, I did use a text editor to add in the function into OnStart (I have to confess, I use the text editor for 95% of my building these days). Once the call to the function is in place, you will only be able to modify the source code directly (although you can do that in the builder), the builder will no longer help you construct the code, which is why I suggested putting that sort of call in a MessageBox button function earlier. Let me know if you need a demo of that.

 

Yes, please post a demo. Demos are very good learning tools.

 

One of the first emails I got from Ranger Fox suggested that I would reach a point where I would drift away from the Builder and start developing code in the text editor. :anitongue:

 

Not only is R/F one helluva Wherigo illuminati, he is also a bit of a prophet. LOL

Link to comment

One of the first emails I got from Ranger Fox suggested that I would reach a point where I would drift away from the Builder and start developing code in the text editor. :anitongue:

 

Not only is R/F one helluva Wherigo illuminati, he is also a bit of a prophet. LOL

One of the design goals of Earwigo was to allow you to include arbitrary Lua code inline without having to abandon the point-and-click builder for the easy bits. Using a text editor is fine for code but not so much fun for regular data declarations.

Link to comment

One of the first emails I got from Ranger Fox suggested that I would reach a point where I would drift away from the Builder and start developing code in the text editor. :anitongue:

 

Not only is R/F one helluva Wherigo illuminati, he is also a bit of a prophet. LOL

One of the design goals of Earwigo was to allow you to include arbitrary Lua code inline without having to abandon the point-and-click builder for the easy bits. Using a text editor is fine for code but not so much fun for regular data declarations.

 

I think its the cut and paste I like so much with the text editor :) and the fact that I can save the lua file in the text editor, load and run the script in the builder, find its taken out the builder or emulator and just undo the changes with out loosing all my work.

Link to comment

a_snail,

 

It took me all day to realize what you meant about putting the Author Script call in an obscure Message Box so that I wouldn't limit the ability of the Builder to help me create code.

 

If I put the call in the OnStart function I can't use the Builder to develop more OnStart code. But, if I put it in a simple "Welcome to my Cartridge" message box, I can still use the Builder everywhere else.

 

Takes awhile for things to sink in sometimes. :anitongue:

 

Thanks for all your great help.

 

Tequila

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...