Home   Help Search Login Register  

Author Topic: Armsty can't handle first grade OFP?  (Read 510 times)

0 Members and 1 Guest are viewing this topic.

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Armsty can't handle first grade OFP?
« on: 30 Aug 2004, 20:30:43 »
This is a really n00bish question 'cause I've been working on this dialog for days but now I'm stuck with this small piece of code. ???

Code: [Select]
_Number = ctrlText _ID
? _Number = 0 : exit
_Number = _Number - 1
ctrlsetText [_ID, format["%1", _number]]

What I am trying to do is basicly get the ctrltext from _ID, be sure it won't go negative, extract 1 and then show the new number. Fine. However, it shows up -1? So I checked it with a hint format line. Aparantley, it's this line:
? _Number = 0 : exit
that fucks up 'cause after that _number shows up 0? Before it shows up 3, as it should do. I mean, that's a very simple line!! I can't handle first grade OFP scripting?? WTF? ???

:beat: *Gets Shot* :beat:

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Armsty can't handle first grade OFP?
« Reply #1 on: 30 Aug 2004, 20:45:14 »
Hmmm... Intresting, I commented the ? _number = 0 and an error message popped up. Aparantley, _number is a string. How do I turn a string into a variable?? Any ideas?

:beat: *Gets Shot* :beat:

Offline The_Mark

  • Members
  • *
Re:Armsty can't handle first grade OFP?
« Reply #2 on: 30 Aug 2004, 20:48:14 »
Code: [Select]
_Number = ctrlText _ID
? _Number = 0 : exit
_Number = _Number - 1
ctrlsetText [_ID, format["%1", _number]]

Code: [Select]
? _Number = 0: exit
should be

Code: [Select]
? _Number == 0: exit
If you have only one =, OFP defines _Number as 0..
You ask a condition with ==.

And yes, it is a very  simple line ;D
Silent enim leges inter arma.

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Armsty can't handle first grade OFP?
« Reply #3 on: 30 Aug 2004, 20:55:02 »
Agh! However, it still is a string and won't accept the line:

_Number = _Number - 1

as it spits it out, 'cause it expects a number, not a string. :-\

:beat: *Gets Shot* :beat:

Offline The_Mark

  • Members
  • *
Re:Armsty can't handle first grade OFP?
« Reply #4 on: 30 Aug 2004, 20:55:33 »
Quote
Aparantley, _number is a string.

Damn. You got a point there. I recall seeing some kind of string-to-int function in the Ed Depot.

Or you could write your own script  ;D
Silent enim leges inter arma.

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Armsty can't handle first grade OFP?
« Reply #5 on: 30 Aug 2004, 21:00:15 »
Hooray! StringToNumber by SnYpir. Another file into the list. LCD's gonna go nuts for me taking up too much space. ;D

:beat: *Gets Shot* :beat: