Jump to content

Create input by code problem


charlenni

Recommended Posts

Hello,

 

I use the following code to create an input by code. It works perfect, all choices will be shown on the screen, but I didn't get the result. The varaible is allways nil.

 

	translateInput = ""
parCartridge.ZVariables.translateInput = ""
buildervar.translateInput = {}
buildervar.translateInput.Id ="9cb725df-376d-4334-a46b-cae1d4eff1fc"
buildervar.translateInput.Name = "translateInput"
buildervar.translateInput.Type = "String"
buildervar.translateInput.Data=[[]]
buildervar.translateInput.Description=[[]]
zinputLang = Wherigo.ZInput(parCartridge)
zinputLang.Id="89a0db31-3ec5-43e3-9845-831bc451a86c"
zinputLang.Name="Translate"
zinputLang.Description=[[]]
zinputLang.Visible=true
zinputLang.Choices = {"Choice1","Choice2"}
zinputLang.InputType="MultipleChoice"
zinputLang.InputVariableId="9cb725df-376d-4334-a46b-cae1d4eff1fc"
zinputLang.Text=[[]]
Wherigo.GetInput(zinputLang)
if translateInput ~= nil then
  print(translateInput)
end

 

Any ideas?

 

Best regards.

Dirk

Link to comment

Thanks a lot for your help. Forgot to create a function ;-)

 

this is what builder does for every input, the variable assignment via "buildervar" is not magic.

i wonder why GS chose this approach, why not just make the "input" parameter accessible directly. oh well.

I learnd, that you need no buildvar for an input. You need only the zinput and the OnGetInput method. So, if you want create an input by code, all you need is

 

	zinputLang = Wherigo.ZInput(parCartridge)
zinputLang.Id="89a0db31-3ec5-43e3-9845-831bc451a86c"
zinputLang.Name="Translate"
zinputLang.Description=[[]]
zinputLang.Visible=true
zinputLang.Choices = {"Choice1","Choice2"}
zinputLang.InputType="MultipleChoice"
zinputLang.Text=[[]]
zinputLang.OnGetInput = function(self,input) translateLang = input end
Wherigo.GetInput(zinputLang)

Link to comment

Putting your variable inside buildervar will (well, should) guarantee its value saves and restores when the player saves and load a cartridge save file. Declaring and using variables outside buildervar scope will not exhibit this behavior.

 

You might want to make use of buildervar if you expect players to save and resume your cartridge and you need a value.

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...