+charlenni Posted February 14, 2009 Share Posted February 14, 2009 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 Quote Link to comment
matejcik Posted February 14, 2009 Share Posted February 14, 2009 so where's your OnGetInput script? Quote Link to comment
matejcik Posted February 14, 2009 Share Posted February 14, 2009 function zinputLang:OnGetInput(input) translateInput = input -- your script goes here end 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. Quote Link to comment
+charlenni Posted February 14, 2009 Author Share Posted February 14, 2009 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) Quote Link to comment
Ranger Fox Posted February 19, 2009 Share Posted February 19, 2009 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. Quote Link to comment
Recommended Posts
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.