Jump to content

Calling a variable in a message box


wizardmirth

Recommended Posts

How can you call a variable in a message box? The error message I keep getting for the "float" line....

mismatched input 'float' expecting RPAREN
required (...)+ loop did not match anything at input ')'

Relevant part of the script...

Int IButton = MyModMSG.Show(float afArg1) ;;<<----error?
	If iButton == 0
		Return StoreItems()
	EndIf

Previously (on an oldrim mod) I was able to get it to compile without any errors although I still did not see anything but 0's listed in the messagebox where there should have been other numbers. Now I just get the compile error and I am declaring everything. My quick fix is to remove the "float afArg1" and it will compile but I will not get any correct variables called in the message box.

 

Also I am using "%.0f" in my message box for each variable, up to 10 at a time (as per something I read somewhere).

Link to comment
Share on other sites

It compiles but I still only get a "0" in the message box. There should be a "1" there based on my current character's inventory count at the time of testing.

 

I have tried various ways of doing this, including calling the float at the top of the script as well as within the following Function box.

 

Is this somehow because I need to show in the message box in the Activation block for the object? I'm doing this because I don't want to show the message box unless there is at least one of the items in the player's inventory.

Link to comment
Share on other sites

Example:

 

Message Form

 

Body text:

Current number of Itmes: %.0f

 

buttons

0 - OK

1 - Cancel

(both close the menu for this example..)

 

The code:

Message property MyMessage auto

Float fNumItems
 
Event SomeEvent
fNumItems = some code that returns the number of items and stores it to this variable
EndEvent
 
Function MyMenu(Int aiButton = 0)
    aiButton = MyMessage.Show(fNumItems)
EndFunction

This is an example only, code is thrown together and not compile ready. This is just to show proper syntax on passing variables in a message.

Edited by Lisselli
Link to comment
Share on other sites

Okay thank you, but I'm still not getting the correct value returned. I'm wondering now if my FormList call in the same script is any problem. This formlist part works fine, when checking to see if player has one of the form list items and then opens the message box in question. The only problem is after that, where I can't get a correct value in the message box. I am also declaring each of the items to be counted as ObjectReferences, as well as of course declaring the FormList itself and the Message.

 

Here's my workflow for the script, attached to a container (the failed part is in red):

  1. check a form list to see if 1 or more items is present in player inventory
  2. if so open the message box
  3. if not then just cancel (container opens normally)
  4. message box appears lists the player inventory counts for (in this case) 9 items and asks player to sort all the items found from the lists into the container (Yes, No)
  5. if YES, sorts
  6. of NO, nothing (container opens normally)

Everything compiles fine, I just can't get a correct result in the message box. No matter what I try it always defaults to "0" for all 9 items.

Edited by wizardmirth
Link to comment
Share on other sites

By any chance are you using GetItemCount to obtain this number? Because I've heard it is quite buggy:

  • If the argument akItem is a keyword and the object reference is an actor this function will fail to operate properly. A solution is to transfer the contents of the actor's inventory to a container and call the function on that container ( Source (EN) - Source (FR)).
  • In all cases, if the object reference contains CK-Defined Leveled lists of items then this function will fail to operate properly (Source)
  • If the argument akItem is a keyword and the object reference contains CK-defined items (Object References) then this function will fail to operate properly (Source) : it fails to include the CK-defined inventory when GetItemCount tries to calculate its count.
  • Calling this function on an objectreference from the outside of its cell will return 1 in the case of the passed in form being in a leveled list. Needs more testing.. but works fine if the player is in the same cell.

That last one isn't really a bug because you can't normally do stuff to an object in an unloaded cell.

Edited by Lisselli
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...