ID:141238
 
I finally learned about Topic for the first time, so I made a poll verb and it works perfectly.

Here's that:

Client/Topic(href)
if(href == "Chh1")
if(Question == null)
usr << "That poll is already finished."
else
if(usr.Jerry != 1)
usr.Jerry = 1
Choice1a++
else
usr << "<font color=Green>The Great Kazoo: You already voted, dumb-dumb!"
if(href == "Chh2")
if(Question == null)
usr << "That poll is already finished."
else
if(usr.Jerry != 1)
usr.Jerry = 1
Choice2b++
else
usr << "<font color=Green>The Great Kazoo: You already voted, dumb-dumb!"

mob/commands
verb
Poll()
set category="Chat"
Question = input("What's the poll question?","Poll")as text
Choice1 = input("What's the first choice?","Choice 1")as text
Choice2 = input("What's the second choice?","Choice 2")as text
world << "<font color=red><font size=4>Poll by [usr]:<font size=2><b><br><br><font color=green>[Question]<font color=blue><br><br>1. <a href=?Chh1>[Choice1]</a><br><br>2. <a href=?Chh2>[Choice2]</a><br><br><font color=olive>Polling ends in 30 seconds!"
sleep(300)
if(Choice1a > Choice2b)
world << "<b><font color=red>The Poll is Over!<br><br><font color=blue>[Choice1] votes: [Choice1a]<br><font color=green>[Choice2] votes: [Choice2b]<br><br><font color=black>The winner is... <font color=Olive>[Choice1]!<font color=black><br><br>Jerry the host: <font color=green>It was anyone's guess until the very end! See you next time, on another episode of Ham Ham Rivaaaals Kiiiiiiing!!"
else if(Choice2b > Choice1a)
world << "<b><font color=red>The Poll is Over!<br><br><font color=blue>[Choice1] votes: [Choice1a]<br><font color=green>[Choice2] votes: [Choice2b]<br><br><font color=black>The winner is... <font color=Olive>[Choice2]!<font color=black><br><br>Jerry the host: <font color=green>It was anyone's guess until the very end! See you next time, on another episode of Ham Ham Rivaaaals Kiiiiiiing!!"
else if(Choice1a == Choice2b)
world << "<b><font color=red>The Poll is Over!<br><br><font color=black>Wii Sports Announcer: <font color=green>Deuce! There were [Choice1a] votes for both choices! Advantage Fail!"
else
world << "<b><font color=black>Jerry the host: <font color=green>Very dissapointing. No one voted!"
Choice1 = null
Choice2=null
Question=null
Choice1a = 0
Choice2b = 0
for(M in world)
M.Jerry = 0


HOWEVER

Now my all of my HTML forms in the game don't work at all any more, as the HTML form libary I was using also uses Topic here:

Form/SubmitForm(href,mob/U=usr,params)
usr = U
if(!form_wait_count) StartWaiting()
return Topic(href,params)

Form/Topic(href,params[])
if(usr != form_usr)
world.log << "Illegal form call by ([usr],[type])."
return //do not do normal wrapup

if(!form_sub_path)
if(form_byond_mode)
if(findtext(href,"/",1,2))
var/qry = findtext(href,"?")
form_sub_path = copytext(href,2,qry)

var/FormVar/fv
for(fv in form_vars)
var/html_name = form_var_prefix + fv.name

if(html_name in params)
var/val = params[html_name]
if(fv.interface == MULTI_SELECT || fv.interface == CHECKLIST || fv.interface == HIDDEN_LIST)
if(!istype(val,/list)) val = list(val)
var/lst[] = val
if(fv.input_type == NUM_ITYPE)
for(var/i=1,i<=lst.len,i++)
lst[i] = text2num(lst[i])
for(var/i=1,i<=lst.len,i++)
if(!(lst[i] in fv.values))
if(fv.input_type != NUM_ITYPE && (text2num(lst[i]) in fv.values))
lst[i] = text2num(lst[i])
else if(fv.validate)
world.log << "Illegal value for [fv.name] from ([usr]): ([href])."
goto wrapup
else
if(fv.input_type == NUM_ITYPE)
val = text2num(val)
if(fv.values && !(val in fv.values))
if(fv.input_type != NUM_ITYPE && (text2num(val) in fv.values))
//only some values are numeric, and this is one of them
val = text2num(val)
else if(fv.validate)
world.log << "Illegal value for [fv.name] from ([usr]): ([href])."
goto wrapup
switch(fv.interface)
if(SUBMIT)
//ignore -- bogus submit value is used to force processing of empty forms
if(RADIO_OPTION,RESET) //these should never get set
world.log << "Illegal form input from ([usr]): ([href])."
goto wrapup
if(BUTTON) //only happens when button is clicked--not when form is submitted
StartWaiting()
call(src,fv.clickproc)()
StopWaiting()
return BUTTON_CLICK
if(PROMPT)
if(form_byond_mode)
StartWaiting()
switch(fv.input_type)
if(ICON_ITYPE)
var/pval = (input(usr,fv.label || fv.name) as icon|null)
if(!pval && vars[fv.name] && alert("Retain previous setting?",,"Yes","No") == "Yes")
pval = vars[fv.name]
vars[fv.name] = pval
if(SOUND_ITYPE)
var/pval = (input(usr,fv.label || fv.name) as sound|null)
if(!pval && vars[fv.name] && alert("Retain previous setting?",,"Yes","No") == "Yes")
pval = vars[fv.name]
vars[fv.name] = pval
if(FILE_ITYPE)
var/pval = (input(usr,fv.label || fv.name) as file|null)
if(!pval && vars[fv.name] && alert("Retain previous setting?",,"Yes","No") == "Yes")
pval = vars[fv.name]
vars[fv.name] = pval
else
vars[fv.name] = call(src,fv.clickproc)()
StopWaiting()
return BUTTON_CLICK

if(fv.input_type == ICON_ITYPE || fv.input_type == SOUND_ITYPE || fv.input_type == FILE_ITYPE)
if(findtext(val,"\[") == 1)
val = locate(val)
//TODO: check file type

vars[fv.name] = val

else //no value submitted
switch(fv.interface)
if(CHECKBOX)
vars[fv.name] = null

//do sub-forms
for(fv in form_vars)
if(fv.interface == SUB_FORM)
var/Form/sf = vars[fv.name]
var/ret = sf.SubmitForm(href,usr,params)
if(ret == BUTTON_CLICK) return ret

wrapup:
StopWaiting()
return SUBMIT_CLICK


I can only have one or the other work, they conflict with eachother and I'm too much of a topic newbie to get both of them to work.

How can I have my polling Topic thingy work without making forms stop working?
PLZ FOR TEH LOVE OF GAWD help ...

I have a lot of ideas that use topic, but I can't cuz of the problem =(.
In response to MartialArtistAbu
Put ..() in your Topic() call.
In response to Nadrew
Thanks, it worked. (I really wish someone posted that simple solution 12 hours ago, though >_>. Oh well...)

(Yeah I posted this reply earlier but deleted it cuz I thought I ran into a problem again, but I fixed it so I'm posting this again :3.)