Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Helbolt
Newbie


Joined: 09 Oct 2010
Posts: 1

PostPosted: Sat Oct 09, 2010 6:22 pm   

Function won't return value I can use
 
I am trying to write a function that I can call to return the value of what next skill I want to research. Nestled within the function is a switch. I want the function to return a value that I can send directly (#SEND - or another way). So far, I cannot get the function working, nor can I get it to send anything from within the function. Can anyone help me with this? The full class code is below - i know there are other errors in it - I am mainly worried about the function and how to get the returned value to be sent. Thanks!




<class name="Library Researching (all skillsets)" initdisable="true" id="343">
<var name="stog" id="344">pil1</var>
<var name="subset" id="345">pil</var>
<trigger priority="1640" id="346">
<pattern>You can't learn any more about that from books!</pattern>
<value>subsetnum = @subsetnum+1
stog = %concat(@subset,@subsetnum)</value>
</trigger>
<var name="subsetnum" id="347">1</var>
<trigger priority="1720" id="348">
<pattern>You're not ready to learn that yet, Sorry....</pattern>
<value>XXX</value>
</trigger>
<alias name="learn" id="349">
<value>subset = %1
subsetnum = 1
stog = %concat(@subset,1)
%concat ("research ",SkillFunction(@stog))


</value>
</alias>
<func name="SkillFunction()" id="350">
<value>#FUNCTION SkillFunction(@stog)
{
#switch (@stog)
("Com1") {throw}
("Com2") {blasters}
("Com3") {vibro-blades}
("Com4") {scan}
("Com5") {kick}
("Com6") {mount}
("Com7") {grenades}
("Com8") {gouge}
("Com9") {force pikes}
("Com10") {bowcasters}
("Com11") {rescue}
("Com12") {snipe}
("Com13") {advanced vibroblade}
("Com14") {advanced blaster}
("Com15") {advanced forcepike}
("Com16") {bash}
("Com17") {second attack}
("Com18") {advanced bowcaster}
("Com19") {dodge}
("Com20") {disarm}
("Com21") {dual wield}
("Com22") {berserk}
("Com23") {enhanced damage}
("Com24") {mines}
("Com25") {grip}
("Com26") {unarmed combat}
("Com27") {hitall}
("Com28") {blaster mastery}
("Com29") {forcepike mastery}
("Com30") {aim}
("Com31") {bowcaster mastery}
("Com32") {blastdoor}
("Com33") {flurry}
("Pil1") {navigation}
("Pil2") {ship systems}
("Pil3") {small spacecraft}
("Pil4") {weapon systems}
("Pil5") {space combat 1}
("Pil6") {dock}
("Pil7") {drive}
("Pil8") {fly}
("Pil9") {tractor beams}
("Pil10") {ship maintenance}
("Pil11") {medium spacecraft}
("Pil12") {roll}
("Pil13") {emergency_refuel}
("Pil14") {shipdodge}
("Pil15") {large spacecraft}
("Pil16") {space combat 2}
("Pil17") {heavy spacecraft}
("Pil18") {space combat 3}
("Eng1") {gather}
("Eng2") {makeclothing}
("Eng3") {makecontainer}
("Eng4") {makecanteen}
("Eng5") {makecircuit}
("Eng6") {makeflashlight}
("Eng7") {makeholster}
("Eng8") {makecomlink}
("Eng9") {makegoggles}
("Eng10") {repairarmor}
("Eng11") {repairweapon}
("Eng12") {makedatapad}
("Eng13") {makejewelry}
("Eng14") {survey}
("Eng15") {enhancearmor}
("Eng16") {gemcutting}
("Eng17") {makeblade}
("Eng18") {repairhatch}
("Eng19") {tuneship}
("Eng20") {repairhull}
("Eng21") {repairdroid}
("Eng22") {makeforcepike}
("Eng23") {makeblaster}
("Eng24") {makeshield}
("Eng25") {makelandmine}
("Eng26") {makegrenade}
("Eng27") {upgradeship}
("Eng28") {makebowcaster}
("Eng29") {combine}
("Eng30") {makearmor}
("Eng31") {buildstructure}
("Eng32") {upgradedroid}
("Eng33") {imbue}
("Eng34") {makedroid}
("Eng35") {restring}
("Eng36") {buildship}
("Dip1") {research}
("Dip2") {smalltalk}
("Dip3") {bribe}
("Dip4") {setleader}
("Dip5") {propaganda}
("Dip6") {broadcast}
("Dip7") {seduce}
("Dip8") {inspirecrime}
("Dip9") {leadplanet}
("Lea1") {teach}
("Lea2") {jail}
("Lea3") {call}
("Lea4") {torture}
("Esp1") {duplicate}
("Esp2") {swipe}
("Esp3") {tail}
("Esp4") {conceal}
("Esp5") {makebinders}
("Esp6") {sabotage}
("Esp7") {makecamera}
("Esp8") {install_camera}
("Esp9") {doorcut}
("Esp10") {sharp eye}
("Esp11") {monitor_camera}
("Esp12") {camera_sweep}
("Esp13") {blackjack}
("Esp14") {makecutter}
("Sli1") {showplanet}
("Sli2") {showclan}
("Sli3") {lookup}
("Sli4") {remodulate}
("Sli5") {short}
("Sli6") {locateship}
("Sli7") {fakesignal}
("Sli8") {hack}
("Sli9") {encrypt_file}
("Sli10") {networkhack}
("Sli11") {jam}
("Sli12") {lifthack}
("Sli13") {security}
("Sli14") {decrypt_file}
("Sli15") {crackdatapad}
("Sli16") {protect_account}
("Sli17") {matchvector}
("Sli18") {disable_security}
("Med1") {aid}
("Med2") {first aid}
("Med3") {diagnose}
("Med4") {makemedpac}
("Med5") {revive}
("Med6") {fillsyringe}
("Med7") {docter}
("Med8") {inject}
("Med9") {healwound}
("Med10") {cyber}
("Med11") {clone}
("Sci1") {ponder}
("Sci2") {advanced electronic}
("Sci3") {chemistry}
("Sci4") {construction}
("Sci5") {data}
("Sci6") {estruction}
("Sci7") {edibles}
("Sci8") {education}
("Sci9") {electronics}
("Sci10") {enhancement}
("Sci11") {equipment}
("Sci12") {forensics}
("Sci13") {guidance}
("Sci14") {machines}
("Sci15") {medical}
("Sci16") {minerals}
("Sci17") {narcotics}
("Sci18") {spacecraft}
("Sci19") {study}
("Sci20") {transportation}
("Sci21") {develop}
("Sci22") {hypothesize}
("Sci23") {theorize}
}</value>
</func>
</class>
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sat Oct 09, 2010 6:36 pm   
 
First of all, please encode any scripts in code tags (you surround code with [], and close it with /code surrounded by []).

Second, your function isn't proper. Functions are supposed to #RETURN something. In your case, you'd want to do something like:

#RETURN %switch(@stog, "com1", "throw", "com2", "blasters" ... etc).

However, you're probably better off making the com1 stuff as a key in a database variable with the value being the throw stuff. For example:

#ADDKEY researchdb {com1} {throw}
#ADDKEY researchdb {com2} {blasters}
etc.

That way, in your scripts, you can do:

research %db(@researchdb, @stog).

Charneus
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net