Jump to content

Variables


Graham_K

Recommended Posts

Can someone tell me here if it is possible to display the current value of a variable in a message or dialog to the user?

Yes. In the Groundspeak Builder, it's a bit clunky. You need to put this in your dialog:

 

You are holding ]] .. variablename .. [[ items

This works (just) because the Builder will put [[ at the start and ]] at the end of your dialog contents, to make a complete Lua string. Your ]] and [[ interrupt this, and the .. variablename .. bit inserts the value of the variable.

 

In Earwigo, you can just use ~~variablename~~ at any point in any string in the system.

 

Urwigo presumably has something similar.

Link to comment

Furthermore, can someone also tell me if, using the Wherigo builder, whether it is possible to do background processing arithmetic calculations on variables within a Wherigo cartridge?

 

Eg. Var2 = Var1 / 3600.

 

Var3 = Var4 - Var2.

 

Many Thanks

Graham

Only if you can put it into an Author Script function. The Groundspeak Builder does not have a complete Lua parser, so if you put anything which it doesn't know about (which is, more or less, anything which it can't generate itself) in an event handler statement, it will crash on opening the Lua file. The Author Script section of the file is not parsed by the Builder and so can contain anything you like (but if it has Lua syntax errors, it will of course crash the compiler).

 

The other problem with Author Script functions is that (AFAIK; I'd love to find out if there is indeed a way), there is no legitimate, supported way to call them. The only way I've been able to get "into" the Author Script code is to create one of the event handler functions for the cartridge or another object in the Author Script section, using the same name and syntax which the Builder would use. For example, instead of creating a "When a cartridge is started" handler in the interactive, point-and-click part of the Builder, you could create an Author Script function called (exactly) CartYourCartNameGoesHere:onStart ().

 

If you want to be able to mix point-and-click construction of objects with hand-written code, you either need the patience of a saint, or another builder. Earwigo lets you write an arbitrary Lua statement at any point in any function. Urwigo probably has something similar.

Edited by sTeamTraen
Link to comment

Is there a list of ~~variable names?~~

A dedicated list of what each one does in Earwigo ?

 

In Urwigo you just grab, and pull from the menu on the left side.

Like the players name , device they are using, date of birth, # kids in their uncles brothers family, color of socks in their clothes pile on the dresser ...

 

For example on a google search, I found we can use our own variables. But specific functions say... like the "completion code" are sacred.

The ones from our cartridge, are selected by finding the LUA code variable name, I just used the wiki page as an example.

 

~~Player.CompletionCode~~

~~WWB_CompletionCode15~~

Or somewhere else I found on the google,

At first I thought it would have been CompletionCodeIS, is looks so much like 15 pending on the font, and glasses used !

setValue:item:wallet:Description => Constant:"Your wallet contains ~~var_money~~ coins."

I tried this ~~Player.name~~ but the cartridge just crashed.

not sure if I should try name with a capital name as in ~~Player.Name~~ or perhaps ~~WWB_Player.name~~ or something like that ?

 

ERROR
.../a313f5fd-9d46-4ff0-9d13-982c6e0c863a/_cartridge.enc:1396: attempt to concatenate global 'WWB_Playername15' (a nil value)

ERROR
.../f0e3d50c-498c-4515-8681-f3058059a192/_cartridge.enc:1396: attempt to concatenate global 'WWB_Playername' (a nil value)

~~WWB_Playername~~

ERROR
.../22ecd559-b81c-48e1-98e3-9ad236381829/_cartridge.enc:1396: attempt to concatenate global 'WWB_PlayerName' (a nil value)

Edited by K-and-K
additional info (error)
Link to comment

https://www.lua.org/manual/5.1/

image.png.068851739375dccb27cd36a051c6d199.png

(English)

- Some of the links don't work anymore.

image.png.37aad4be6c64fd00ad4472d1e34a2097.png

 

Might have to go back to Urwigo...

ERROR
.../170d2b1e-b16c-442f-8d83-c907e5fe1890/_cartridge.enc:1396: attempt to concatenate global 'PlayerName' (a nil value)

Whoo .. Hoo I found it !

 

ERROR
.../170d2b1e-b16c-442f-8d83-c907e5fe1890/_cartridge.enc:1396: attempt to concatenate global 'PlayerName' (a nil value)

 

was changed to  : ~~Player.Name~~

 

Earwigo

Members in your group: 0

image.png.c402388566e3f0a36ae83eb4db739aa9.png

 

Need to put a bailing bucket in the photo !

... okay that's two coded I know !

 

PortBruceProvincialPark(347).gwc

 

.. so much easier to do in Urwigo, all this uploading and waiting for the server !

 

image.png.f30d18f3f7ebc0e498416f3a78c34fef.pngimage.png.a801f7539290f3fba3daf67240458aee.png

Edited by K-and-K
Link to comment

Okay today I am working with ...

ERROR
.../08b93e71-3421-4f84-b10f-89c1db748afa/_cartridge.enc:1434: attempt to concatenate field 'Count' (a nil value)

Oh what could it be this time !

 

~~Player.Name~~ ' s Geobag       Inventory : ~~Player.Inventory.Count~~ Does not like !

~~Player.Name~~ ' s Geobag       Inventory : ~~Player.InventoryCount~~

 

ERROR
.../15044be4-41df-42ab-b301-14e4fd8d6d83/_cartridge.enc:1434: attempt to concatenate field 'InventoryCount' (a nil value)

Inventory : ~~Player.Inventory~~

ERROR
.../df04d090-5ff1-4a4e-be0a-c6b4aa96e90e/_cartridge.enc:1434: attempt to concatenate field 'Inventory' (a table value)

Grr... (but I think it may work ?)

 

PortBruceProvincialPark(358).gwc

ERROR
.../d438344f-3590-4c85-ace5-91d3ab7cebd8/_cartridge.enc:1434: attempt to concatenate field 'Inventorycount' (a nil value)

So it's not Capitals. It's not small letters, the period in between changes to a different instruction all together ?

I know Player.Name works !

It recognizes Player.Inventory ; but not Inventorycount or InventoryCount

I'm not going to try ~~Player.InventoryCount~~ with a small letter ~~Player.Inventorycount~~

 

... So what is next ?

 

Using Urwigo ...

 

~~Player.CompletionCode~~

~~WWB_CompletionCode15~~

And what WIKI suggested I thought I covered all the items. I have one more thought , the error came back different then the rest...

 

field 'Inventory' (a table value)

 

I'm thinking Urwigo and/or , Nand/Nor ... may be doing some Lua code in the background and that Urwigo is as it is has more structure to it than Earwigo has ?

 

Not going to try ~~WWB_ ; at this point, probably just going to give up.

 

 

image.png.3784fd603364ae4753cfa4e37d931cb3.png

 

Tue May 25 10:20:54 2021 ERROR [Engine]: CartridgeCommand(): Lua method call failed. .../urwigo-src-732c9a06-a634-4a85-8981-f3a60af4235a.lua:291: attempt to get length of field 'Inventory' (a nil value)
Tue May 25 10:20:54 2021 CARTRIDGE [Lua]: 0.00000|0.00000|0.000|0.000|ZCartridge:Start - Downloaded Tue May 25 11:20:40 2021
Tue May 25 10:20:54 2021 CARTRIDGE [Lua]: 0.00000|0.00000|0.000|0.000|Engine Version 2.11, Player Name: Urwigo, Device ID: Desktop

 

image.png.cefc4b5b3329206c7222a682eec33fc8.png  image.png.309efce2160398d45ac6646cd4e84c2c.png

 

Inventory is only 1, I could add more, ... I did but added images to wrong qoute, oops see previous message, my bad.

But simply to prove a point Urwigo must be implementing all the code for variable tables in the background with Lua instructions .

All I had to do is drag the item from the left over to the right , took 30 seconds.

 

 

 

Edited by K-and-K
Urwigo image added
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...