Home   Help Search Login Register  

Author Topic: publicVariable "array" not possible?  (Read 2042 times)

0 Members and 3 Guests are viewing this topic.

Rubble_Maker

  • Guest
publicVariable "array" not possible?
« on: 03 Apr 2003, 23:38:37 »
Just read in another thread that publicVariable doesn't work with strings or array, can anybody confirm me on that?


Tactician

  • Guest
Re:publicVariable "array" not possible?
« Reply #1 on: 04 Apr 2003, 03:45:50 »
It's true.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:publicVariable "array" not possible?
« Reply #2 on: 04 Apr 2003, 03:55:03 »
Yep. This drove me nuts too when I found out. Write it in stone, take a picture, and move on.   :(

There is allways OFP2!
« Last Edit: 04 Apr 2003, 03:55:32 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Rubble_Maker

  • Guest
Re:publicVariable "array" not possible?
« Reply #3 on: 04 Apr 2003, 15:20:19 »
Allright thx for the quick reply. I figure its possible to use arrays and strings anyways, if you just chop them to pieces before sending (using metavariables to broadcast individual elements via PublicVariable). But thats a PITA indeed!

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:publicVariable "array" not possible?
« Reply #4 on: 05 Apr 2003, 07:41:35 »
Allright thx for the quick reply. I figure its possible to use arrays and strings anyways, if you just chop them to pieces before sending (using metavariables to broadcast individual elements via PublicVariable). But thats a PITA indeed!

Sending arrays seems possible, though I making it reliable is another question.

As for strings, there are no OFP scripting commands for manipulating strings, so it's seems sending strings is impossible. If OFP had a command that could break a string down into it induvidual characters, or treat strings as arrays, it would be fairly easy.
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Rubble_Maker

  • Guest
Re:publicVariable "array" not possible?
« Reply #5 on: 06 Apr 2003, 11:30:22 »
I haven't looked at this stuff yet, toadlife, but can't the Format/ForEach commands be used ("abused" seems to be the better word here) to break strings into chars (gotta take a look at that string->number function, it uses some similar trick)?

Well, as far as for addons there's another possibility as well. Most addons with MP-scripting require the user to run a script file (client-server loop) from the init.sqs anyways (because of all the local commands in OFP), so why not distribute the arrays/strings using that script? Exchanging values from one client to another would still not be possible directly, but the client-server loop could wait for a signal to change an array or string on all clients. That way we have global arrays or strings on each client, and we can fake the broadcasting by letting the script change the arrays on each client. For example, the client-server script could receive a signal together with a value and a position, to put that value into the array (at the specified position).
I know thats a crummy solution, but still better than nothing ;)


Tactician

  • Guest
Re:publicVariable "array" not possible?
« Reply #6 on: 06 Apr 2003, 20:40:35 »
If you used stringTable.csv, you could pre-arrange any number of strings and then just pass the number reference as a single variable.  Could also just define strings as variables for everyone, such as:

stringOne = "Bunker"
stringTwo = "Farmhouse"
stringThree = "Roadblock"

Then make an array..

stringArray = [stringOne,stringTwo,stringThree]

And publicVariable the string reference..

stringRef = 1; publicVariable "stringRef"
showString = true; publicVariable "showString"

With a script to capture it..

@showString
hint format["I am near the %1", (stringArray select stringRef)]

Which comes out as "I am near the Farmhouse".

Look at BIS missions for examples of "localize" and "stringtable.csv".

And sending a string character-by-character would require a declared variable for each character, not something I'd want to do :P

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re:publicVariable "array" not possible?
« Reply #7 on: 06 Apr 2003, 21:30:58 »
Quote
thx for the quick reply. I figure its possible to use arrays and strings anyways, if you just chop them to pieces before sending (using metavariables to broadcast individual elements via PublicVariable). But thats a PITA indeed!  

Over at the CoC, bn880's developing a MP comms suite.  Building on his comms stuff, I did exactly that to create a "PublicArray" function.  So stay tuned.
Bn880's also got stuff to transmit strings, but they have to be "broken down" before transmitting. (in other words, you can type in "I am at the farmhouse" into a dialog, and it will send it to someone and reconstruct it",  but you can't take a string (say "I AM AT THE FARMHOUSE" and send it across directly.

« Last Edit: 06 Apr 2003, 21:33:38 by Dinger »
Dinger/Cfit

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:publicVariable "array" not possible?
« Reply #8 on: 06 Apr 2003, 22:48:06 »
I haven't looked at this stuff yet, toadlife, but can't the Format/ForEach commands be used ("abused" seems to be the better word here) to break strings into chars (gotta take a look at that string->number function, it uses some similar trick)?

As far as I know, the only commands that process strings are these....

stringa + stringb
format["blah %1",stringa]
call stringa

If there were only a command like this....
"aac" - "c" = "aa"

or this....
explodestring "aac" = [a,a,c]

For now the method Tactician described, allthough tedious, is the best method I can see of simulating the sending of strings.
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re:publicVariable "array" not possible?
« Reply #9 on: 07 Apr 2003, 00:56:48 »
Right.  There's no way to convert a string.
On the bright side, this is a non-issue for all but one situation.
For most comms that you want to use involving strings, you can translated the string into a representative integer.  After all, everybody's using the same mission.  So:
MissionStrings = ["Hello", "Hi", "GoodBye", "BiteMe"]

Message = 2
publicvariable "Message"
---
the only case where this won't work is where you want the player to specify (via dialog) a string, and transmit it.  And in that case, Bn880 has a system he's working on.
Dinger/Cfit