ID:133761
 
Using input to call procedures or verbs with parameters

I've got 10+ inputs in my game, each effecting a different value, I do not want to create 10 verbs each handling one input. So if im inputing, 10,000,000 in various input boxes

Input 1:
ChangeStats("Agriculture",10000000)
Input 2
ChangeStats("Infrastructure",10000000)
Input 3
ChangeStats("Administration",10000000)

Having the ability to call a procedure means that differant parameters can be declared so that you can have one procedure manage all or most interface inputs. So that input could call, ChangeStats("Administration",Input)
What exactly are you asking for here? It sounds more like a developer how-to question where you forgot the question. I don't follow at all.

Lummox JR
In response to Lummox JR
Im looking to be able to call a procedure from an input on the interface. Where I could have the input call this UpdateStats("Agriculture",Input) instead of having todo this:
        proc/UpdateAgriculture(n as num)
spawn()Updatestats("Agriculture",n)
proc/UpdateInfrastructure(n as num)
spawn()Updatestats("Infrastructure",n)
proc/UpdatePropaganda(n as num)
spawn()Updatestats("Propaganda",n)
proc/UpdateEnvironment(n as num)
spawn()Updatestats("Environment",n)
proc/UpdateHealthCare(n as num)
spawn()Updatestats("Healthcare",n)
proc/UpdateEducation(n as num)
spawn()Updatestats("Education",n)
proc/UpdateTelecom(n as num)
spawn()Updatestats("Telecom",n)
proc/UpdateGovernment(n as num)
spawn()Updatestats("Government",n)
proc/ForeignAid(n as num)
spawn()Updatestats("Foreign Aid",n)
proc/Research(n as num)
spawn()Updatestats("Research",n)
proc/Tourism(n as num)
spawn()Updatestats("Tourism",n)

This would also allow me to handle all of the inputs from one procedure instead of having a verb for every single input space.
In response to Strawgate
It still doesn't make sense. Why wouldn't you be able to do this now?

Lummox JR
In response to Lummox JR
Lummox JR wrote:
It still doesn't make sense. Why wouldn't you be able to do this now?

Lummox JR

When you have an input on your interface it asks you for a default command, im asking for the ability to add constant parameters to this default command.


Default Command: ChangeStats("Agriculture",Input)

Where ChangeStats is a procedure and not a verb. I was under the impression that you can't directly call procedures from inputs, instead you have to call a verb, which would then call a procedure.

So basically if you could call procedures from the input box the code would look like this:
On interface it would look like this ChangeStats("Agriculture",Input), or maybe ChageStats "Agriculture",Input

blah/blah
ChangeStats(Type,n as num)


Which would then be seperated todo differant things depending on the type. Where as right now I have todo this.

Currently I have todo this:
Interface:
Default Command: UpdateAgriculture
blah/blah
ChangeStats(Type,n as num)
//Rest of the code which would seperate it into differant actions

//These are the verbs that would need to be called from the input default command
mob
verb
UpdateAgriculture(n as num)
spawn()Updatestats("Agriculture",n)
UpdateInfrastructure(n as num)
spawn()Updatestats("Infrastructure",n)
UpdatePropaganda(n as num)
spawn()Updatestats("Propaganda",n)
UpdateEnvironment(n as num)
spawn()Updatestats("Environment",n)
UpdateHealthCare(n as num)
spawn()Updatestats("Healthcare",n)
UpdateEducation(n as num)
spawn()Updatestats("Education",n)
UpdateTelecom(n as num)
spawn()Updatestats("Telecom",n)
UpdateGovernment(n as num)
spawn()Updatestats("Government",n)
ForeignAid(n as num)
spawn()Updatestats("Foreign Aid",n)
Research(n as num)
spawn()Updatestats("Research",n)
Tourism(n as num)
spawn()Updatestats("Tourism",n)
In response to Strawgate
Strawgate wrote:
Lummox JR wrote:
It still doesn't make sense. Why wouldn't you be able to do this now?

When you have an input on your interface it asks you for a default command, im asking for the ability to add constant parameters to this default command.

And you can do this now. In the interface file it'd look like this:

command = "ChangeStats \"Agriculture\" "


Lummox JR
In response to Lummox JR
No you can't, you can only call things that have been added to your verbs list.
In response to Nadrew
Nadrew wrote:
No you can't, you can only call things that have been added to your verbs list.

Clearly in my example the assumption is that whatever he uses, it should be a verb. The point is not the command itself but the syntax. He's acting like it's impossible to put another argument in there, which is quite wrong.

Lummox JR
In response to Strawgate
Why not do this?
proc/Update(n,area)
n=text2num(n)//incase it's text
if(isnum(n) && istext(area))//check if it's not text or a number
spawn()Updatestats(area,n)